multicolored fonts

Previous topic - Next topic

Corax


Hemlos

Please, if you can use the forums to store your projects, do so..

that zdshare place messes up my browser.....so much junk built into that site.
Bing ChatGpt is pretty smart :O

Corax

What happened ?

Maybe we should install something like the showroom for code-snippets.

Besides: this function may interest beginners, its nothing for advanced programmers.

Hemlos

#3
Dont need to add anything...


Just click Additional Options... at the bottom of your message.

See look i can attach a picture:


[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

9940

#4
I made a small improvement.

Code (glbasic) Select

SETTRANSPARENCY RGB(255, 255, 255)
LOADFONT "font.png", 1
SETFONT 1
SETTRANSPARENCY RGB(255, 0, 128)

PRINTCOLOR("Red text", 0, 0, RGB(255, 0, 0))
SHOWSCREEN
MOUSEWAIT


FUNCTION PRINTCOLOR: output$, x, y, color
    LOCAL tx, ty
    GETFONTSIZE tx, ty
    LOCAL tw = LEN(output$) * tx

    GRABSPRITE 0, x, y, tw, ty
    DRAWRECT x, y, tw, ty, color
    PRINT output$, x, y
    GRABSPRITE 1, x, y, tw, ty
    DRAWSPRITE 0, x, y
    DRAWSPRITE 1, x, y
ENDFUNCTION



Hemlos

@9940 :

have you even tested that function?
It does the opposite of color a font...it colors the background...

..also you cant use PRINT as the beginning of a function name.
Bing ChatGpt is pretty smart :O

9940

Quote
It does the opposite of color a font...it colors the background...
You used a wrong font img, try this



Quote
..also you cant use PRINT as the beginning of a function name.
Rename it to COLORPRINT and add PRINTCOLOR to Gernot's bug list  ;)

Kitty Hello

Do no use CAPITAL_ONLY_COMMANDS. They're mine :P

Hemlos

Ok i couldnt get yours to work with the glbasic fonts so i whipped up my own rendition.

However, instead of drawrect etc...try poly vectors...theyre prettier.

here is my version of what you made, you can use standard glbasic fonts with it...

i dont know what good it is...probably good for just making text images.

[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

9940

#9
Are you talking about the speed?
There is a little problem in your func.

Code (glbasic) Select

FUNCTION PRINCOOR: output$, x, y, color

  [some code]

  LOADFONT "smalfont.png",0
  SETFONT 0
  [some code]

ENDFUNCTION


This func. call LOADFONT every time is used which is a big waste of time

   
There is a reason why the background is pink: the default background of the sprites is pink and so there is no need to call every time SETTRANSPARENCY. Only if you use other sprite.

9940

#10
Benchmark for COLORPRINT (up to 30 strings on my pc)

However with PRINT you can write more than 1500 strings without suffering slowdowns...
Depends on what you have to write  =D

[attachment deleted by admin]

Kitty Hello

using polyvector for coloured fonts might be slightly faster. Grabsprite or createscreen are quite expensive.
Also, instead of GRABSPRITE try CREATESCREEN. It *might* be faster.

9940

The func. with CREATESCREEN is more slowly than GRABSPRITE and the sprites created with CREATESCREEN hasn't transparency.