Author Topic: Altering the colour and size of GLBasics preset Font  (Read 3630 times)

Offline I love my Brick

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
Just thought this might be handy for new projects.  Instead of bothering with a new font set why not enlarge the original and effect its colour value.  The code grabs a line of text as a sprite and then messes with its RED value - no need to look at GREEN & BLUE cos they are all 255.  It then doubles the size of the sprite and makes it more readable on screen.  Handy for laying out the text on screen.


...

Code: (glbasic) [Select]
example=500 ; newone=501

PRINT "A COLOURED FONT TO PLAY WITH",0,0

GRABSPRITE example,0,0,256,10

CLEARSCREEN

//////////////////////////////////////////////////////

FOR ypos=0 TO 500 STEP 8 ; DRAWSPRITE example,100,ypos

GOSUB recolourgraphics

DRAWSPRITE newone,200,ypos

ZOOMSPRITE newone,RND(600),RND(600),2,2

INC newcol,RND(25)

NEXT

SHOWSCREEN

KEYWAIT

///////////////////////////////////////////////////////

SUB recolourgraphics:

GLOBAL dotz%[]

SPRITE2MEM(dotz%[], example)
 
FOREACH d% IN dotz%[]
       
        d=changecol(d)

NEXT

LOCAL width%, height%

GETSPRITESIZE example, width, height

MEM2SPRITE(dotz%[], newone, width%, height%)       

ENDSUB


FUNCTION changecol%: colour%
 
LOCAL r% = bAND(colour%        , 0xff)
       
IF r>140 // NOTE: Changing this value will alter the font

 RETURN 0xff000000 + RGB(RND(255),255,newcol)

ENDIF

ENDFUNCTION

« Last Edit: 2012-Jun-11 by Schranz0r »
I like things and do stuff.

Offline I love my Brick

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
Ive used it for "score", "lifes" etc in past early projects without needing to design or load a font.
I like things and do stuff.

Offline Albert

  • Dr. Type
  • ****
  • Posts: 257
    • View Profile
    • Blog
That's really nice!

Offline CW

  • Mr. Polyvector
  • ***
  • Posts: 155
    • View Profile
Very nice, Brick!  :good:

Your trick allows the use of Rotozoomsprite (instead of zoomsprite) for interesting effects. Try:
Code: (glbasic) [Select]
ROTOZOOMSPRITE newone,RND(600),RND(600),-45+RND(90),RND(30)
-CW
« Last Edit: 2013-Mar-05 by CW »