DrawVectorText
Posted: Thu May 07, 2020 7:19 pm
It is possible to use 'BackColor' with DrawVectorText ?
Thank you very much for the replies
Thank you very much for the replies
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