@@ -4,18 +4,14 @@ Import "LimbManager.bmx"
4
4
'//// GRAPHICS OUTPUT ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5
5
6
6
Type GraphicsOutput
7
- 'Draw Bools
8
- Field m_RedoLimbTiles:Int = False
9
- 'Constants
10
- Const c_MaxZoom:Int = 11
11
7
Const c_MaxFrameCount:Int = 20
12
- Field c_Magenta:Int [] = [255 , 0 , 255 ]
13
- 'Graphic Assets
14
8
15
9
Field m_MaxZoom:Int = 5 'Assume 1366px is the lowest resolution because it's not 1999. 1366px - 260px (left column) = 1106 / 192 (source image width) = 5 (floored)
10
+ Field m_Magenta:Int [] = [255 , 0 , 255 ]
11
+
16
12
Field m_SourceImage:TImage
17
13
Field m_SourceImageSize:SVec2I
18
- 'Output Settings
14
+
19
15
Field m_InputZoom:Int = g_DefaultInputZoom
20
16
Field m_TileSize:Int = 24 * m_InputZoom
21
17
Field m_FrameCount:Int = g_DefaultFrameCount
@@ -32,7 +28,7 @@ Type GraphicsOutput
32
28
33
29
Method New (maxWorkspaceWidth:Int )
34
30
SetClsColor(m_BackgroundColor[ 0 ] , m_BackgroundColor[ 1 ] , m_BackgroundColor[ 2 ] )
35
- SetMaskColor(c_Magenta [ 0 ] , c_Magenta [ 1 ] , c_Magenta [ 2 ] )
31
+ SetMaskColor(m_Magenta [ 0 ] , m_Magenta [ 1 ] , m_Magenta [ 2 ] )
36
32
37
33
m_MaxZoom = Int (FloorF(maxWorkspaceWidth / 192 ))
38
34
EndMethod
@@ -49,14 +45,6 @@ Type GraphicsOutput
49
45
EndIf
50
46
EndMethod
51
47
52
- '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
53
-
54
- Method SetBackgroundColor :Int [] (rgbValue:Int [] )
55
- m_BackgroundColor = rgbValue
56
- ChangeBackgroundColor(m_BackgroundColor)
57
- Return m_BackgroundColor
58
- EndMethod
59
-
60
48
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
61
49
62
50
Method SetInputZoom :Int (newZoom:Int )
@@ -74,15 +62,10 @@ Type GraphicsOutput
74
62
75
63
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76
64
77
- Method GetFrameCount :Int ()
78
- Return m_FrameCount
79
- EndMethod
80
-
81
- '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
82
-
83
- Method SetFrameCount :Int (newCount:Int )
84
- m_FrameCount = Utility.Clamp(newCount, 1 , c_MaxFrameCount)
85
- Return m_FrameCount
65
+ Method SetBackgroundColor :Int [] (rgbValue:Int [] )
66
+ m_BackgroundColor = rgbValue
67
+ ChangeBackgroundColor(m_BackgroundColor)
68
+ Return m_BackgroundColor
86
69
EndMethod
87
70
88
71
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -101,60 +84,21 @@ Type GraphicsOutput
101
84
102
85
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
103
86
104
- Method SetDrawOutputFrameBounds (drawOrNot :Int )
105
- m_DrawOutputFrameBounds = drawOrNot
87
+ Method GetFrameCount :Int ( )
88
+ Return m_FrameCount
106
89
EndMethod
107
90
108
91
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
109
92
110
- Method Update ()
111
- 'Left mouse to adjust joint markers, click or hold and drag
112
- If MouseDown(1 ) Then
113
- Local mousePos:SVec2I = New SVec2I (MouseX(), MouseY())
114
- If Utility.PointIsWithinBox(mousePos, New SVec2I (0 , 0 ), m_SourceImageSize * m_InputZoom) Then
115
- m_LimbManager.SetJointMarker(mousePos)
116
- EndIf
117
- EndIf
93
+ Method SetFrameCount :Int (newCount:Int )
94
+ m_FrameCount = Utility.Clamp(newCount, 1 , c_MaxFrameCount)
95
+ Return m_FrameCount
118
96
EndMethod
119
97
120
98
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
121
99
122
- Method Draw ()
123
- If m_SourceImage = Null Then
124
- DrawNoSourceImageScreen()
125
- Else
126
- Cls()
127
-
128
- SetColor(c_Magenta[ 0 ] , c_Magenta[ 1 ] , c_Magenta[ 2 ] )
129
- DrawRect(0 , 0 , GraphicsWidth(), (m_SourceImageSize[ 1 ] * m_InputZoom) + 1 ) 'Extend the source image magenta strip all the way to the right and adjust height to input zoom
130
- Utility.ResetDrawColor()
131
- DrawImageRect(m_SourceImage, 0 , 0 , m_SourceImageSize[ 0 ] * m_InputZoom, m_SourceImageSize[ 1 ] * m_InputZoom)
132
-
133
- m_LimbManager.DrawTileOutlines()
134
- m_LimbManager.DrawJointMarkers()
135
-
136
- Local vertOffsetFromSource:Int = (m_SourceImageSize[ 1 ] * m_InputZoom) + 34
137
- m_LimbManager.DrawBentLimbs(New SVec2I (100 , vertOffsetFromSource), m_FrameCount)
138
-
139
- Local drawColor:Int [] = [ 255 , 230 , 80 ]
140
- Utility.DrawTextWithShadow(" Arm FG" , New SVec2I (10 , vertOffsetFromSource), drawColor)
141
- Utility.DrawTextWithShadow(" Arm BG" , New SVec2I (10 , vertOffsetFromSource + 50 - 2 ), drawColor)
142
- Utility.DrawTextWithShadow(" Leg FG" , New SVec2I (10 , vertOffsetFromSource + (50 * 2 ) - 4 ), drawColor)
143
- Utility.DrawTextWithShadow(" Leg BG" , New SVec2I (10 , vertOffsetFromSource + (50 * 3 ) - 6 ), drawColor)
144
-
145
- If m_DrawOutputFrameBounds Then
146
- drawColor = [ 0 , 0 , 80 ]
147
- m_FrameBoundingBoxSize = New SVec2I (32 , 48 )
148
- For Local row:Int = 0 Until c_LimbCount
149
- For Local frame:Int = 0 Until m_FrameCount
150
- m_FrameBoundingBoxPosX[ row, frame] = 100 - 20 + (frame * (m_TileSize / m_InputZoom + 8 ))
151
- m_FrameBoundingBoxPosY[ row, frame] = vertOffsetFromSource - 12 + (row * 48 )
152
- Utility.DrawRectOutline(New SVec2I (m_FrameBoundingBoxPosX[ row, frame] , m_FrameBoundingBoxPosY[ row, frame] ), m_FrameBoundingBoxSize, drawColor)
153
- Next
154
- Next
155
- EndIf
156
- Flip(1 )
157
- EndIf
100
+ Method SetDrawOutputFrameBounds (drawOrNot:Int )
101
+ m_DrawOutputFrameBounds = drawOrNot
158
102
EndMethod
159
103
160
104
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -163,9 +107,9 @@ Type GraphicsOutput
163
107
If m_SourceImage = Null Then
164
108
Notify(" Nothing to save!" , False )
165
109
Else
166
- ChangeBackgroundColor(c_Magenta )
110
+ ChangeBackgroundColor(m_Magenta )
167
111
Draw()
168
- Flip(1 ) 'Have to flip again for background color to actually change, not sure why but whatever
112
+ Flip(1 ) 'Have to flip again for background color to actually change (for the grabbed pixmap, not the canvas) , not sure why but whatever
169
113
Return GrabPixmap(55 , 120 , 34 * m_FrameCount, 210 )
170
114
EndIf
171
115
EndMethod
@@ -176,9 +120,9 @@ Type GraphicsOutput
176
120
If m_SourceImage = Null Then
177
121
Notify(" Nothing to save!" , False )
178
122
Else
179
- ChangeBackgroundColor(c_Magenta )
123
+ ChangeBackgroundColor(m_Magenta )
180
124
Draw()
181
- Flip(1 ) 'Have to flip again for background color to actually change, not sure why but whatever
125
+ Flip(1 ) 'Have to flip again for background color to actually change (for the grabbed pixmaps, not the canvas) , not sure why but whatever
182
126
183
127
Local framesToSave:TPixmap [ c_LimbCount, m_FrameCount]
184
128
For Local row:Int = 0 Until c_LimbCount
@@ -198,6 +142,18 @@ Type GraphicsOutput
198
142
EndIf
199
143
EndMethod
200
144
145
+ '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
146
+
147
+ Method Update ()
148
+ 'Left mouse to adjust joint markers, click or hold and drag
149
+ If MouseDown(1 ) Then
150
+ Local mousePos:SVec2I = New SVec2I (MouseX(), MouseY())
151
+ If Utility.PointIsWithinBox(mousePos, New SVec2I (0 , 0 ), m_SourceImageSize * m_InputZoom) Then
152
+ m_LimbManager.SetJointMarker(mousePos)
153
+ EndIf
154
+ EndIf
155
+ EndMethod
156
+
201
157
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
202
158
203
159
Method DrawNoSourceImageScreen ()
@@ -209,4 +165,44 @@ Type GraphicsOutput
209
165
SetScale(1 , 1 )
210
166
Flip(1 )
211
167
EndMethod
168
+
169
+ '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
170
+
171
+ Method Draw ()
172
+ If m_SourceImage = Null Then
173
+ DrawNoSourceImageScreen()
174
+ Else
175
+ Cls()
176
+
177
+ SetColor(m_Magenta[ 0 ] , m_Magenta[ 1 ] , m_Magenta[ 2 ] )
178
+ DrawRect(0 , 0 , GraphicsWidth(), (m_SourceImageSize[ 1 ] * m_InputZoom) + 1 ) 'Extend the source image magenta strip all the way to the right and adjust height to input zoom
179
+ Utility.ResetDrawColor()
180
+ DrawImageRect(m_SourceImage, 0 , 0 , m_SourceImageSize[ 0 ] * m_InputZoom, m_SourceImageSize[ 1 ] * m_InputZoom)
181
+
182
+ m_LimbManager.DrawTileOutlines()
183
+ m_LimbManager.DrawJointMarkers()
184
+
185
+ Local vertOffsetFromSource:Int = (m_SourceImageSize[ 1 ] * m_InputZoom) + 34
186
+ m_LimbManager.DrawBentLimbs(New SVec2I (100 , vertOffsetFromSource), m_FrameCount)
187
+
188
+ Local drawColor:Int [] = [ 255 , 230 , 80 ]
189
+ Utility.DrawTextWithShadow(" Arm FG" , New SVec2I (10 , vertOffsetFromSource), drawColor)
190
+ Utility.DrawTextWithShadow(" Arm BG" , New SVec2I (10 , vertOffsetFromSource + 50 - 2 ), drawColor)
191
+ Utility.DrawTextWithShadow(" Leg FG" , New SVec2I (10 , vertOffsetFromSource + (50 * 2 ) - 4 ), drawColor)
192
+ Utility.DrawTextWithShadow(" Leg BG" , New SVec2I (10 , vertOffsetFromSource + (50 * 3 ) - 6 ), drawColor)
193
+
194
+ If m_DrawOutputFrameBounds Then
195
+ drawColor = [ 0 , 0 , 80 ]
196
+ m_FrameBoundingBoxSize = New SVec2I (32 , 48 )
197
+ For Local row:Int = 0 Until c_LimbCount
198
+ For Local frame:Int = 0 Until m_FrameCount
199
+ m_FrameBoundingBoxPosX[ row, frame] = 100 - 20 + (frame * (m_TileSize / m_InputZoom + 8 ))
200
+ m_FrameBoundingBoxPosY[ row, frame] = vertOffsetFromSource - 12 + (row * 48 )
201
+ Utility.DrawRectOutline(New SVec2I (m_FrameBoundingBoxPosX[ row, frame] , m_FrameBoundingBoxPosY[ row, frame] ), m_FrameBoundingBoxSize, drawColor)
202
+ Next
203
+ Next
204
+ EndIf
205
+ Flip(1 )
206
+ EndIf
207
+ EndMethod
212
208
EndType
0 commit comments