1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| ; fonction - imagefont - pf shadoko - 2016
CompilerIf #PB_Compiler_OS<>5
Macro doevents:Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow:EndMacro
CompilerElse
Macro doevents:i=i:EndMacro
CompilerEndIf
;####################################################################################
Procedure SortIdx(Array t.l(1),Array idx.l(1),deb=0, fin=-1)
Protected min,i,j,v,idmin
If fin=-1: fin=ArraySize(t()):EndIf
Dim idx(fin)
For i=deb To fin:idx(i)=i:Next
For i=deb To fin
min=$7fffffff
For j=i To fin
v=t(idx(j))
If v<min:min=v:idmin=j:EndIf
Next
Swap idx(i),idx(idmin)
Next
EndProcedure
Procedure initIF(image,centerX.l=-1,centerY=-1)
;image : numero de l'image
;centerx/y : definit le centre de l'image
Structure IFsij
i.b
j.b
EndStructure
Protected i,j,n,di,dj
Protected idx=ImageWidth(image):If centerX<0:centerX=idx/2:EndIf
Protected idy=ImageHeight(image):If centery<0:centery=idy/2:EndIf
Protected Dim IFdis.l(idx * idy-1)
Global Dim IFidx.l(idx * idy-1)
Global Dim IFbmp.l(idx-1,idy-1)
Global Dim IFpos.IFsij(idx * idy-1)
StartDrawing(ImageOutput(image))
DrawingMode(#PB_2DDrawing_AllChannels)
For j=0 To idy-1
For i=0 To idx-1
IFbmp(i,j)=Point(i,j)
IFpos(n)\i=i:di=i-centerX
IFpos(n)\j=j:dj=j-centerY
;IFdis(n)=di*di+dj*dj
IFdis(n)=Abs(di)+Abs(dj)
n+1
Next
Next
StopDrawing()
sortidx(IFdis(),IFidx())
EndProcedure
Procedure DrawTextIF(x,y,text.s)
Protected n,nn=ArraySize(IFidx())
DrawingMode(#PB_2DDrawing_Transparent |#PB_2DDrawing_AlphaBlend)
For n=0 To nn
With IFpos(IFidx(nn-n))
If Alpha(IFbmp(\i,\j)):DrawText(x+\i,y+\j,text,IFbmp(\i,\j)):EndIf
EndWith
Next
EndProcedure
;####################################################################################
Procedure exemple()
EnableExplicit
Protected i,j,n,idx=800,idy=600
For n=0 To 7
CreateImage(10+n,16,16,32,#PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(10+n))
Select n
Case 0
VectorSourceCircularGradient(8-3,8-3,10)
VectorSourceGradientColor($ffffffff, 0.0)
VectorSourceGradientColor($ffffaaaa, 0.4)
VectorSourceGradientColor($ff886666, 1.0)
VectorSourceGradientColor($00886666, 1.0)
AddPathCircle(8,8,7):FillPath()
Case 1
AddPathBox(11,11,4,4):VectorSourceColor($08000000):FillPath()
AddPathBox(8,8,2,2):VectorSourceColor($ff0000ff):FillPath()
Case 2
AddPathCircle(12,12,3):VectorSourceColor($11000000):FillPath()
AddPathCircle(8,8,3)
VectorSourceColor($ff008800):FillPath(#PB_Path_Preserve)
VectorSourceColor($ffffffff):StrokePath(2)
Case 3
AddPathBox(6,6,4,4)
VectorSourceColor($ffaaaaff):FillPath(#PB_Path_Preserve)
VectorSourceColor($ffffffff):StrokePath(1)
AddPathBox(6,10,4,4):VectorSourceColor($ff8888ff):FillPath()
Case 4
VectorSourceCircularGradient(8,8,7)
VectorSourceGradientColor($ff008800, 0.0)
VectorSourceGradientColor($ff00ffff, 0.8)
VectorSourceGradientColor($0000ffff, 1.0)
FillVectorOutput()
Case 5
AddPathCircle(8,8,7):VectorSourceColor($ffffffff):FillPath()
AddPathCircle(8,8,1):VectorSourceColor($ff0000ff):StrokePath(1)
AddPathCircle(8,8,4):VectorSourceColor($ff0000ff):StrokePath(1)
Case 6
RandomSeed(1)
For i=0 To 15
AddPathBox(Random(8)+4,Random(8)+4,1,1)
VectorSourceColor(RGBA(0,Random(255),0,$44)):FillPath()
Next
Case 7
AddPathBox(11,11,4,4):VectorSourceColor($10000000):FillPath()
AddPathBox(7,7,4,4):VectorSourceColor($ffff4444):FillPath()
AddPathBox(5,5,4,4):VectorSourceColor($ffffbbbb):FillPath()
AddPathBox(6,6,4,4):VectorSourceColor($ffff8888):FillPath()
EndSelect
StopVectorDrawing()
Next
LoadFont(0, "Courier New", 45)
CreateImage(0,idx,idy,32,$888888)
StartDrawing(ImageOutput(0))
For j=0 To idx Step 16
For i=16 To idx Step 16
Box(i,j,16,16,($a0+(i+j) & $10) * $010101)
Next
Next
StopDrawing()
For i=0 To 7
initif(10+i)
StartDrawing(ImageOutput(0))
DrawingFont(FontID(0))
DrawTextif(20,i*72,"BONJOUR tout le monde")
DrawAlphaImage(ImageID(10+i),0,30+i*72)
StopDrawing()
Next
OpenWindow(0, 0, 0, idx, idy, "test4", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(0, 0, 0, idx, idy,ImageID(0))
doevents
EndProcedure
exemple() |
Partager