2006-12-10 05:33:38 +08:00
|
|
|
; GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
;
|
|
|
|
; This program is free software; you can redistribute it and/or modify
|
|
|
|
; it under the terms of the GNU General Public License as published by
|
|
|
|
; the Free Software Foundation; either version 2 of the License, or
|
|
|
|
; (at your option) any later version.
|
2006-10-16 09:08:54 +08:00
|
|
|
;
|
1997-11-25 06:05:25 +08:00
|
|
|
; This program is distributed in the hope that it will be useful,
|
|
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
; GNU General Public License for more details.
|
2006-10-16 09:08:54 +08:00
|
|
|
;
|
1997-11-25 06:05:25 +08:00
|
|
|
; You should have received a copy of the GNU General Public License
|
|
|
|
; along with this program; if not, write to the Free Software
|
|
|
|
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
;
|
2006-10-16 09:08:54 +08:00
|
|
|
; Truchet - a script to create Truchet patterns
|
1997-11-25 06:05:25 +08:00
|
|
|
; by Adrian Likins <aklikins@eos.ncsu.edu>
|
|
|
|
; http://www4.ncsu.edu/~aklikins/
|
|
|
|
; version about .8 give or take
|
|
|
|
;
|
|
|
|
; Lots of thanks to Quartic for his help.
|
|
|
|
;
|
|
|
|
;
|
|
|
|
; The utility of this script is left as an exercise for the reader.
|
2006-10-16 09:08:54 +08:00
|
|
|
;
|
|
|
|
; NOTE: This script works best with even values for 'thickness'.
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
(define (center-ellipse img cx cy rx ry op aa feather frad)
|
2006-10-16 09:08:54 +08:00
|
|
|
(gimp-ellipse-select img (- cx rx) (- cy ry) (+ rx rx ) (+ ry ry )
|
|
|
|
op aa feather frad)
|
|
|
|
)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
(define (use-tiles img drawable height width img2 drawable2 xoffset yoffset)
|
1998-11-15 04:46:25 +08:00
|
|
|
(gimp-edit-copy drawable2)
|
|
|
|
(let ((floating-sel (car (gimp-edit-paste drawable FALSE))))
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-layer-set-offsets floating-sel xoffset yoffset)
|
|
|
|
(gimp-floating-sel-anchor floating-sel)
|
2006-10-16 09:08:54 +08:00
|
|
|
)
|
1997-11-25 06:05:25 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(define (create-tiles img drawable1 drawable2 size thickness backcolor forecolor)
|
|
|
|
(let* (
|
2006-10-16 09:08:54 +08:00
|
|
|
(half-thickness (/ thickness 2))
|
|
|
|
(outer-radius (+ (/ size 2) half-thickness))
|
|
|
|
(inner-radius (- (/ size 2) half-thickness))
|
|
|
|
)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
(gimp-selection-all img)
|
2004-09-23 02:43:09 +08:00
|
|
|
(gimp-context-set-background backcolor)
|
2003-10-16 20:47:33 +08:00
|
|
|
(gimp-edit-fill drawable1 BACKGROUND-FILL)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
(let* (
|
2006-10-16 09:08:54 +08:00
|
|
|
(tempSize (* size 3))
|
|
|
|
(temp-img (car (gimp-image-new tempSize tempSize RGB)))
|
|
|
|
(temp-draw (car (gimp-layer-new temp-img tempSize tempSize RGB-IMAGE "Jabar" 100 NORMAL-MODE)))
|
|
|
|
)
|
1999-10-17 08:07:55 +08:00
|
|
|
(gimp-image-undo-disable temp-img)
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-image-add-layer temp-img temp-draw 0)
|
2004-09-23 02:43:09 +08:00
|
|
|
(gimp-context-set-background backcolor)
|
2003-10-16 20:47:33 +08:00
|
|
|
(gimp-edit-fill temp-draw BACKGROUND-FILL)
|
2006-10-16 09:08:54 +08:00
|
|
|
|
|
|
|
|
2004-02-03 19:46:27 +08:00
|
|
|
(center-ellipse temp-img size size outer-radius outer-radius CHANNEL-OP-REPLACE TRUE FALSE 0)
|
|
|
|
(center-ellipse temp-img size size inner-radius inner-radius CHANNEL-OP-SUBTRACT TRUE FALSE 0)
|
2006-10-16 09:08:54 +08:00
|
|
|
|
2004-02-03 19:46:27 +08:00
|
|
|
(center-ellipse temp-img (* size 2) (* size 2) outer-radius outer-radius CHANNEL-OP-ADD TRUE FALSE 0)
|
|
|
|
(center-ellipse temp-img (* size 2) (* size 2) inner-radius inner-radius CHANNEL-OP-SUBTRACT TRUE FALSE 0)
|
2004-09-23 02:43:09 +08:00
|
|
|
(gimp-context-set-background forecolor)
|
2003-10-16 20:47:33 +08:00
|
|
|
(gimp-edit-fill temp-draw BACKGROUND-FILL)
|
2006-10-16 09:08:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-selection-none temp-img)
|
|
|
|
|
|
|
|
(gimp-image-resize temp-img size size (- size) (- size))
|
|
|
|
; woo hoo it works....finally...
|
|
|
|
|
|
|
|
|
|
|
|
(gimp-selection-all temp-img)
|
1998-11-15 04:46:25 +08:00
|
|
|
(gimp-edit-copy temp-draw)
|
|
|
|
(let ((floating-sel (car (gimp-edit-paste drawable2 FALSE))))
|
2006-10-16 09:08:54 +08:00
|
|
|
(gimp-floating-sel-anchor floating-sel))
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-11-15 04:46:25 +08:00
|
|
|
(let ((floating-sel (car (gimp-edit-paste drawable1 FALSE))))
|
2007-04-27 14:24:15 +08:00
|
|
|
(gimp-floating-sel-anchor floating-sel))
|
2006-10-16 09:08:54 +08:00
|
|
|
|
2007-04-27 14:24:15 +08:00
|
|
|
(let ((drawble (car (gimp-drawable-transform-flip-simple drawable1
|
|
|
|
ORIENTATION-VERTICAL TRUE 0 TRUE)))))
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
;(gimp-display-new temp-img)
|
|
|
|
(gimp-image-delete temp-img)
|
|
|
|
)
|
2006-10-16 09:08:54 +08:00
|
|
|
)
|
1998-11-15 04:46:25 +08:00
|
|
|
)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
(define (script-fu-truchet size thickness backcolor forecolor xtiles ytiles)
|
1998-11-15 04:46:25 +08:00
|
|
|
(let* (
|
2006-10-16 09:08:54 +08:00
|
|
|
(width (* size xtiles))
|
|
|
|
(height (* size ytiles))
|
|
|
|
(img (car (gimp-image-new width height RGB)))
|
|
|
|
(tile (car (gimp-image-new size size RGB)))
|
|
|
|
(layer-one (car (gimp-layer-new img width height
|
|
|
|
RGB-IMAGE "Rambis" 100 NORMAL-MODE)))
|
|
|
|
(tiledraw1 (car (gimp-layer-new tile size size
|
|
|
|
RGB-IMAGE "Johnson" 100 NORMAL-MODE)))
|
|
|
|
(tiledraw2 (car (gimp-layer-new tile size size
|
|
|
|
RGB-IMAGE "Cooper" 100 NORMAL-MODE)))
|
|
|
|
(Xindex 0)
|
|
|
|
(Yindex 0)
|
|
|
|
)
|
2004-09-23 19:16:23 +08:00
|
|
|
|
|
|
|
(gimp-context-push)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-17 08:07:55 +08:00
|
|
|
(gimp-image-undo-disable img)
|
|
|
|
(gimp-image-undo-disable tile)
|
2006-10-16 09:08:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-image-add-layer img layer-one 0)
|
|
|
|
(gimp-image-add-layer tile tiledraw1 0)
|
|
|
|
(gimp-image-add-layer tile tiledraw2 0)
|
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
;just to look a little better
|
|
|
|
(gimp-selection-all img)
|
2004-09-23 02:43:09 +08:00
|
|
|
(gimp-context-set-background backcolor)
|
2003-10-16 20:47:33 +08:00
|
|
|
(gimp-edit-fill layer-one BACKGROUND-FILL)
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-selection-none img)
|
|
|
|
|
|
|
|
(create-tiles tile tiledraw1 tiledraw2 size thickness backcolor forecolor)
|
2006-10-16 09:08:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
(while (<= Xindex xtiles)
|
2006-10-16 09:08:54 +08:00
|
|
|
(while (<= Yindex ytiles)
|
|
|
|
(if (= (rand 2) 0)
|
|
|
|
(use-tiles img layer-one height width tile tiledraw1 (* Xindex size) (* Yindex size))
|
|
|
|
(use-tiles img layer-one height width tile tiledraw2 (* Xindex size) (* Yindex size))
|
|
|
|
)
|
|
|
|
(set! Yindex (+ Yindex 1))
|
|
|
|
)
|
|
|
|
(set! Yindex 0)
|
|
|
|
(set! Xindex (+ Xindex 1))
|
|
|
|
)
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-image-delete tile)
|
1999-10-17 08:07:55 +08:00
|
|
|
(gimp-image-undo-enable img)
|
1998-07-14 07:21:43 +08:00
|
|
|
(gimp-display-new img)
|
2004-09-23 19:16:23 +08:00
|
|
|
|
2006-10-16 09:08:54 +08:00
|
|
|
(gimp-context-pop)
|
|
|
|
)
|
|
|
|
)
|
2004-11-19 06:44:28 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
(script-fu-register "script-fu-truchet"
|
2006-10-16 09:08:54 +08:00
|
|
|
_"T_ruchet..."
|
|
|
|
_"Create an image filled with a Truchet pattern"
|
|
|
|
"Adrian Likins <aklikins@eos.ncsu.edu>"
|
|
|
|
"Adrian Likins"
|
|
|
|
"1997"
|
|
|
|
""
|
|
|
|
SF-ADJUSTMENT _"Block size" '(32 2 512 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Thickness" '(2 1 512 1 10 1 1)
|
2006-10-21 01:55:14 +08:00
|
|
|
SF-COLOR _"Background color" "white"
|
|
|
|
SF-COLOR _"Foreground color" "black"
|
2006-10-16 09:08:54 +08:00
|
|
|
SF-ADJUSTMENT _"Number of X tiles" '(5 1 512 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Number of Y tiles" '(5 1 512 1 10 1 1)
|
|
|
|
)
|
2004-11-19 06:44:28 +08:00
|
|
|
|
|
|
|
(script-fu-menu-register "script-fu-truchet"
|
2008-04-10 01:04:24 +08:00
|
|
|
"<Image>/File/New/Patterns")
|