Bordered Text

This is the first in a collection of code snippets on this site. This code snippet requires that you download the D3D Plugin for Dark Basic Pro. This effect can be achieved with native DBP, but the text commands in the D3D plugin are faster and look better, so you’d be a fool to not grab it. πŸ™‚ You can find it here.

A quick explanation. This plugin uses Font IDs, so just drop a command like this to make the font ID for my snippet:

D3D_FONT 1, “Arial”, 16, 1, 0, 1

 

And when using text you have to use ‘d3d_starttext’ at the beginning and ‘d3d_endtext’ at the end. Do it for where you place your text – don’t put them at the beginning and end of your loop, because they can conflict with other commands (for example, paste image).

Anyway, here is the function:

function Border_Text(ID, x,y hor, body$)

D3D_text ID, x+2,y, hor, body$, D3D_RGBA(0,0,20,255)
D3D_text ID, x-2,y, hor, body$, D3D_RGBA(0,0,0,255)
D3D_text ID, x+2,y+2, hor, body$, D3D_RGBA(0,0,0,255)
D3D_text ID, x-2,y+2, hor, body$, D3D_RGBA(0,0,0, 255)
D3D_text ID, x,y+2, hor, body$, D3D_RGBA(0,0,0, 255)
D3D_text ID, x,y-2, hor, body$, D3D_RGBA(0,0,0, 255)
D3D_text ID, x+2,y-2, hor, body$, D3D_RGBA(0,0,0, 255)
D3D_text ID, x-2,y-2, hor, body$, D3D_RGBA(0,0,0, 255)

D3D_text ID, x,y, hor, body$, D3D_RGBA(255,255,255,255)

ENDFUNCTION

Very simple. TextID is the font, X & Y is the position on the screen, ‘Hor’ is the text’s horizontal alignment 0 = left, 1 = middle, 2= right and body$ is your text content.

So in a code you might do this with it:

D3d_INIT

D3d_FONT, 1, “Calibri”, 16, 1, 0, 1

do

d3d_starttext

Border_text(1, 30, 30, 0, “Hello The Old Chaps”)

Border_Text(1, 30, 70, 0, “I like CHEEEEESE!!!”)

d3d_endtext

if returnkey() = 1 the end

loop

 

 

 

Shimples. πŸ˜‰

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s