-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathawesome-canvas-animation.pb
97 lines (91 loc) · 2.74 KB
/
awesome-canvas-animation.pb
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
; (c) deseven.info
Enumeration
#wnd
#canvas
#plus
#minus
#change
EndEnumeration
Global anima_type
points.b = 5
isAnimating = #False
Procedure drawPoints(points.b,animate.b = #False,animatePlus.b = #True,animateStep.b = 0)
StartDrawing(CanvasOutput(#canvas))
Box(0,0,400,40,GetWindowColor(#wnd))
For i = 0 To points-1
If i = points-1 And animate
If animatePlus
Select anima_type
Case 1
Box(i*40+5,5,3*animateStep,3*animateStep,$ff0000)
Case 2
Box(i*40+5+(30-3*animateStep)/2,5+(30-3*animateStep)/2,3*animateStep,3*animateStep,RGB(255-animateStep*25,255-animateStep*25,255))
Case 3
Box(i*40+5+(400-i*40+5)/animateStep+1,5,30,30,RGB(255-animateStep*25,255-animateStep*25,255))
Case 4
Box(i*40+5,-25+animateStep*3,30,30,RGB(255-animateStep*25,255-animateStep*25,255))
EndSelect
Else
Select anima_type
Case 1
Box(i*40+5,5,30/animateStep,30/animateStep,$ff0000)
Case 2
Box(i*40+5+(30-30/animateStep)/2,5+(30-30/animateStep)/2,30/animateStep,30/animateStep,RGB(animateStep*25,animateStep*25,255))
Case 3
Box(400-(400-i*40+5)/animateStep,5,30,30,RGB(animateStep*25,animateStep*25,255))
Case 4
Box(i*40+5,5+animateStep*3,30,30,RGB(animateStep*25,animateStep*25,255))
EndSelect
EndIf
Else
Box(i*40+5,5,30,30,$ff0000)
EndIf
Next
StopDrawing()
EndProcedure
OpenWindow(#wnd,#PB_Ignore,#PB_Ignore,400,120,"Простейший индикатор на канвасе",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CanvasGadget(#canvas,0,0,400,40)
ButtonGadget(#plus,0,40,200,40,"+1")
ButtonGadget(#minus,200,40,200,40,"-1")
ButtonGadget(#change,0,80,400,40,"Change Animation")
drawPoints(points)
Repeat
ev = WindowEvent()
If ev
Select EventGadget()
Case #plus
If points+1 <= 10 And EventType() = #PB_EventType_LeftClick
newPoints = points + 1
isAnimating = #True
EndIf
Case #minus
If points-1 >= 0 And EventType() = #PB_EventType_LeftClick
newPoints = points - 1
isAnimating = #True
EndIf
Case #change
If anima_type > 4
anima_type = 1
Else
anima_type = anima_type + 1
EndIf
EndSelect
ElseIf isAnimating
If animateStep = 10
isAnimating = #False
animateStep = 0
points = newPoints
drawPoints(points)
Else
animateStep + 1
If newPoints > points
drawPoints(newPoints,#True,#True,animateStep)
Else
drawPoints(points,#True,#False,animateStep)
EndIf
EndIf
Delay(15)
Else
Delay(10)
EndIf
Until ev = #PB_Event_CloseWindow