Code : Tout sélectionner
; new position of the vector cursor position after drawing ;nouvelle position de la position du curseur vectoriel après le dessin
EnumerationBinary
#VCP_MoveToEnd ;add text width to starting cursor position ;ajouter la largeur du texte à la position de départ du curseur
#VCP_MoveDown ;add text height to starting cursor position ;ajouter la hauteur du texte à la position de départ du curseur
#VCP_NoMove = 0 ;leave original cursor position unchanged ;laisser la position d'origine du curseur inchangée
EndEnumeration
;Draws the text in RGBA 'fcolor' with a shadow in RGBA 'ucolor' at 'offsetX' and 'offsetY' from the text and move the cursor to the 'new position' relative to the text
;Dessine le texte en RGBA 'fcolor' avec une ombre en RGBA 'ucolor' à 'offsetX' et 'offsetY' à partir du texte et déplace le curseur vers la 'nouvelle position' par rapport au texte
Procedure DrawShadowText(Text.s, offsetX= 5, offsetY = 5, fcolor = $FF0000FF, ucolor = $00000040, newPosition = #VCP_NoMove)
Protected x.d, y.d
;draw shadow ;dessiner une ombre
VectorSourceColor(ucolor)
MovePathCursor(offsetX, offsetY, #PB_Path_Relative)
DrawVectorText(Text)
;draw text ;dessiner du texte
MovePathCursor(-offsetX - VectorTextWidth(Text), -offsetY, #PB_Path_Relative)
VectorSourceColor(fcolor)
DrawVectorText(Text)
;update vector cursor position ;mettre à jour la position du curseur vectoriel
x = - VectorTextWidth(Text)
y = VectorTextHeight(Text)
If newPosition = #VCP_NoMove
y = 0
Else
If newPosition & #VCP_MoveToEnd
x = 0
EndIf
If newPosition & #VCP_MoveDown <> #VCP_MoveDown
y = 0
EndIf
EndIf
MovePathCursor(x, y, #PB_Path_Relative)
EndProcedure
OpenWindow(0, 0, 0, 800, 400, "test", #PB_Window_SystemMenu)
CanvasGadget(0, 0, 0, 800, 400)
LoadFont(0, "broadway", 120) ;arbitrary fonts ;polices arbitraires
LoadFont(1, "goudy", 120)
StartVectorDrawing(CanvasVectorOutput(0))
VectorFont(FontID(0))
DrawShadowText("BIGGER", 10, 10, RGBA(255, 0, 0, 255), RGBA(255, 0, 0, 64), #VCP_MoveDown)
VectorFont(FontID(1))
DrawShadowText("smaller", 6, 6, RGBA(0, 0, 255, 128), RGBA(0, 0, 0, 32), #VCP_MoveToEnd)
DrawShadowText("12345", 4, 8, RGBA(0, 255, 0, 255), RGBA(0, 255, 0, 64), #VCP_MoveDown)
VectorFont(FontID(0), 24)
DrawShadowText("ABCDEF", 2, 4, RGBA(128, 0, 128, 255), RGBA(128, 0, 128, 128), #VCP_MoveDown)
StopVectorDrawing()
Repeat
event = WaitWindowEvent()
If event = #PB_Event_CloseWindow
End
EndIf
ForEver