DrawVectorText

Just starting out? Need help? Post your questions and find answers here.
Lima
User
User
Posts: 43
Joined: Tue Jul 14, 2015 2:52 pm

DrawVectorText

Post by Lima »

It is possible to use 'BackColor' with DrawVectorText ?
Thank you very much for the replies
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: DrawVectorText

Post by Olliv »

No. You have however two alternatives :

1) DrawRotatedText() (lib 2dDrawing)
2) AddPathBox() (lib VectorDrawing requires color adapting)
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: DrawVectorText

Post by Saki »

Hello,
You mean like this ?

Code: Select all

; Vector text output, for image and canvas

EnableExplicit

Procedure VectorText(text$, output, output_x, output_y, font, color_text=#White, color_background=#Black, alpha_text=255, alpha_background=255)
  
  If IsGadget(output)
    Protected back_value = StartVectorDrawing(CanvasVectorOutput(output))
  Else
    back_value = StartVectorDrawing(ImageVectorOutput(output))
  EndIf
  
  If back_value
    VectorFont(FontID (font))
    VectorSourceColor(RGBA(Red(color_background), Green(color_background), Blue(color_background), alpha_background))
    AddPathBox(output_x, output_y, VectorTextWidth(text$), VectorTextHeight(text$))
    FillPath()
    VectorSourceColor(RGBA(Red(color_text), Green(color_text), Blue(color_text), alpha_text))
    MovePathCursor (output_x, output_y)
    DrawVectorText(text$)
    StopVectorDrawing()
    ProcedureReturn 1
  EndIf
  
  ProcedureReturn 0
  
EndProcedure

Define window = OpenWindow(#PB_Any, 0, 0, 800, 600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Define canvas = CanvasGadget(#PB_Any, 0, 0, 800, 600)

Define font = LoadFont(#PB_Any, "", 36, #PB_Font_Bold)
Define font_1 = LoadFont(#PB_Any, "", 12, #PB_Font_Bold)

Define text$ = "  Hello Lima, how are you ?"+#LF$+"  Also multiline"

Define output_x = 80
Define output_y = 100
Define color_text = #Green
Define color_background = #Blue
Define alpha_text = 255
Define alpha_background = 255

VectorText(text$, canvas, output_x, output_y, font, color_text, color_background, alpha_text, alpha_background)

VectorText(text$, canvas, 280, 350, font_1)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by Saki on Sun May 10, 2020 3:35 pm, edited 1 time in total.
地球上の平和
Lima
User
User
Posts: 43
Joined: Tue Jul 14, 2015 2:52 pm

Re: DrawVectorText

Post by Lima »

Hello my friends.
Your ideas are a big help.

Thank you so much for everything.
Post Reply