Skip to content

Commit e777c80

Browse files
authored
Remove error with selection
Removed error and improved prompts in the registration.
1 parent 9ab4ff1 commit e777c80

File tree

1 file changed

+62
-18
lines changed

1 file changed

+62
-18
lines changed

JMS-Grid_Create_Hexagon.scm

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
;; * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
1919
;; ***************************************************************************
2020

21-
(define (script-fu-HexGrid
21+
(define (script-fu-HexGrid-jms
2222
gType
2323
circDiam
2424
xCirc
@@ -47,16 +47,19 @@
4747
(xStart 0.0)
4848
(yStart 0.0)
4949
(rowCheck 0.0)
50+
51+
(vGapSpace 0)
5052
)
5153

5254
(gimp-context-push)
5355
(cond
5456
((= gType 0)
57+
(set! vGapSpace (+ -4.5 (* gapSpace 0.722)) )
5558
(set! inWidth (+ (+ tBorder (* circDiam xCirc)) (* gapSpace (- xCirc 1))))
56-
(set! inHeight (+ (+ tBorder (* circDiam yCirc)) (* gapSpace (- yCirc 1))))
59+
(set! inHeight (+ (+ tBorder (* circDiam yCirc)) (* vGapSpace (- yCirc 1))))
5760
)
5861
((= gType 1)
59-
(set! xGap (round (* s3 (+ circRad (round (* 0.5 gapSpace))))))
62+
(set! xGap (round (* s3 (+ circRad (round (* gapSpace 0.5))))))
6063
(set! yGap (* gapSpace (- yCirc 1)))
6164
(set! inWidth (+ (+ tBorder circDiam) (+ (* (- xCirc 1) xGap))))
6265
(set! inHeight (+ tBorder (+ circRad (+ yGap (+ (round (* gapSpace 0.5)) (* circDiam yCirc))))))
@@ -68,6 +71,10 @@
6871

6972
(gimp-image-insert-layer theImage baseLayer 0 0)
7073

74+
(gimp-context-set-feather FALSE)
75+
(gimp-context-set-feather-radius 0.0 0.0)
76+
(gimp-context-set-antialias TRUE)
77+
7178
(gimp-context-set-background bgColor)
7279
(gimp-context-set-foreground gridColor)
7380

@@ -77,29 +84,66 @@
7784
(cond
7885
((= gType 0)
7986
(set! xStart (+ oBorder (* xFlag (+ circDiam gapSpace))))
87+
88+
;(set! rowCheck 0.0)
89+
; reduce vGapSpace by just less than the golden ratio to improve appearance
90+
(set! vGapSpace (+ -4.5 (* gapSpace 0.722)) )
91+
;(gimp-message (number->string vGapSpace))
8092
)
8193
((= gType 1)
8294
(if (= (fmod xFlag 2) 1)
83-
(set! rowCheck (+ (* gapSpace 0.5) circRad))
95+
(set! rowCheck (+ (* 0.5 gapSpace) circRad))
8496
)
85-
(set! xStart (+ oBorder (* s3 (+ circRad (round (* 0.5 gapSpace))) xFlag)))
97+
(set! xStart (+ oBorder (* s3 (* (+ circRad (round (* 0.5 gapSpace))) xFlag))))
8698
)
8799
)
88100

89101
(while (< yFlag yCirc)
102+
;(gimp-message (number->string rowCheck))
103+
;(gimp-message (number->string oBorder))
104+
;(gimp-message (number->string gapSpace))
105+
;(gimp-message (number->string yFlag))
106+
;(quit)
107+
108+
;(gimp-message "line102")
109+
;(set! yStart (+ rowCheck (+ oBorder (+ (* gapSpace yFlag) (* circDiam yFlag)))))
90110
(set! yStart (+ rowCheck (+ oBorder (+ (* gapSpace yFlag) (* circDiam yFlag)))))
91111

92-
(gimp-free-select theImage 12
112+
(if (= gType 0)
113+
(begin
114+
;(gimp-message "line111 adjust yStart")
115+
(set! yStart (+ rowCheck (+ oBorder (+ (* vGapSpace yFlag) (* circDiam yFlag)))))
116+
)
117+
)
118+
119+
120+
;(gimp-message "line106")
121+
;(gimp-free-select theImage 12
122+
; (vector xStart (+ yStart (* circDiam 0.5))
123+
; (+ xStart (* circDiam 0.25)) (+ yStart (* circDiam 0.067))
124+
; (+ xStart (* circDiam 0.75)) (+ yStart (* circDiam 0.067))
125+
; (+ xStart circDiam) (+ yStart (* circDiam 0.5))
126+
; (+ xStart (* circDiam 0.75)) (+ yStart (* circDiam 0.933))
127+
; (+ xStart (* circDiam 0.25)) (+ yStart (* circDiam 0.933))
128+
; )
129+
; CHANNEL-OP-REPLACE TRUE FALSE 0)
130+
131+
;(gimp-message "line130")
132+
(gimp-context-set-feather FALSE)
133+
;(gimp-context-set-feather-radius 0.0 0.0)
134+
135+
(gimp-image-select-polygon theImage CHANNEL-OP-REPLACE 12
93136
(vector xStart (+ yStart (* circDiam 0.5))
94137
(+ xStart (* circDiam 0.25)) (+ yStart (* circDiam 0.067))
95138
(+ xStart (* circDiam 0.75)) (+ yStart (* circDiam 0.067))
96139
(+ xStart circDiam) (+ yStart (* circDiam 0.5))
97140
(+ xStart (* circDiam 0.75)) (+ yStart (* circDiam 0.933))
98141
(+ xStart (* circDiam 0.25)) (+ yStart (* circDiam 0.933))
99142
)
100-
CHANNEL-OP-REPLACE TRUE FALSE 0)
101-
(gimp-edit-bucket-fill baseLayer BUCKET-FILL-FG LAYER-MODE-NORMAL 100 255 0 0 0)
102-
(set! yFlag (+ 1 yFlag))
143+
)
144+
145+
(gimp-edit-bucket-fill baseLayer BUCKET-FILL-FG LAYER-MODE-NORMAL 100 255 0 0 0)
146+
(set! yFlag (+ yFlag 1))
103147
)
104148

105149
(set! xFlag (+ xFlag 1))
@@ -115,7 +159,7 @@
115159
)
116160

117161
(script-fu-register
118-
"script-fu-HexGrid"
162+
"script-fu-HexGrid-jms"
119163
"Grid - Hexagon..."
120164
"Creates a grid of X by Y Hexagons. either in rectangular or hexagonal packing. - \nfile:JMS-Grid_Create_Hexagon.scm"
121165
"James Sambrook"
@@ -124,16 +168,16 @@
124168
""
125169
SF-OPTION "Grid Type" '( "Rectangular"
126170
"Hexagonal")
127-
SF-ADJUSTMENT _"Circular Diameter" '(40 10 200 1 5 0 0)
128-
SF-ADJUSTMENT _"Hexes in X Direction" '(10 1 100 1 5 0 0)
129-
SF-ADJUSTMENT _"Hexes in y Direction" '(10 1 100 1 5 0 0)
130-
SF-ADJUSTMENT _"Outer Border Around Hexagons" '(10 1 100 1 5 0 0)
131-
SF-ADJUSTMENT _"Gap Between the Hexagons" '(10 1 100 1 5 0 0)
132-
SF-COLOR _"Color for grid lines" '(0 0 0)
133-
SF-COLOR _"Color for interior" '(255 255 255)
171+
SF-ADJUSTMENT "Circular Diameter" '(40 10 200 1 5 0 0)
172+
SF-ADJUSTMENT "Hexes in X Direction" '(10 1 100 1 5 0 0)
173+
SF-ADJUSTMENT "Hexes in y Direction" '(10 1 100 1 5 0 0)
174+
SF-ADJUSTMENT "Outer Border Around Hexagons" '(10 0 100 1 5 0 0)
175+
SF-ADJUSTMENT "Gap Between the Hexagons" '(10 0 100 1 5 0 0)
176+
SF-COLOR "Color for Hexagons" '(0 0 0)
177+
SF-COLOR "Color for background" '(255 255 255)
134178
)
135179

136-
(script-fu-menu-register "script-fu-HexGrid"
180+
(script-fu-menu-register "script-fu-HexGrid-jms"
137181
"<Toolbox>/Script-Fu/Render/Pattern/")
138182

139183
;end of script

0 commit comments

Comments
 (0)