Emboss Text Function by MjG000114th Jun 2012 9:32
|
---|
Summary Emboss text 8 different ways with a single command. Description Embossing creates the illusion of shade and depth. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com remstart Title: emboss_text(x,y,s$,e,c,d,a) Version: 1.0 Language: Dark Basic Professional 1.077 Developer: Michael James Garrett Company: The Game Creators Copyright: No Restrictions Development Period: 6/14/2012 - 6/14/2012 Minimum HW Requirements: NA Description: Embossing creates the illusion of shade and depth. Draws embossed text at the x,y coordinates specified, using the emboss color and color specified. Emboss direction can be specified using 0-8 (clockwise). 0-7 specifies a direction for emboss and 8 embosses from every direction. The amount (distance from emboss text to regular text) can also be specified. Warnings: NA Algorithm: 1.) If d=0 then emboss the top 2.) If d=1 then emboss the top right 3.) If d=2 then emboss the right 4.) If d=3 then emboss the bottom right 5.) If d=4 then emboss the bottom 6.) If d=5 then emboss the bottom left 7.) If d=6 then emboss the left 8.) If d=7 then emboss the top left 9.) If d=8 then emboss all around the text Varibles: a integer amount c double color d integer direction of emboss e double emboss color i integer index x integer x ordinate y integer y ordinate xo integer x offset yo integer y offset Error Handling: NA Function Tests: NA Test Driver: set text font "Ariel" : set text size 80 do : for i=0 to 8 cls set text size 20 : ink rgb(255,255,255),0 : text 10,10,"Mode: "+str$(i) set text size 80 : emboss_text(100,100,"Hello World",rgb(255,255,255),rgb(190,190,190),i,5) wait key next i : loop : end Notes: NA Revision History: NA Suggestions For Improvement: - Possibly add center text option. remend function emboss_text(x,y,s$,e,c,d,a) if d=0 ink e,0 : text x,y,s$ inc y,a ink c,0 : text x,y,s$ endif if d=1 ink e,0 : text x,y,s$ dec x,a : inc y,a ink c,0 : text x,y,s$ endif if d=2 ink e,0 : text x,y,s$ dec x,a ink c,0 : text x,y,s$ endif if d=3 ink e,0 : text x,y,s$ dec x,a : dec y,a ink c,0 : text x,y,s$ endif if d=4 ink e,0 : text x,y,s$ dec y,a ink c,0 : text x,y,s$ endif if d=5 ink e,0 : text x,y,s$ inc x,a : dec y,a ink c,0 : text x,y,s$ endif if d=6 ink e,0 : text x,y,s$ inc x,a ink c,0 : text x,y,s$ endif if d=7 ink e,0 : text x,y,s$ inc x,a : inc y,a ink c,0 : text x,y,s$ endif if d=8 ink e,0 for i=1 to 8 if i=>2 and i=<4 then xo=-a if i=1 or i=5 then xo=0 if i=>6 and i=<8 then xo=a if i=>4 and i=<6 then yo=-a if i=3 or i=7 then yo=0 if i=>1 and i=<2 or i=8 then yo=a text x+xo,y+yo,s$ next i ink c,0 : text x,y,s$ endif endfunction |