2006-12-09 21:33:38 +00:00
|
|
|
; GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
;
|
|
|
|
; Make-Brush - a script for the script-fu program
|
|
|
|
; by Seth Burgess 1997 <sjburges@ou.edu>
|
|
|
|
;
|
2000-12-18 19:11:14 +00:00
|
|
|
; 18-Dec-2000 fixed to work with the new convention (not inverted) of
|
|
|
|
; gbr saver (jtl@gimp.org)
|
|
|
|
;
|
2009-01-17 22:28:01 +00:00
|
|
|
; This program is free software: you can redistribute it and/or modify
|
1997-11-24 22:05:25 +00:00
|
|
|
; it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
; the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 22:05:25 +00:00
|
|
|
; (at your option) any later version.
|
|
|
|
;
|
|
|
|
; 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.
|
|
|
|
;
|
|
|
|
; You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(define (script-fu-make-brush-rectangular name width height spacing)
|
|
|
|
(let* (
|
|
|
|
(img (car (gimp-image-new width height GRAY)))
|
|
|
|
(drawable (car (gimp-layer-new img
|
|
|
|
width height GRAY-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"MakeBrush" 100 LAYER-MODE-NORMAL)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(filename (string-append gimp-directory
|
|
|
|
"/brushes/r"
|
|
|
|
(number->string width)
|
|
|
|
"x"
|
|
|
|
(number->string height)
|
|
|
|
".gbr"))
|
|
|
|
)
|
2004-09-22 23:33:29 +00:00
|
|
|
|
|
|
|
(gimp-context-push)
|
2011-11-09 02:42:34 -05:00
|
|
|
(gimp-context-set-defaults)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-drawable-fill drawable FILL-BACKGROUND)
|
2004-09-22 23:33:29 +00:00
|
|
|
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-REPLACE 0 0 width height)
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-08-28 08:13:11 -04:00
|
|
|
; -1: NULL export_options
|
|
|
|
(file-gbr-export 1 img filename -1 spacing name)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete img)
|
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-pop)
|
|
|
|
|
|
|
|
(gimp-brushes-refresh)
|
2024-04-19 11:08:12 +02:00
|
|
|
(gimp-context-set-brush (car (gimp-brush-get-by-name name)))
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-09-27 05:44:07 -04:00
|
|
|
(script-fu-register-procedure "script-fu-make-brush-rectangular"
|
2006-10-16 01:08:54 +00:00
|
|
|
_"_Rectangular..."
|
|
|
|
_"Create a rectangular brush"
|
|
|
|
"Seth Burgess <sjburges@ou.edu>"
|
|
|
|
"1997"
|
|
|
|
SF-STRING _"Name" "Rectangle"
|
|
|
|
SF-ADJUSTMENT _"Width" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Height" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Spacing" '(25 1 100 1 10 1 0)
|
|
|
|
)
|
2004-09-23 00:11:13 +00:00
|
|
|
|
2004-11-18 22:44:28 +00:00
|
|
|
(script-fu-menu-register "script-fu-make-brush-rectangular"
|
2024-02-25 00:13:01 +01:00
|
|
|
"<Brushes>/Brushes Menu")
|
2006-10-16 01:08:54 +00:00
|
|
|
|
|
|
|
|
2006-10-20 17:55:14 +00:00
|
|
|
(define (script-fu-make-brush-rectangular-feathered name width height
|
2006-10-16 01:08:54 +00:00
|
|
|
feathering spacing)
|
|
|
|
(let* (
|
|
|
|
(widthplus (+ width feathering))
|
|
|
|
(heightplus (+ height feathering))
|
|
|
|
(img (car (gimp-image-new widthplus heightplus GRAY)))
|
|
|
|
(drawable (car (gimp-layer-new img
|
|
|
|
widthplus heightplus GRAY-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"MakeBrush" 100 LAYER-MODE-NORMAL)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(filename (string-append gimp-directory
|
|
|
|
"/brushes/r"
|
|
|
|
(number->string width)
|
|
|
|
"x"
|
|
|
|
(number->string height)
|
|
|
|
"f"
|
|
|
|
(number->string feathering)
|
|
|
|
".gbr"))
|
|
|
|
)
|
2004-09-22 23:33:29 +00:00
|
|
|
|
|
|
|
(gimp-context-push)
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-context-set-paint-mode LAYER-MODE-NORMAL)
|
|
|
|
(gimp-context-set-opacity 100.0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-drawable-fill drawable FILL-BACKGROUND)
|
2004-09-22 23:33:29 +00:00
|
|
|
|
2011-11-06 15:55:45 -05:00
|
|
|
(cond
|
|
|
|
((< 0 feathering)
|
|
|
|
(gimp-context-set-feather TRUE)
|
|
|
|
(gimp-context-set-feather-radius feathering feathering)
|
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-REPLACE
|
|
|
|
(/ feathering 2) (/ feathering 2) width height))
|
|
|
|
((>= 0 feathering)
|
|
|
|
(gimp-context-set-feather FALSE)
|
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-REPLACE 0 0 width height))
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-08-28 08:13:11 -04:00
|
|
|
(file-gbr-export 1 img filename -1 spacing name)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete img)
|
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-pop)
|
|
|
|
|
|
|
|
(gimp-brushes-refresh)
|
2024-04-19 11:08:12 +02:00
|
|
|
(gimp-context-set-brush (car (gimp-brush-get-by-name name)))
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-09-27 05:44:07 -04:00
|
|
|
(script-fu-register-procedure "script-fu-make-brush-rectangular-feathered"
|
2006-10-16 01:08:54 +00:00
|
|
|
_"Re_ctangular, Feathered..."
|
|
|
|
_"Create a rectangular brush with feathered edges"
|
|
|
|
"Seth Burgess <sjburges@ou.edu>"
|
|
|
|
"1997"
|
|
|
|
SF-STRING _"Name" "Rectangle"
|
|
|
|
SF-ADJUSTMENT _"Width" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Height" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Feathering" '(4 1 100 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Spacing" '(25 1 100 1 10 1 0)
|
|
|
|
)
|
2004-11-18 22:44:28 +00:00
|
|
|
|
|
|
|
(script-fu-menu-register "script-fu-make-brush-rectangular-feathered"
|
2024-02-25 00:13:01 +01:00
|
|
|
"<Brushes>/Brushes Menu")
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
|
2004-09-23 00:11:13 +00:00
|
|
|
(define (script-fu-make-brush-elliptical name width height spacing)
|
2006-10-16 01:08:54 +00:00
|
|
|
(let* (
|
|
|
|
(img (car (gimp-image-new width height GRAY)))
|
|
|
|
(drawable (car (gimp-layer-new img
|
|
|
|
width height GRAY-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"MakeBrush" 100 LAYER-MODE-NORMAL)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(filename (string-append gimp-directory
|
|
|
|
"/brushes/e"
|
|
|
|
(number->string width)
|
|
|
|
"x"
|
|
|
|
(number->string height)
|
|
|
|
".gbr"))
|
|
|
|
)
|
2004-09-23 00:11:13 +00:00
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-push)
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-context-set-antialias TRUE)
|
|
|
|
(gimp-context-set-feather FALSE)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-drawable-fill drawable FILL-BACKGROUND)
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-image-select-ellipse img CHANNEL-OP-REPLACE 0 0 width height)
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-08-28 08:13:11 -04:00
|
|
|
(file-gbr-export 1 img filename -1 spacing name)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete img)
|
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-pop)
|
|
|
|
|
|
|
|
(gimp-brushes-refresh)
|
2024-04-19 11:08:12 +02:00
|
|
|
(gimp-context-set-brush (car (gimp-brush-get-by-name name)))
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-09-27 05:44:07 -04:00
|
|
|
(script-fu-register-procedure "script-fu-make-brush-elliptical"
|
2006-10-16 01:08:54 +00:00
|
|
|
_"_Elliptical..."
|
|
|
|
_"Create an elliptical brush"
|
|
|
|
"Seth Burgess <sjburges@ou.edu>"
|
|
|
|
"1997"
|
|
|
|
SF-STRING _"Name" "Ellipse"
|
|
|
|
SF-ADJUSTMENT _"Width" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Height" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Spacing" '(25 1 100 1 10 1 0)
|
|
|
|
)
|
2004-09-23 00:11:13 +00:00
|
|
|
|
2004-11-18 22:44:28 +00:00
|
|
|
(script-fu-menu-register "script-fu-make-brush-elliptical"
|
2024-02-25 00:13:01 +01:00
|
|
|
"<Brushes>/Brushes Menu")
|
2006-10-16 01:08:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
(define (script-fu-make-brush-elliptical-feathered name
|
|
|
|
width height
|
|
|
|
feathering spacing)
|
|
|
|
(let* (
|
|
|
|
(widthplus (+ feathering width)) ; add 3 for blurring
|
|
|
|
(heightplus (+ feathering height))
|
|
|
|
(img (car (gimp-image-new widthplus heightplus GRAY)))
|
|
|
|
(drawable (car (gimp-layer-new img
|
|
|
|
widthplus heightplus GRAY-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"MakeBrush" 100 LAYER-MODE-NORMAL)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(filename (string-append gimp-directory
|
|
|
|
"/brushes/e"
|
|
|
|
(number->string width)
|
|
|
|
"x"
|
|
|
|
(number->string height)
|
|
|
|
"f"
|
|
|
|
(number->string feathering)
|
|
|
|
".gbr"))
|
|
|
|
)
|
2004-09-22 23:33:29 +00:00
|
|
|
|
|
|
|
(gimp-context-push)
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-context-set-antialias TRUE)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-drawable-fill drawable FILL-BACKGROUND)
|
2004-09-22 23:33:29 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(cond ((> feathering 0) ; keep from taking out gimp with stupid entry.
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-context-set-feather TRUE)
|
|
|
|
(gimp-context-set-feather-radius feathering feathering)
|
|
|
|
(gimp-image-select-ellipse img CHANNEL-OP-REPLACE
|
2006-10-16 01:08:54 +00:00
|
|
|
(/ feathering 2) (/ feathering 2)
|
2011-11-06 15:55:45 -05:00
|
|
|
width height))
|
1998-11-14 20:46:25 +00:00
|
|
|
((<= feathering 0)
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-context-set-feather FALSE)
|
|
|
|
(gimp-image-select-ellipse img CHANNEL-OP-REPLACE 0 0 width height)))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-08-28 08:13:11 -04:00
|
|
|
(file-gbr-export 1 img filename -1 spacing name)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete img)
|
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-context-pop)
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2004-09-22 23:33:29 +00:00
|
|
|
(gimp-brushes-refresh)
|
2024-04-19 11:08:12 +02:00
|
|
|
(gimp-context-set-brush (car (gimp-brush-get-by-name name)))
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-09-27 05:44:07 -04:00
|
|
|
(script-fu-register-procedure "script-fu-make-brush-elliptical-feathered"
|
2006-10-16 01:08:54 +00:00
|
|
|
_"Elli_ptical, Feathered..."
|
|
|
|
_"Create an elliptical brush with feathered edges"
|
|
|
|
"Seth Burgess <sjburges@ou.edu>"
|
|
|
|
"1997"
|
|
|
|
SF-STRING _"Name" "Ellipse"
|
|
|
|
SF-ADJUSTMENT _"Width" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Height" '(20 1 200 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Feathering" '(4 1 100 1 10 0 1)
|
|
|
|
SF-ADJUSTMENT _"Spacing" '(25 1 100 1 10 1 0)
|
|
|
|
)
|
2004-11-18 22:44:28 +00:00
|
|
|
|
|
|
|
(script-fu-menu-register "script-fu-make-brush-elliptical-feathered"
|
2024-02-25 00:13:01 +01:00
|
|
|
"<Brushes>/Brushes Menu")
|