@@ -145,6 +145,61 @@ GMTEBrush >> layer: anObject [
145
145
layer := anObject
146
146
]
147
147
148
+ {
149
+ #category : #forms ,
150
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/9/2024 22:53'
151
+ }
152
+ GMTEBrush >> lineBrush [
153
+ | radius collection start end deltaX deltaY stepX stepY error error2 x y offsets |
154
+
155
+ radius := self radius - 1 .
156
+ self resetOutputSet.
157
+ self flag: ' todo: method extraction' .
158
+ " Helper method to generate radius offsets"
159
+ offsets := OrderedCollection new .
160
+ (0 - radius to: radius) do: [:dx |
161
+ (0 - radius to: radius) do: [:dy |
162
+ (dx * dx + dy * dy <= (radius * radius)) ifTrue: [
163
+ offsets add: dx @ dy.
164
+ ].
165
+ ].
166
+ ].
167
+
168
+ self resetOutputSet.
169
+ (self currentMatrixIndex isNil or : [self firstMatrixIndex isNil]) ifTrue: [^ nil ].
170
+
171
+ start := self firstMatrixIndex.
172
+ end := self currentMatrixIndex.
173
+ deltaX := (end x - start x) abs.
174
+ deltaY := (end y - start y) abs.
175
+ stepX := (start x < end x) ifTrue: [1 ] ifFalse: [- 1 ].
176
+ stepY := (start y < end y) ifTrue: [1 ] ifFalse: [- 1 ].
177
+ error := deltaX - deltaY.
178
+ x := start x.
179
+ y := start y.
180
+
181
+ collection := OrderedCollection new .
182
+
183
+ [
184
+ | point |
185
+ point := x @ y.
186
+ offsets do: [:offset | collection add: (point + offset)].
187
+ (x = end x and : [y = end y]) ifTrue: [
188
+ self outputSet: collection asSet.
189
+ ^ self outputSet.].
190
+ error2 := 2 * error.
191
+ (error2 > (0 - deltaY)) ifTrue: [
192
+ error := error - deltaY.
193
+ x := x + stepX.
194
+ ].
195
+ (error2 < deltaX) ifTrue: [
196
+ error := error + deltaX.
197
+ y := y + stepY.
198
+ ].
199
+ ] repeat.
200
+
201
+ ]
202
+
148
203
{
149
204
#category : #accessing ,
150
205
#' squeak_changestamp' : ' Valentin Teutschbein 7/9/2024 21:18'
@@ -255,6 +310,15 @@ GMTEBrush >> selectFillBrush [
255
310
self currentBrush: [self fillBrush]
256
311
]
257
312
313
+ {
314
+ #category : #select ,
315
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/9/2024 22:27'
316
+ }
317
+ GMTEBrush >> selectLineBrush [
318
+
319
+ self currentBrush: [self lineBrush]
320
+ ]
321
+
258
322
{
259
323
#category : #select ,
260
324
#' squeak_changestamp' : ' TW 7/9/2024 19:18'
0 commit comments