Skip to content

Commit 0e8e832

Browse files
authored
Bugs fixed. Use existing brush
1 parent 5502124 commit 0e8e832

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

sg-mystic-rose.scm

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
palette
2121
gradient
2222
create-path?)
23-
(let* ( (create-path (not (zero? create-path?)))
23+
24+
(let* (
25+
(create-path (not (zero? create-path?)))
2426
(color-mode (+ (* 2 colormodea) randomb))
2527
(width (car (gimp-drawable-width drawable)))
2628
(height (car (gimp-drawable-height drawable)))
@@ -51,23 +53,31 @@
5153
(gimp-image-undo-group-start image)
5254
(gimp-context-push)
5355
(set! old-fg (car (gimp-context-get-foreground)))
54-
(gimp-message "started")
56+
;(gimp-message "started")
5557
(gimp-context-set-paint-method "gimp-paintbrush")
5658
(gimp-context-set-paint-mode LAYER-MODE-NORMAL)
57-
(set! brush (car (gimp-brush-new "sg mystic temporary")))
58-
(gimp-brush-set-shape brush BRUSH-GENERATED-CIRCLE)
59-
(gimp-brush-set-hardness brush 0.99)
60-
(gimp-brush-set-aspect-ratio brush 1.0)
61-
(gimp-brush-set-spacing brush 20.0)
62-
(gimp-brush-set-radius brush (round (/ thickness 2)))
59+
(set! brush (car (gimp-context-get-brush)))
60+
;(set! brush (car (gimp-brush-new "sg mystic temporary")))
61+
;(gimp-brush-set-shape brush BRUSH-GENERATED-CIRCLE)
62+
;(gimp-brush-set-spikes brush 2)
63+
;(gimp-brush-set-hardness brush 0.99)
64+
;(gimp-brush-set-aspect-ratio brush 1.0)
65+
;(gimp-brush-set-spacing brush 20.0)
66+
;(gimp-brush-set-radius brush (round (/ thickness 2)))
6367
;(gimp-brushes-refresh)
6468

65-
;(gimp-brush-set-radius brush 2.0)
66-
(gimp-context-set-brush brush) ; was brush not "temporary"
69+
(gimp-context-set-brush-size thickness)
70+
;(gimp-context-set-brush brush) ; was brush not "temporary"
71+
72+
;(gimp-brush-set-radius brush 8.0)
73+
;(gimp-brushes-refresh)
6774

6875
(gimp-context-set-foreground old-fg)
6976
(gimp-context-set-opacity 100.0)
7077

78+
(gimp-context-set-palette palette)
79+
(gimp-context-set-gradient gradient)
80+
7181
;(gimp-message "line 56")
7282
(set! path (car (gimp-vectors-new image (string-append (number->string number-of-points)
7383
"pt mystic rose" ))))
@@ -111,18 +121,20 @@
111121
;(gimp-message "line 106 using fg")
112122
)
113123
((= color-mode 1) ; random color
124+
(gimp-message "line 108 - random color")
114125
(gimp-context-set-foreground (list (rand 255) (rand 255) (rand 255))) ; were all random 256
115126
;(gimp-message "line 100 random color")
116127
)
117128
((= color-mode 2) ; palette - color-index is offset into palette
118129
;(gimp-message "line 103 - palette")
119130
(gimp-context-set-foreground
120-
(car (gimp-palette-entry-get-color palette (floor (modulo color-index (- num-palette-entries 1))))) )
131+
(car (gimp-palette-entry-get-color palette (floor (modulo color-index (- num-palette-entries 0))))) )
121132
)
122133
((= color-mode 3) ; palette random - choose random color from specified palette
123134
;(gimp-message "line 108 - palette random")
135+
(gimp-context-set-palette palette)
124136
(gimp-context-set-foreground
125-
(car (gimp-palette-entry-get-color palette (rand (- num-palette-entries 1)))) ) ; was rand dum-pal-entr
137+
(car (gimp-palette-entry-get-color palette (- (rand (- num-palette-entries 0)) 1))) ) ; was rand dum-pal-entr
126138
)
127139
((= color-mode 4) ; gradient - color-index is offset into specified gradient
128140
;(gimp-message "line 113 - gradient color")
@@ -135,6 +147,7 @@
135147
(quit)
136148
)
137149
)
150+
(gimp-context-set-gradient gradient)
138151
(let* ((color-vector (cadr (gimp-gradient-get-custom-samples gradient
139152
1
140153
(vector (/ color-index num-strokes))
@@ -148,6 +161,7 @@
148161
)
149162
((= color-mode 5) ; gradient random - random color from specified gradient
150163
;(gimp-message "line 134 - gradient random")
164+
(gimp-context-set-gradient gradient)
151165
(let* ((color-vector (cadr (gimp-gradient-get-custom-samples gradient
152166
1
153167
(vector (/ (random num-strokes) num-strokes))
@@ -205,10 +219,11 @@
205219
; )
206220
;)
207221

208-
(gimp-message "Good finish OK")
222+
;(gimp-message "Good finish OK")
209223
(gimp-context-pop)
210224
(gimp-image-undo-group-end image)
211225
(gimp-displays-flush)
226+
(gc) ; garbage cleanup; temp brush was used
212227
)
213228
)
214229

@@ -222,7 +237,7 @@
222237
SF-IMAGE "Image" 0
223238
SF-DRAWABLE "Layer" 0
224239
SF-ADJUSTMENT "Number of points" '(12 3 179 1 10 0 1)
225-
SF-ADJUSTMENT "Line thickness (not used)" '(4 1 20 1 3 0 1)
240+
SF-ADJUSTMENT "Line thickness (overides brush size)" '(4 1 210 1 3 0 1)
226241
SF-TOGGLE "Random?" FALSE
227242
SF-OPTION "Color method" '("Foreground" "Palette" "Gradient")
228243
SF-PALETTE "Palette" "Default"

0 commit comments

Comments
 (0)