The library "VectorDrawing" poses big problems (slowness, leak memory),
I made a new version
compared to PB, many functions (or options) are missing
some are however easy to achieve,
others, on the other hand, poses problems:
AddPathSegments
AddPathText
BeginVectorLayer
PathBoundsX, PathLength ...
it may be possible with the prototype, but I am not yet very competent in JS.
If someone has ideas ...
in any case this version is very useful,
I hope you will also find it useful
http://cg.racine.free.fr/demo/
Code: Select all
;##############################################################################################################################################
; VectorDrawing - new version
; Pf Shadoko - 2017
;##############################################################################################################################################
;{
!ctx=0;
Global.d canvascx,canvascy
Declare _StrokePath(w.d,f=0)
Procedure.s jscolor(c.l)
ProcedureReturn "RGBA("+Str(Red(c))+","+Str(Green(c))+","+Str(Blue(c))+","+StrF(Alpha(c)/255)+")"
EndProcedure
Procedure.s jslinecap(f)
Protected lc.s
Select f & ~ #PB_Path_Preserve
Case #PB_Path_Default
lc= "butt"
Case #PB_Path_RoundEnd
lc= "round"
Case #PB_Path_SquareEnd
lc= "square"
EndSelect
ProcedureReturn lc
EndProcedure
Procedure _ImageVectorOutput(n)
ProcedureReturn ImageOutput(n)
EndProcedure
Procedure _CanvasVectorOutput(n)
ProcedureReturn CanvasOutput(n)
EndProcedure
Procedure _AddPathArc(x1.d,y1.d,x2.d,y2.d,radius.d,flags=0)
!ctx.arcTo(v_x1,v_y1,v_x2,v_y2,v_radius);
EndProcedure
Procedure _AddPathBox(x.d,y.d,w.d,h.d)
!ctx.rect(v_x,v_y,v_w,v_h);
EndProcedure
Procedure _AddPathCircle(x.d,y.d,radius.d,startangle.d=0,endangle.d=360,flags=0)
startangle=Radian(startangle)
endangle=Radian(endangle)
!ctx.moveTo(v_x+v_radius*Math.cos(v_startangle),v_y+v_radius*Math.sin(v_startangle));
!ctx.arc(v_x,v_y,v_radius,v_startangle,v_endangle);
EndProcedure
Procedure _AddPathCurve(x1.d,y1.d,x2.d,y2.d,x3.d,y3.d,flags=0)
!ctx.bezierCurveTo(v_x1,v_y1,v_x2,v_y2,v_x3,v_y3);
EndProcedure
Procedure _AddPathEllipse(x.d,y.d,radiusx.d,radiusy.d,a1.d=0,a2.d=360,flags=0)
a1=Radian(a1)
a2=Radian(a2)
!ctx.save();
!ctx.translate(v_x,v_y);
!ctx.scale(v_radiusx, v_radiusy);
!ctx.moveTo(Math.cos(v_a1),Math.sin(v_a1));
!ctx.arc(0,0,1,v_a1,v_a2);
!ctx.translate(-v_x,-v_y);
!ctx.restore();
EndProcedure
Procedure _AddPathLine(x.d,y.d,flags=0)
!ctx.lineTo(v_x,v_y);
EndProcedure
Procedure _AddPathSegments(segments.s,flags=0);!!!
; !var p = new Path2D(segments);
EndProcedure
Procedure _AddPathText(text.s);!!!
!ctx.strokeText(v_text, v_canvascx,v_canvascy);
EndProcedure
Procedure _BeginVectorLayer(alpha);!!!
EndProcedure
Procedure _ClipPath(flags=0)
!ctx.save();
!ctx.clip();
!if (v_flags == 0) ctx.beginPath();
EndProcedure
Procedure _ClosePath()
!ctx.closePath();
EndProcedure
Procedure _ConvertCoordinateX();!!!
EndProcedure
; ConvertCoordinateY
Procedure _CustomDashPath(width.d,Array a.d(1),flags=0,startoffset=0)
Protected lc.s=jslinecap(flags)
!ctx.setLineDash(a_a.array);
!ctx.lineCap= v_lc;
!ctx.lineDashOffset = v_startoffset;
_StrokePath(width,flags)
!ctx.setLineDash([]);
EndProcedure
Procedure _DashPath(width.d,length.d,flags=0,startoffset=0)
Protected lc.s=jslinecap(flags)
!ctx.setLineDash([v_length, v_length]);
!ctx.lineCap= v_lc;
!ctx.lineDashOffset = v_startoffset;
_StrokePath(width,flags)
!ctx.setLineDash([]);
EndProcedure
Procedure _DotPath(width.d,length.d,flags=0,startoffset=0)
!ctx.setLineDash([0,v_length]);
!ctx.lineCap= "round";
!ctx.lineDashOffset = v_startoffset;
_StrokePath(width,flags)
!ctx.setLineDash([]);
EndProcedure
Procedure _DrawVectorImage(imageid,alpha=255,width.d=-1,height.d=-1)
!ctx.globalAlpha=v_alpha/255;
If width=-1
!ctx.drawImage(v_imageid, v_canvascx,v_canvascy);
Else
!ctx.drawImage(v_imageid, v_canvascx,v_canvascy,v_width,v_height);
EndIf
!ctx.globalAlpha=1;
EndProcedure
Procedure _DrawVectorParagraph(Text.s, width.d, height.d, flags=#PB_VectorParagraph_Left);!
!function getLines(ctx, text, maxWidth) {
! var words = text.split(" ");
! var lines = [];
! var currentLine = words[0];
! for (var i = 1; i < words.length; i++) {
! var word = words[i];
! var width = ctx.measureText(currentLine + " " + word).width;
! if (width < maxWidth) {
! currentLine += " " + word;
! } else {
! lines.push(currentLine);
! currentLine = word;
! }
! }
! lines.push(currentLine);
! return lines;
!}
Protected ta.s, x.d
Select flags
Case #PB_VectorParagraph_Left:ta="left":x=0
Case #PB_VectorParagraph_Right:ta="right":x=width
Case #PB_VectorParagraph_Center:ta="center":x=width/2
;Case #PB_VectorParagraph_Block:ta=""
EndSelect
!var textAlign_mem=ctx.textAlign;
!ctx.textAlign=v_ta;
!var lh=parseFloat(ctx.font);
!var lines=getLines(ctx,v_text,v_width);
!for (var n = 0; n < lines.length; n++) { ctx.fillText(lines[n], v_canvascx+v_x,v_canvascy,v_width);v_canvascy+=lh;};
!ctx.textAlign=textAlign_mem;
EndProcedure
Procedure _DrawVectorText(text.s)
!ctx.fillText(v_text, v_canvascx,v_canvascy);
EndProcedure
Procedure _EndVectorLayer();!!!
EndProcedure
Procedure _FillPath(flags=0)
!ctx.fill();
!if (v_flags == 0) ctx.beginPath();
EndProcedure
Procedure _FillVectorOutput()
!ctx.save();
!ctx.setTransform(1,0,0,1,0,0);
!ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height);
!ctx.restore();
EndProcedure
Procedure _FlipCoordinatesX(x.d)
!ctx.translate(v_x,0);
!ctx.transform(-1,0,0,1,0,0);
!ctx.translate(-v_x,0);
EndProcedure
Procedure _FlipCoordinatesY(y.d)
!ctx.translate(0,v_y);
!ctx.transform(1,0,0,-1,0,0);
!ctx.translate(0,-v_y);
EndProcedure
Procedure.b _IsInsidePath(x.d,y.d,system=#PB_Coordinate_User)
!return ctx.isPointInPath(v_x, v_y)
EndProcedure
Procedure.b _IsInsideStroke(x.d,y.d,width.d,f=0,system=#PB_Coordinate_User)
!var width_mem=ctx.lineWidth;
!ctx.lineWidth = v_width;
!return ctx.isPointInStroke(v_x, v_y)
!ctx.lineWidth=width_mem;
EndProcedure
; IsPathEmpty
Procedure _MovePathCursor(x.d,y.d)
canvascx=x
canvascy=y
!ctx.moveTo(v_canvascx,v_canvascy);
EndProcedure
; NewVectorPage
; PathBoundsHeight
; PathBoundsWidth
; PathBoundsX
; PathBoundsY
Procedure.d _PathCursorX();!
ProcedureReturn canvascx
EndProcedure
Procedure.d _PathCursorY();!
ProcedureReturn canvascy
EndProcedure
; PathLength
; PathPointAngle
; PathPointX
; PathPointY
; PathSegments
; PdfVectorOutput
Procedure _ResetCoordinates(system=#PB_Coordinate_User)
!ctx.setTransform(1,0,0,1,0,0);
EndProcedure
Procedure _ResetPath()
!ctx.beginPath();
EndProcedure
Procedure _RestoreVectorState()
!ctx.restore();
EndProcedure
Procedure _RotateCoordinates(x.d,y.d,Angle.d)
angle=Radian(angle)
!ctx.translate(v_x,v_y);
!ctx.rotate(v_angle);
!ctx.translate(-v_x,-v_y);
EndProcedure
Procedure _SaveVectorState()
!ctx.save();
EndProcedure
Procedure _SkewCoordinates(anglex.d,angley.d,system=#PB_Coordinate_User)
anglex=Tan(Radian(anglex))
angley=Tan(Radian(angley))
!ctx.transform(1,v_angley,v_anglex,1,0,0);
EndProcedure
Procedure _ScaleCoordinates(scalex.d,scaley.d,system=#PB_Coordinate_User)
!ctx.scale(v_scalex,v_scaley);
EndProcedure
Procedure _StartVectorDrawing(n)
!prevctx=ctx;
StartDrawing(n)
!ctx = spider.drawing.context;
!ctx.restore();
!ctx.textBaseline="top";
!ctx.setTransform(1,0,0,1,0,0);
EndProcedure
Procedure _StopVectorDrawing()
StopDrawing()
!ctx=prevctx;
EndProcedure
Procedure _StrokePath(width.d,flags=0)
!ctx.lineWidth = v_width;
!ctx.stroke();
!if ((v_flags & 8) ==0) ctx.beginPath();
EndProcedure
; SvgVectorOutput
Procedure _TranslateCoordinates(x.d,y.d,system=#PB_Coordinate_User)
!ctx.translate(v_x,v_y);
EndProcedure
Procedure _VectorFont(fontid,fontsize.d)
!ctx.font=v_fontsize+"px "+v_fontid.family;
EndProcedure
Procedure _VectorOutputHeight()
!return ctx.canvas.height;
EndProcedure
Procedure _VectorOutputWidth()
!return ctx.canvas.width;
EndProcedure
; VectorParagraphHeight
; VectorResolutionX
; VectorResolutionY
Procedure _VectorSourceCircularGradient(x.d,y.d,radius.d,centerx.d=0,centery.d=0)
!ctx.fillStyle=ctx.createRadialGradient(v_x+v_centerx,v_y+v_centery,0,v_x,v_y,v_radius);
EndProcedure
Procedure _VectorSourceColor(color.l)
Protected col.s=jscolor(color)
!ctx.fillStyle = v_col;
!ctx.strokeStyle = v_col;
EndProcedure
Procedure _VectorSourceGradientColor(color.l,position.d)
Protected col.s=jscolor(color)
!ctx.fillStyle.addColorStop(v_position,v_col);
EndProcedure
Procedure _VectorSourceImage(imageid, alpha=255 , width.d=-1, height.d=-1 ,flags=0);!
!ctx.globalAlpha= v_alpha/255;
!var pattern = ctx.createPattern(v_imageid,"repeat");
!ctx.fillStyle=pattern;
!ctx.globalAlpha=1;
EndProcedure
Procedure _VectorSourceLinearGradient(x1.d,y1.d,x2.d,y2.d)
!ctx.fillStyle=ctx.createLinearGradient(v_x1,v_y1,v_x2,v_y2);
EndProcedure
Procedure.f _VectorTextHeight(text.s,flags=0);!
!return parseFloat(ctx.font);
EndProcedure
Procedure.f _VectorTextWidth(text.s,flags=0);!
!return ctx.measureText(v_text).width;
EndProcedure
Procedure VectorShadow(color.l=0,blur=0,OffsetX=0,Offsety=0)
Protected col.s=jscolor(color)
!ctx.shadowColor=v_col;
!ctx.shadowBlur=v_blur;
!ctx.shadowOffsetX=v_offsetx;
!ctx.shadowOffsetY=v_offsety;
EndProcedure
; VectorUnit
; -------------------------------------------------------------------
Macro ImageVectorOutput:_ImageVectorOutput:EndMacro
Macro CanvasVectorOutput:_CanvasVectorOutput:EndMacro
Macro AddPathArc:_AddPathArc:EndMacro
Macro AddPathBox:_AddPathBox:EndMacro
Macro AddPathCircle:_AddPathCircle:EndMacro
Macro AddPathCurve:_AddPathCurve:EndMacro
Macro AddPathEllipse:_AddPathEllipse:EndMacro
Macro AddPathLine:_AddPathLine:EndMacro
Macro AddPathSegments:_AddPathSegments:EndMacro
Macro AddPathText:_AddPathText:EndMacro
Macro BeginVectorLayer:_BeginVectorLayer:EndMacro
Macro ClipPath:_ClipPath:EndMacro
Macro ClosePath:_ClosePath:EndMacro
Macro ConvertCoordinateX:_ConvertCoordinateX:EndMacro
Macro CustomDashPath:_CustomDashPath:EndMacro
Macro DashPath:_DashPath:EndMacro
Macro DotPath:_DotPath:EndMacro
Macro DrawVectorImage:_DrawVectorImage:EndMacro
Macro DrawVectorParagraph:_DrawVectorParagraph:EndMacro
Macro DrawVectorText:_DrawVectorText:EndMacro
Macro EndVectorLayer:_EndVectorLayer:EndMacro
Macro FillPath:_FillPath:EndMacro
Macro FillVectorOutput:_FillVectorOutput:EndMacro
Macro FlipCoordinatesX:_FlipCoordinatesX:EndMacro
Macro FlipCoordinatesY:_FlipCoordinatesY:EndMacro
Macro IsInsidePath:_IsInsidePath:EndMacro
Macro IsInsideStrokex:_IsInsideStrokex:EndMacro
Macro MovePathCursor:_MovePathCursor:EndMacro
Macro PathCursorX:_PathCursorX:EndMacro
Macro PathCursorY:_PathCursorY:EndMacro
Macro ResetCoordinates:_ResetCoordinates:EndMacro
Macro ResetPath:_ResetPath:EndMacro
Macro RestoreVectorState:_RestoreVectorState:EndMacro
Macro RotateCoordinates:_RotateCoordinates:EndMacro
Macro SaveVectorState:_SaveVectorState:EndMacro
Macro SkewCoordinates:_SkewCoordinates:EndMacro
Macro ScaleCoordinates:_ScaleCoordinates:EndMacro
Macro StartVectorDrawing:_StartVectorDrawing:EndMacro
Macro StopVectorDrawing:_StopVectorDrawing:EndMacro
Macro StrokePath:_StrokePath:EndMacro
Macro TranslateCoordinates:_TranslateCoordinates:EndMacro
Macro VectorFont:_VectorFont:EndMacro
Macro VectorOutputHeight:_VectorOutputHeight:EndMacro
Macro VectorOutputWidth:_VectorOutputWidth:EndMacro
Macro VectorSourceCircularGradient:_VectorSourceCircularGradient:EndMacro
Macro VectorSourceColor:_VectorSourceColor:EndMacro
Macro VectorSourceGradientColor:_VectorSourceGradientColor:EndMacro
Macro VectorSourceImage:_VectorSourceImage:EndMacro
Macro VectorSourceLinearGradient:_VectorSourceLinearGradient:EndMacro
Macro VectorTextHeight:_VectorTextHeight:EndMacro
Macro VectorTextWidth:_VectorTextWidth:EndMacro
Procedure ClearVectorOutput()
!ctx.save();
!ctx.setTransform(1,0,0,1,0,0);
!ctx.clearRect(0,0,ctx.canvas.width,ctx.canvas.height);
!ctx.restore();
EndProcedure
;}
;##############################################################################################################################################
Procedure.f POM(v.f)
ProcedureReturn (Random(v*100000)-v*50000)/50000
EndProcedure
Macro cola(col,a=$ff):((col|(a<<24))):EndMacro
Procedure ColorBlend(color1.l, color2.l, blend.f)
Protected r.w,g.w,b.w,a.w
r= Red(color1) + (Red(color2) - Red(color1)) * blend
g=Green(color1) + (Green(color2) - Green(color1)) * blend
b= Blue(color1) + (Blue(color2) - Blue(color1)) * blend
a=Alpha(color1) + (Alpha(color2) - Alpha(color1)) * blend
ProcedureReturn RGBA(r,g,b,a)
EndProcedure
;----------------------------------------------------------- demo -----------------------------------------------------------
Procedure sphere(n,col.l)
Protected la=64,la2=la*2
CreateImage(n,la2,la2,32,#PB_Image_Transparent )
StartVectorDrawing(ImageVectorOutput(n))
AddPathCircle(la,la,la-1)
VectorSourceCircularGradient(la,la,la,-la*0.4,-la*0.4)
VectorSourceGradientColor(cola($ffffff,255),0.0)
VectorSourceGradientColor(cola(col,128),0.2)
VectorSourceGradientColor(cola(colorblend(col,$000000,0.5),255),1.0)
FillPath()
StopVectorDrawing()
EndProcedure
Structure sballon
type.b
x.f
y.f
z.f
vx.f
vy.f
vz.f
EndStructure
Structure spoint
color.l
vx.f
vy.f
x.f
y.f
xa.f
ya.f
EndStructure
Global ex,ey
Global nballon=500
Global.sballon Dim tb(nballon)
Global nlum=200
Global Dim lum.spoint(nlum)
Procedure test1_affiche()
Protected i
Protected.f x,y,r
StartVectorDrawing(CanvasVectorOutput(0))
VectorFont(FontID(0),160)
VectorSourceColor($ff888888)
FillVectorOutput()
For i=0 To nballon
With tb(i)
\vx=(\vx+pom(0.2))*0.98
\y-\vy:If \y<-500:\y=500:\vx=0:EndIf
\x-\vx
x=ex/2+ \x/ \z
y=ey/2+ \y/ \z
r=64 / \z
If i=nballon*0.9:MovePathCursor((ex-VectorTextWidth("SpiderBasic"))/2,200):VectorSourceColor($ff0000ff):DrawVectorText("SpiderBasic"):EndIf
MovePathCursor(x-r/2,y-r/2)
DrawVectorImage(ImageID(100+\type),255,r,r)
EndWith
Next
StopVectorDrawing()
EndProcedure
Procedure test1()
Protected i
For i=0 To 15
sphere(100+i,Random($ffffff))
Next
For i=0 To nballon
With tb(i)
\type=Random(15)
\x=Random(1000)-500
\y=Random(1000)-500
\z=(1.2-i/nballon)*1
\vy=1+pom(0.2)
EndWith
Next
BindEvent(#PB_Event_Timer, @ test1_affiche())
EndProcedure
Procedure test2_affiche()
Protected i,r.f
Protected.spoint p1,p2,p3,p4
StartVectorDrawing(CanvasVectorOutput(0))
TranslateCoordinates(ex/2,ey/2):ScaleCoordinates(ex/4,ex/4)
Static atr.f,tr:atr+0.01:tr=(Sin(atr)+1)*128
VectorSourceColor(cola(0,20))
FillVectorOutput()
For i=1 To nlum
If i & 1=0:ScaleCoordinates(1.02,1.02):EndIf
With lum(i)
\vx=(\vx+pom(0.001))*0.995
\vy=(\vy+pom(0.001))*0.995
\xa=\x:\x=(\x+\vx)*0.99
\ya=\y:\y=(\y+\vy)*0.99
r=Sqr(\vx*\vx+\vy*\vy)*4
r=0.02
AddPathCircle(\x,\y,r)
VectorSourceCircularGradient(\x,\y,r)
VectorSourceGradientColor(cola(\color,128),0)
VectorSourceGradientColor(cola(\color,0 ),1)
FillPath()
EndWith
Next
StopVectorDrawing()
EndProcedure
Procedure test2()
Protected i
For i=0 To nlum:lum(i)\color=Random($ffffff):Next
BindEvent(#PB_Event_Timer, @ test2_affiche())
EndProcedure
Procedure test3_affiche()
Protected i,r.f
Protected.spoint p1,p2,p3,p4
StartVectorDrawing(CanvasVectorOutput(0))
TranslateCoordinates(ex/2,ey/2):ScaleCoordinates(ex/2,ex/2)
Static atr.f,tr:atr+0.01:tr=(Sin(atr)+1)*128
VectorSourceColor(cola(0,16))
FillVectorOutput()
For i=1 To nlum
With lum(i)
\vx=(\vx+pom(0.001))*0.995
\vy=(\vy+pom(0.001))*0.995
\xa=\x:\x=(\x+\vx)*0.99
\ya=\y:\y=(\y+\vy)*0.99
EndWith
Next
For i=1 To nlum/4 Step 4
p1=lum(i)
p2=lum(i+1)
p3=lum(i+2)
p4=lum(i+3)
VectorSourceColor(cola(p1\color,128))
MovePathCursor(p1\x,p1\y)
AddPathCurve(p2\x,p2\y,p3\x,p3\y,p4\x,p4\y)
AddPathLine(p4\xa,p4\ya)
AddPathCurve(p3\xa,p3\ya,p2\xa,p2\ya,p1\xa,p1\ya)
ClosePath()
FillPath()
Next
StopVectorDrawing()
EndProcedure
Procedure test3()
Protected i
For i=0 To nlum:lum(i)\color=Random($ffffff):Next
BindEvent(#PB_Event_Timer, @ test3_affiche())
EndProcedure
Procedure test4()
Protected i
sphere(1,$ffff8800)
StartVectorDrawing(CanvasVectorOutput(0))
ScaleCoordinates(ex/800,ey/600)
VectorSourceColor($aa000000)
FillVectorOutput()
SaveVectorState()
For i=0 To 15
RotateCoordinates(640,400,5)
AddPathBox(640-100,400-100,200,200)
VectorSourceColor(RGBA(255,0,255,i*16))
StrokePath(5)
Next
RestoreVectorState()
MovePathCursor(600,00)
VectorSourceColor($ffffffff)
VectorFont(FontID(0), 20)
DrawVectorParagraph("Chaque sortie de dessin a une unité de mesure par défaut. L'unité par défaut est le pixel",200,200,#PB_VectorParagraph_Right)
VectorSourceColor($ffffff00)
MovePathCursor(140, 60)
AddPathArc(200, 140, 260, 20, 20)
AddPathArc(260, 20, 320, 180, 20)
Dim dashes.d(3)
dashes(0) = 10
dashes(1) = 2
dashes(2) = 5
dashes(3) = 2
CustomDashPath(10, dashes())
;DotPath(10,15,#PB_Path_SquareEnd)
;DashPath(15,20,#PB_Path_RoundEnd,2)
MovePathCursor(50, 100)
AddPathCurve(90, 30, 250, 180, 350, 100)
VectorSourceColor($ffffff00)
StrokePath(3)
SaveVectorState()
VectorFont(FontID(0), 30)
MovePathCursor(400,50)
VectorSourceColor($88ffff00)
StrokePath(1)
AddPathText("AddPathText")
VectorSourceColor($ff0000ff)
MovePathCursor(20, 20)
DrawVectorText("Texte normal")
SaveVectorState()
MovePathCursor(120, 120)
RotateCoordinates(120, 120, -50)
VectorSourceColor($ffff0000)
DrawVectorText("Rotation texte")
RestoreVectorState()
MovePathCursor(220, 120)
DrawVectorText("Texte normal")
RestoreVectorState()
MovePathCursor(450,250)
AddPathLine(550,350)
AddPathLine(550,200)
ClosePath()
AddPathEllipse(256,256,200,100)
VectorSourceImage(ImageID(1))
FillPath(#PB_Path_Preserve)
VectorSourceColor($77008800)
StrokePath(10)
MovePathCursor(50,450)
AddPathLine(500,0)
VectorSourceColor($ff880000)
StrokePath(10)
SaveVectorState()
AddPathCircle(200,400,200)
ClipPath()
Protected text.s=" ClipPath "
For i=0 To 50
VectorFont(FontID(0),Random(60,20))
VectorSourceColor($88ffffff)
MovePathCursor(Random(400) - VectorTextWidth(Text)/2, 200+Random(400) - VectorTextHeight(Text)/2)
DrawVectorText(text)
Next
RestoreVectorState()
MovePathCursor(50,500)
AddPathLine(550,0)
VectorSourceColor($ff88ff00)
StrokePath(10)
StrokePath(1)
StopVectorDrawing()
EndProcedure
Procedure menu()
UnbindEvent(#PB_Event_Timer, @ test1_affiche())
UnbindEvent(#PB_Event_Timer, @ test2_affiche())
UnbindEvent(#PB_Event_Timer, @ test3_affiche())
Select EventGadget()
Case 1:test1()
Case 2:test2()
Case 3:test3()
Case 4:test4()
EndSelect
EndProcedure
Procedure size_event()
ex=DesktopWidth(0)
ey=DesktopHeight(0)
ResizeGadget(0,0,0,ex,ey)
EndProcedure
BindEvent(#PB_Event_SizeDesktop,@ size_event())
LoadFont(0, "times", 100, #PB_Font_Bold)
OpenWindow(0,10,10,120,130, "", #PB_Window_BorderLess):StickyWindow(0,1):SetWindowColor(0,$22ffffff)
ButtonGadget(1,10,10,100,20,"demo 1"):BindGadgetEvent(1,@ menu())
ButtonGadget(2,10,40,100,20,"demo 2"):BindGadgetEvent(2,@ menu())
ButtonGadget(3,10,70,100,20,"demo 3"):BindGadgetEvent(3,@ menu())
ButtonGadget(4,10,100,100,20,"Sample"):BindGadgetEvent(4,@ menu())
OpenWindow(1, 0, 0,800,600, "", #PB_Window_Background)
AddWindowTimer(1, 0, 20)
CanvasGadget(0,0,0,800,600)
size_event()
test1()