Page 1 of 1

DrawVectorText

Posted: Thu May 07, 2020 7:19 pm
by Lima
It is possible to use 'BackColor' with DrawVectorText ?
Thank you very much for the replies

Re: DrawVectorText

Posted: Fri May 08, 2020 10:39 am
by Olliv
No. You have however two alternatives :

1) DrawRotatedText() (lib 2dDrawing)
2) AddPathBox() (lib VectorDrawing requires color adapting)

Re: DrawVectorText

Posted: Fri May 08, 2020 1:13 pm
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

Re: DrawVectorText

Posted: Fri May 08, 2020 5:15 pm
by Lima
Hello my friends.
Your ideas are a big help.

Thank you so much for everything.