Page 1 sur 1

Comment faire un texte flou en VectorDrawing ?

Publié : ven. 07/août/2020 21:57
par Shadow
Bonsoir,

Je voudrais faire du texte avec des ombres mais il faudrait pouvoir flouter un texte (Ombre)
Je ne sais pas comment faire un texte avec Ombre en VectorDrawing !
Comment ont fait svp ?

Re: Comment faire un texte flou en VectorDrawing ?

Publié : sam. 08/août/2020 3:20
par Demivec
Une manière:

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

Re: Comment faire un texte flou en VectorDrawing ?

Publié : sam. 08/août/2020 7:29
par Shadow
Bonjour Demivec :)

Je te remercie pour ton exemple sympathique :)
J'ai fais aussi ce genre de chose et je n'en ai pas été satisfais :(

Je ne trouve pas le résultat extraordinaire, et plus le texte est petit et pire c'est !
Il faudrait un texte flouté (Ombre).

Merci.
Cordialement.

Re: Comment faire un texte flou en VectorDrawing ?

Publié : sam. 08/août/2020 9:07
par Patrick88
marrant sous linux, je n'ai que le gros texte "bigger" pas les autres

Code : Tout sélectionner

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()
Image

Re: Comment faire un texte flou en VectorDrawing ?

Publié : sam. 08/août/2020 9:55
par Shadow
C'est normale, Linux est Anti Ombre :mrgreen: