TomLebowski
02-01-2010, 12:35
good morning, happy new year and hope everybody has started with good mood and power for this year 2010 !
I wanted to build simple solution of circles they are falling down from top, make some relays with "sleep", "canvas clear", and changing shapes and colours. my example shows what I am intended to do. left side is nearly ok bleongs to my idea, so I have had this idea to show this effect, but right example stops and started again. didn't know really why ? ;) so I need little help. wanted connect console modus of circles building with canvas circles. must grin cause I have tried to play with "incr canvas_circles" statements, but that cannot run. example I found at canvas folder. thanks!
' Empty GUI script created on 12-29-2009 22:47:13 by (ThinAIR)
'- testcode for canvas with circles and animas by tom
'-------------------------------------------------------------
Uses "UI", "console"
Begin Const
%cCanvasSB = %WM_USER + 500
%cCanvasDB
%btnClose
%tAnimationTimer
End Const
Function TBMAIN()
Local hDlg As DWord
Dim cx, cy As Long
Dialog New 0, "Toms Circles_Test",-1,-1, 282, 170, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX, 0 To hDlg
Dialog Pixels hDlg, 200, 200 To Units cx, cy
Control Add Canvas, hDlg, %cCanvasSB, "", 5, 25, cx, cy
Control Add Canvas, hDlg, %cCanvasDB, "", 5+cx+5, 25, cx,cy
Control Add Label, hDlg, -1, "Single buffer"+$CRLF+"(immediate, but with flicker)", 5, 5, cx, 30
Control Add Label, hDlg, -1, "Double buffer"+$CRLF+"(draws all at once, no flicker)", 5+cx+5, 5, cx, 30
Control Add Button, hDlg, %btnClose, "Click to close", 10+cx, 30+cy, cx, 14, Call btnCloseProc
Dialog Show Modal hDlg, Call dlgProc
End Function
' -- Callback for dialog --------------------------------------------
CallBack Function dlgProc()
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %tAnimationTimer, 10, %NULL
Case %WM_TIMER
Dim tx, ty As Long
Canvas_Attach(CBHNDL, %cCanvasSB, %FALSE)
DrawGraphics()
Canvas_Attach(CBHNDL, %cCanvasDB, %TRUE)
DrawGraphics()
Canvas_Redraw
Case %WM_CLOSE
End Select
End Function
CallBack Function btnCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End If
End Function
'------ circles -----------------------------------
Sub DrawGraphics()
Dim tx, ty, p As Long
Dim CountCircles As Byte
CountCircles = 0
p = 0
Do
Incr CountCircles
tx = 80+Cos(GetTickCount/100)*4
ty = 80+Sin(GetTickCount/100)*4
Canvas_Color Rgb(128, 255, 0), Rgb(0, 0, 0)
Canvas_Clear(Rgb(0,0,0))
Canvas_Box(tx-50,ty-50,tx,ty, 0, Rgb(255, 0, 0), Rgb(255,128,0),%CANVAS_FILLSTYLE_DIAGONALCROSSEDLINES )
Canvas_Ellipse (tx-80, ty-90, tx-40, ty-25, Rgb(150,0,50),Rgb(50,0,250),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Print " Welcome "+Str$(Rnd(1,256))
Canvas_Print " sun :) "+Str$(Rnd(1,256))
Canvas_Ellipse (140, 120, 40, 35, Rgb(250,0,250),Rgb(150,0,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
'Sleep 10
'Canvas_Clear(Rgb(0,0,0))
Canvas_Ellipse (140, 125, 50, 15, Rgb(50,0,250),Rgb(150,100,250),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 130, 50, 15, Rgb(150,0,150),Rgb(50,160,150),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 135, 50, 15, Rgb(150,100,50),Rgb(50,100,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 140, 50, 15, Rgb(150,100,50),Rgb(50,100,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 125, 40, 35, Rgb(250,100,50),Rgb(50,0,150),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Sleep 10
Canvas_Ellipse (140, 110, 30, 35, Rgb(250,0,0),Rgb(150,0,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
'Canvas_Line ((0,0), (200, 200), Rgb(255,0,0))
'Canvas_Line ((200,0), (0, 200), rgb(255,0,0))
Console_WriteLine("-- CountCircles test :"+Str$(CountCircles))
If CountCircles = 150 Then Exit Do
Loop
End Sub
''Canvas_Ellipse (tx-140, ty-160, tx-40, ty-25, Rgb(150,0,50),Rgb(250,0,150),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
tom
I wanted to build simple solution of circles they are falling down from top, make some relays with "sleep", "canvas clear", and changing shapes and colours. my example shows what I am intended to do. left side is nearly ok bleongs to my idea, so I have had this idea to show this effect, but right example stops and started again. didn't know really why ? ;) so I need little help. wanted connect console modus of circles building with canvas circles. must grin cause I have tried to play with "incr canvas_circles" statements, but that cannot run. example I found at canvas folder. thanks!
' Empty GUI script created on 12-29-2009 22:47:13 by (ThinAIR)
'- testcode for canvas with circles and animas by tom
'-------------------------------------------------------------
Uses "UI", "console"
Begin Const
%cCanvasSB = %WM_USER + 500
%cCanvasDB
%btnClose
%tAnimationTimer
End Const
Function TBMAIN()
Local hDlg As DWord
Dim cx, cy As Long
Dialog New 0, "Toms Circles_Test",-1,-1, 282, 170, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX, 0 To hDlg
Dialog Pixels hDlg, 200, 200 To Units cx, cy
Control Add Canvas, hDlg, %cCanvasSB, "", 5, 25, cx, cy
Control Add Canvas, hDlg, %cCanvasDB, "", 5+cx+5, 25, cx,cy
Control Add Label, hDlg, -1, "Single buffer"+$CRLF+"(immediate, but with flicker)", 5, 5, cx, 30
Control Add Label, hDlg, -1, "Double buffer"+$CRLF+"(draws all at once, no flicker)", 5+cx+5, 5, cx, 30
Control Add Button, hDlg, %btnClose, "Click to close", 10+cx, 30+cy, cx, 14, Call btnCloseProc
Dialog Show Modal hDlg, Call dlgProc
End Function
' -- Callback for dialog --------------------------------------------
CallBack Function dlgProc()
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %tAnimationTimer, 10, %NULL
Case %WM_TIMER
Dim tx, ty As Long
Canvas_Attach(CBHNDL, %cCanvasSB, %FALSE)
DrawGraphics()
Canvas_Attach(CBHNDL, %cCanvasDB, %TRUE)
DrawGraphics()
Canvas_Redraw
Case %WM_CLOSE
End Select
End Function
CallBack Function btnCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End If
End Function
'------ circles -----------------------------------
Sub DrawGraphics()
Dim tx, ty, p As Long
Dim CountCircles As Byte
CountCircles = 0
p = 0
Do
Incr CountCircles
tx = 80+Cos(GetTickCount/100)*4
ty = 80+Sin(GetTickCount/100)*4
Canvas_Color Rgb(128, 255, 0), Rgb(0, 0, 0)
Canvas_Clear(Rgb(0,0,0))
Canvas_Box(tx-50,ty-50,tx,ty, 0, Rgb(255, 0, 0), Rgb(255,128,0),%CANVAS_FILLSTYLE_DIAGONALCROSSEDLINES )
Canvas_Ellipse (tx-80, ty-90, tx-40, ty-25, Rgb(150,0,50),Rgb(50,0,250),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Print " Welcome "+Str$(Rnd(1,256))
Canvas_Print " sun :) "+Str$(Rnd(1,256))
Canvas_Ellipse (140, 120, 40, 35, Rgb(250,0,250),Rgb(150,0,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
'Sleep 10
'Canvas_Clear(Rgb(0,0,0))
Canvas_Ellipse (140, 125, 50, 15, Rgb(50,0,250),Rgb(150,100,250),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 130, 50, 15, Rgb(150,0,150),Rgb(50,160,150),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 135, 50, 15, Rgb(150,100,50),Rgb(50,100,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 140, 50, 15, Rgb(150,100,50),Rgb(50,100,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Canvas_Ellipse (140, 125, 40, 35, Rgb(250,100,50),Rgb(50,0,150),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
Sleep 10
Canvas_Ellipse (140, 110, 30, 35, Rgb(250,0,0),Rgb(150,0,50),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
'Canvas_Line ((0,0), (200, 200), Rgb(255,0,0))
'Canvas_Line ((200,0), (0, 200), rgb(255,0,0))
Console_WriteLine("-- CountCircles test :"+Str$(CountCircles))
If CountCircles = 150 Then Exit Do
Loop
End Sub
''Canvas_Ellipse (tx-140, ty-160, tx-40, ty-25, Rgb(150,0,50),Rgb(250,0,150),%CANVAS_FILLSTYLE_UPWARDDIAGONALLINES)
tom