Voici ma modeste contribution :
Comment écrire un texte incurvé pour légender un camembert par exemple ou des segments de cercle.
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 400, 400, "Texte incurvé", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 400)
LoadFont(0, "Arial", 14, #PB_Font_HighQuality|#PB_Font_Bold)
Texte0$ ="Secteur 0 haut"
Texte1$ ="Secteur 1 haut"
Texte2$ ="Secteur 2 haut"
Texte3$ ="Secteur 3 bas"
Texte4$ ="Secteur 4 bas"
Texte5$ ="Secteur 5 bas"
If StartVectorDrawing(CanvasVectorOutput(0))
X_Centre = 200
Y_Centre = 200
Long_branche = 170
Dgr_Rad.f = #PI/180
Taille_p.l = 12
VectorSourceColor(RGBA(211, 211, 211, 255))
For j = 0 To 5
MovePathCursor(X_Centre,Y_Centre)
Angle_valeur = (360 / 6 * j) - 90
X_valeur = X_Centre + (Cos(Dgr_Rad * (Angle_valeur - 30)) * (Long_branche + 20))
Y_valeur = Y_Centre + (Sin(Dgr_Rad * (Angle_valeur - 30)) * (Long_branche + 20))
AddPathLine(X_valeur , Y_valeur)
StrokePath(1)
Next
VectorFont(FontID(0), Taille_p)
VectorSourceColor(RGBA(0, 0, 0, 255))
larc = 60/360 *2 * 3.14 * Long_branche
Debug larc
Long.f = VectorTextWidth(texte0$)
Ltarc0 = Long / larc * 60
RotateCoordinates(X_Centre,Y_Centre,-60 - ((Ltarc0) / 2))
For i =1 To Len(Texte0$)
lettre$ = Mid(Texte0$,i,1)
MovePathCursor(X_Centre,Y_Centre - Long_branche - Taille_p)
DrawVectorText(lettre$)
RotateCoordinates(X_Centre,Y_Centre,Ltarc0/Long*VectorTextWidth(lettre$))
Next
ResetCoordinates()
Long.f = VectorTextWidth(texte1$)
Ltarc1 = Long / larc * 60
RotateCoordinates(X_Centre,Y_Centre, - (Ltarc1 / 2))
For i =1 To Len(Texte1$)
lettre$ = Mid(Texte1$,i,1)
MovePathCursor(X_Centre,Y_Centre - Long_branche - Taille_p)
DrawVectorText(lettre$)
RotateCoordinates(X_Centre,Y_Centre,Ltarc1/Long*VectorTextWidth(lettre$))
Next
ResetCoordinates()
Long.f = VectorTextWidth(texte2$)
Debug "l2=" + Str(Long)
Ltarc2 = Long / larc * 60
RotateCoordinates(X_Centre,Y_Centre, 60 - ((Ltarc2) / 2))
For i =1 To Len(Texte2$)
lettre$ = Mid(Texte2$,i,1)
MovePathCursor(X_Centre,Y_Centre - Long_branche - Taille_p)
DrawVectorText(lettre$)
RotateCoordinates(X_Centre,Y_Centre,Ltarc2/Long*VectorTextWidth(lettre$))
Next
ResetCoordinates()
Long.f = VectorTextWidth(texte3$)
Ltarc3 = Long / larc * 60
RotateCoordinates(X_Centre ,Y_Centre, -60 + ((Ltarc3) / 2))
For i =1 To Len(Texte3$)
lettre$ = Mid(Texte3$,i,1)
MovePathCursor(X_Centre ,Y_Centre + Long_branche )
DrawVectorText(lettre$)
RotateCoordinates(X_Centre,Y_Centre,-Ltarc3/Long*VectorTextWidth(lettre$))
Next
ResetCoordinates()
Long.f = VectorTextWidth(texte4$)
Ltarc4 = Long / larc * 60
RotateCoordinates(X_Centre ,Y_Centre,((Ltarc4) / 2))
For i =1 To Len(Texte4$)
lettre$ = Mid(Texte4$,i,1)
MovePathCursor(X_Centre ,Y_Centre + Long_branche )
DrawVectorText(lettre$)
RotateCoordinates(X_Centre,Y_Centre,-Ltarc4/Long*VectorTextWidth(lettre$))
Next
ResetCoordinates()
Long.f = VectorTextWidth(texte5$)
Ltarc5 = Long / larc * 60
RotateCoordinates(X_Centre ,Y_Centre,60 + ((Ltarc5) / 2))
For i =1 To Len(Texte5$)
lettre$ = Mid(Texte5$,i,1)
MovePathCursor(X_Centre ,Y_Centre + Long_branche )
DrawVectorText(lettre$)
RotateCoordinates(X_Centre,Y_Centre,-Ltarc5/Long*VectorTextWidth(lettre$))
Next
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf