@@ -12,6 +12,15 @@ Class {
12
12
#category : #' GM-TE-UI'
13
13
}
14
14
15
+ {
16
+ #category : #' as yet unclassified' ,
17
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:01'
18
+ }
19
+ GMTEBrush class >> borderingOffsets [
20
+
21
+ ^ {(- 1 )@0 . 0 @(- 1 ). 1 @0 . 0 @1 }
22
+ ]
23
+
15
24
{
16
25
#category : #forms ,
17
26
#' squeak_changestamp' : ' JS 7/11/2024 15:40'
@@ -61,61 +70,57 @@ GMTEBrush >> currentMatrixIndex: anObject [
61
70
62
71
{
63
72
#category : #' as yet unclassified' ,
64
- #' squeak_changestamp' : ' JS 7/11/2024 13:59 '
73
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:10 '
65
74
}
66
75
GMTEBrush >> executeWithMatrixIndex: anIndex andLayer: aLayer [
67
76
77
+ anIndex ifNil: [^ nil ].
68
78
self currentMatrixIndex: anIndex.
69
79
self layer: aLayer.
70
80
^ self currentBrush value
71
81
]
72
82
73
83
{
74
84
#category : #forms ,
75
- #' squeak_changestamp' : ' JS 7/11/2024 14:07 '
85
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:10 '
76
86
}
77
87
GMTEBrush >> fillBrush [
78
88
79
- | collection startTile visited |
89
+ | startTile visited |
80
90
self resetOutputSet.
81
- self currentMatrixIndex ifNil: [^ nil ].
82
91
83
92
visited := Matrix rows: (self layer rowCount) columns: self layer columnCount.
84
- collection := OrderedCollection new .
85
93
startTile := self layer at: self currentMatrixIndex y at: self currentMatrixIndex x.
86
94
87
- collection add: self currentMatrixIndex.
95
+ self outputSet add: self currentMatrixIndex.
88
96
visited at: self currentMatrixIndex y at: self currentMatrixIndex x put: true .
89
97
90
- self fillDfsWithVisited: visited andIndex: self currentMatrixIndex andOriginTile: startTile andCollection: collection.
91
- self outputSet: collection asSet.
98
+ self fillDfsWithVisited: visited andIndex: self currentMatrixIndex andOriginTile: startTile andSet: self outputSet.
92
99
93
100
^ self outputSet
94
101
]
95
102
96
103
{
97
104
#category : #forms ,
98
- #' squeak_changestamp' : ' JS 7/11/2024 13:58 '
105
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:05 '
99
106
}
100
- GMTEBrush >> fillDfsWithVisited: aVisitedMatrix andIndex: anIndex andOriginTile: anOriginTile andCollection: aCollection [
107
+ GMTEBrush >> fillDfsWithVisited: aVisitedMatrix andIndex: anIndex andOriginTile: anOriginTile andSet: aSet [
101
108
102
- | borderingOffsets |
103
109
self flag: ' REFACTOR!' .
104
- borderingOffsets := {(- 1 )@0 . 0 @(- 1 ). 1 @0 . 0 @1 }.
105
- borderingOffsets do: [:offset |
110
+ GMTEBrush borderingOffsets do: [:offset |
106
111
| newIndex newTile |
107
112
newIndex := offset + anIndex.
108
113
((self layer inBounds: newIndex) and : [(aVisitedMatrix at: newIndex y at: newIndex x) isNil]) ifTrue: [
109
114
newTile := self layer at: newIndex y at: newIndex x.
110
115
anOriginTile
111
- ifNil: [newTile ifNil: [aCollection add: newIndex.
116
+ ifNil: [newTile ifNil: [aSet add: newIndex.
112
117
aVisitedMatrix at: newIndex y at: newIndex x put: true .
113
- self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andCollection: aCollection ]]
118
+ self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andSet: aSet ]]
114
119
ifNotNil: [
115
120
(newTile isNil not and : [anOriginTile imageForm bits hash = newTile imageForm bits hash]) ifTrue: [
116
- aCollection add: newIndex.
121
+ aSet add: newIndex.
117
122
aVisitedMatrix at: newIndex y at: newIndex x put: true .
118
- self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andCollection: aCollection ]]]]
123
+ self fillDfsWithVisited: aVisitedMatrix andIndex: newIndex andOriginTile: anOriginTile andSet: aSet ]]]]
119
124
]
120
125
121
126
{
@@ -162,18 +167,15 @@ GMTEBrush >> layer: anObject [
162
167
163
168
{
164
169
#category : #forms ,
165
- #' squeak_changestamp' : ' JS 7/11/2024 16:16 '
170
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:11 '
166
171
}
167
172
GMTEBrush >> lineBrush [
168
173
169
- | offsets |
170
174
self resetOutputSet.
171
- (self currentMatrixIndex isNil or : [self firstMatrixIndex isNil]) ifTrue: [^ nil ].
172
-
173
- offsets := self calculateOffsetsForRadius: self offsetCorrectedRadius.
174
-
175
+ self firstMatrixIndex ifNil: [^ nil ].
176
+
175
177
(self rasterizeLineBetweenAStart: self firstMatrixIndex andAnEnd: self currentMatrixIndex) do: [:point |
176
- offsets do: [:offset |
178
+ ( self calculateOffsetsForRadius: self offsetCorrectedRadius) do: [:offset |
177
179
self outputSet add: (point + offset)]].
178
180
179
181
^ (self outputSet)
@@ -208,32 +210,29 @@ GMTEBrush >> outputSet: anObject [
208
210
209
211
{
210
212
#category : #accessing ,
211
- #' squeak_changestamp' : ' Valentin Teutschbein 7/6 /2024 12:48 '
213
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11 /2024 17:11 '
212
214
}
213
215
GMTEBrush >> radius [
216
+
214
217
^ radius
215
218
]
216
219
217
220
{
218
221
#category : #accessing ,
219
- #' squeak_changestamp' : ' Valentin Teutschbein 7/9 /2024 22:08 '
222
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11 /2024 17:15 '
220
223
}
221
- GMTEBrush >> radius: anObject [
222
- radius := anObject
224
+ GMTEBrush >> radius: aNumber [
225
+
226
+ radius := aNumber
223
227
]
224
228
225
229
{
226
230
#category : #forms ,
227
- #' squeak_changestamp' : ' JS 7/11/2024 16:14 '
231
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:09 '
228
232
}
229
233
GMTEBrush >> radiusBrush [
230
234
231
- | offsets |
232
- self currentMatrixIndex ifNil: [^ nil ].
233
-
234
- offsets := self calculateOffsetsForRadius: self offsetCorrectedRadius.
235
-
236
- offsets do: [:i |
235
+ (self calculateOffsetsForRadius: self offsetCorrectedRadius) do: [:i |
237
236
self outputSet add: (self currentMatrixIndex + i)].
238
237
239
238
^ self outputSet
@@ -280,12 +279,12 @@ GMTEBrush >> rasterizeLineBetweenAStart: aStartPoint andAnEnd: anEndPoint [
280
279
281
280
{
282
281
#category : #forms ,
283
- #' squeak_changestamp' : ' JS 7/11/2024 16:29 '
282
+ #' squeak_changestamp' : ' Valentin Teutschbein 7/11/2024 17:09 '
284
283
}
285
284
GMTEBrush >> rectangleBrush [
286
285
287
286
self resetOutputSet.
288
- ( self currentMatrixIndex isNil or : [ self firstMatrixIndex isNil]) ifTrue : [^ nil ].
287
+ self firstMatrixIndex ifNil : [^ nil ].
289
288
290
289
self flag: ' besser machen?' .
291
290
(self currentMatrixIndex x min: self firstMatrixIndex x) to: (self currentMatrixIndex x max: self firstMatrixIndex x) do: [:row |
0 commit comments