Rotating brushes

Discussion in 'General GIMP help' started by stan calder, Jul 8, 2008.

  1. stan calder

    stan calder New Member

    Joined:
    Jul 1, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Is it possible to rotate a brush? ........... or rotate a layer?

    Thanks
  2. L7hope

    L7hope Member

    Joined:
    Jun 30, 2008
    Messages:
    654
    Likes Received:
    0
    Trophy Points:
    16
    I don't know about a brush...But to rotate a layer just go to Layer -> Transform and then what ever you want.
    Or you could use the Rotate tool. ;D
  3. lamaz1928

    lamaz1928 Active Member

    Joined:
    Dec 9, 2007
    Messages:
    2,205
    Likes Received:
    0
    Trophy Points:
    36
    Occupation:
    School.....*sigh*
    Location:
    Tennessee
    Home page:
    L7 is right. layers are easy. but what you can do to rotate a brush is somewhat simple. create a new layer, then paste your brush. rotate that one layer to your desired degree. u might have to create a new layer for each brush....but yeah :D
  4. L7hope

    L7hope Member

    Joined:
    Jun 30, 2008
    Messages:
    654
    Likes Received:
    0
    Trophy Points:
    16
    Is there a way to rotate a brush without rotating the layer? :question:
    It would certainly make things faster! 8)
  5. lamaz1928

    lamaz1928 Active Member

    Joined:
    Dec 9, 2007
    Messages:
    2,205
    Likes Received:
    0
    Trophy Points:
    36
    Occupation:
    School.....*sigh*
    Location:
    Tennessee
    Home page:
    yeah.....
  6. Siddharth

    Siddharth Active Member

    Joined:
    Nov 27, 2007
    Messages:
    1,829
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    India
    Home page:
    @lamaz u copied my words ;D
  7. lamaz1928

    lamaz1928 Active Member

    Joined:
    Dec 9, 2007
    Messages:
    2,205
    Likes Received:
    0
    Trophy Points:
    36
    Occupation:
    School.....*sigh*
    Location:
    Tennessee
    Home page:
    haha. sorray
  8. Gimper

    Gimper Member

    Joined:
    Aug 31, 2007
    Messages:
    962
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Sydney
    Home page:
    unfortunately GIMP dose not have a brush rotating feature. the only way it can be done is to rotate the layer.
  9. L7hope

    L7hope Member

    Joined:
    Jun 30, 2008
    Messages:
    654
    Likes Received:
    0
    Trophy Points:
    16
    That's what I thought... Sucks... Oh well. ???

    Do you think that it will be added in 2.5?
  10. Leo_in_NJ

    Leo_in_NJ New Member

    Joined:
    Jul 23, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Here is a script (under Script-Fu/BrushUtil) that will rotate (and/or resize) any gbr brush. Copy the code below, paste it into a text editor (beware Notepad; it turns automatic line breaks into hard breaks, which "breaks" the script). Save it as resizebrush.scm in your scripts directory. Check the toolbox File menu/Preferences/Folders/Scripts if you don't know where it is. Restart GIMP.

    I have translated the interface from Chinese to English.



    ;; resizebrush.scm -*-scheme-
    ;; resizes a (gbr)-brush
    ;; version 1.0 2005-11-13
    ;;
    ;; Copyright (C) 2005 by Michael Hoelzen <MichaelHoelzen@aol.com>
    ;; http://www.remoserv.de
    ;;
    ; 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.
    ;
    ; 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.
    ;
    ; version 1.1
    ; the #resiZed.gbr will now be saved in the gimp-directory instead of
    ; the gimp-data-directory which is write-protected in unix
    ;
    ; version 1.2
    ; changed \\brushes\\ to /brushes/ for unix-confirmity
    ;
    ; version 1.3 Modify by James Hwang
    ; 加入灰階選項,讓縮放之後的筆刷也能改變顏色
    ;
    ; version 1.4 Modify by James Hwang
    ; 加入旋轉
    ;
    ; version 2.4 fixed for Gimp 2.4 by James Hwang
    ; 加入鏡射
    (define (script-fu-resize-brush image drawable resFactor angSel mirror bgray?)
    (define brushnameResi "#resiZed")
    (define filesave (string-append "" gimp-directory "/brushes/" brushnameResi ".gbr"))
    (define brushnameIn (car (gimp-context-get-brush)))
    (define (testIfresiZed a)
    (let* (
    (len1)
    (len2)
    (sstr)
    )
    (set! len1 (string-length a))
    (set! len2 (string-length brushnameResi))
    (if (>= len1 len2)
    (begin
    (set! sstr (substring a (- len1 len2) len1))
    (if (string=? sstr brushnameResi)
    (begin
    (set! len1 (- len1 len2))
    (substring a 0 len1)
    )
    a
    )
    )
    a
    )
    ; (if (not (null? (string-search brushnameResi a)))
    ; (substring a 0 (string-search brushnameResi a))
    ; a
    ; )
    )
    )
    (let* (
    (actualbrush)
    (layer)
    (scolor)
    (bcolor)
    (arrayToPaint)
    )
    (set! actualbrush (testIfresiZed brushnameIn))
    ;(set! actualbrush brushnameIn)
    (gimp-context-set-brush actualbrush)
    (let*
    (
    (brushnameOut (string-append actualbrush brushnameResi))
    (spacing (car (gimp-brush-get-spacing actualbrush)))
    (brushDimens (gimp-brush-get-info actualbrush))
    (brushWidth (car brushDimens))
    (brushHeight (cadr brushDimens))
    (resiZedWidth (* brushWidth resFactor))
    (resiZedHeight(* brushHeight resFactor))
    (centerX (/ brushWidth 2))
    (centerY (/ brushHeight 2))
    (centerXpluseins(+ centerX 1))
    (centerYpluseins(+ centerY 1))
    (angle (* angSel (/ 3.14159 180)))
    )

    (and (> resiZedWidth 1)(> resiZedHeight 1)
    (begin
    (set! arrayToPaint (cons-array 4 'double))
    (aset arrayToPaint 0 centerX)
    (aset arrayToPaint 1 centerY)
    (aset arrayToPaint 2 centerXpluseins)
    (aset arrayToPaint 3 centerYpluseins)
    (set! image (car (gimp-image-new brushWidth brushHeight RGB)))
    (set! layer (car (gimp-layer-new image brushWidth brushHeight 1 "layer 1" 100 0)))
    (gimp-image-undo-disable image)
    (gimp-image-add-layer image layer 0)
    (gimp-drawable-fill layer 3)
    (if (= bgray? TRUE)
    (begin
    (set! scolor (car (gimp-context-get-foreground)))
    (set! bcolor (car (gimp-context-get-background)))
    (gimp-context-set-foreground '(0 0 0))
    (gimp-context-set-background '(255 255 255))
    (gimp-paintbrush-default layer 4 arrayToPaint)
    (gimp-image-scale image resiZedWidth resiZedHeight)
    (if (not (= angle 0))
    (begin
    (gimp-drawable-transform-rotate-default layer angle 1 0 0 1 0)
    (gimp-image-resize-to-layers image)
    )
    )
    (cond
    ((= mirror 1)
    (gimp-image-flip image ORIENTATION-HORIZONTAL))
    ((= mirror 2)
    (gimp-image-flip image ORIENTATION-VERTICAL))
    )
    (gimp-image-convert-grayscale image)
    (set! layer (car (gimp-image-flatten image)))
    (gimp-context-set-foreground scolor)
    (gimp-context-set-background bcolor)
    )
    (begin
    (gimp-paintbrush-default layer 4 arrayToPaint)
    (gimp-image-scale image resiZedWidth resiZedHeight)
    (if (not (= angle 0))
    (begin
    (gimp-drawable-transform-rotate-default layer angle 1 0 0 1 0)
    (gimp-image-resize-to-layers image)
    )
    )
    (cond
    ((= mirror 1)
    (gimp-image-flip image ORIENTATION-HORIZONTAL))
    ((= mirror 2)
    (gimp-image-flip image ORIENTATION-VERTICAL))
    )
    )
    )
    (file-gbr-save 1 image layer filesave filesave spacing brushnameOut)
    (gimp-image-undo-enable image)
    (gimp-image-delete image)
    (gimp-brushes-refresh)
    (gimp-context-set-brush brushnameOut)))
    )
    )
    )
    ;
    (script-fu-register "script-fu-resize-brush"
    _"_Resize Rotate Brush"
    "Resize Rotate a brush, Base on resizebrush.scm by Michael Hoelzen"
    "James Huang"
    "James Huang"
    "2008"
    ""
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-ADJUSTMENT _"Scale Factor" '(1.0 0.1 3.0 0.1 1 1 0)
    SF-ADJUSTMENT _"Rotate Degrees" '(0 -180 180 1 10 0 0)
    SF-OPTION _"Transform" '("None" "Mirror" "Invert")
    SF-TOGGLE "Grayscale" TRUE
    ;SF-ADJUSTMENT _"resFactor" '(1.0 0.1 3.0 0.1 1 1 0)
    ;SF-ADJUSTMENT _"Angle" '(0 0 359 1 10 0 0)
    ;SF-TOGGLE "Grayscale" TRUE
    )
    (script-fu-menu-register "script-fu-resize-brush"
    _"<Image>/Script-Fu/BrushUtil")
  11. L7hope

    L7hope Member

    Joined:
    Jun 30, 2008
    Messages:
    654
    Likes Received:
    0
    Trophy Points:
    16
    WOW! THIS IS AWESOME! :eek: :D (And yes I'm yelling :p )
    Thank you so much! This is why I love open-source so much! :D

    Oh, BTW, it also works for .abr brushes. 8)

    Thanks again!
  12. Leo_in_NJ

    Leo_in_NJ New Member

    Joined:
    Jul 23, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Forgot to mention that the rotate/resize script uses the same file name every time, so if you want to save a brush permanently, you have to rename it.
  13. tripwire45

    tripwire45 Member

    Joined:
    Jun 30, 2008
    Messages:
    365
    Likes Received:
    0
    Trophy Points:
    16
    Occupation:
    Technical Writer, Author, and Editor
    Location:
    Boise, Idaho, USA
    Home page:
    This is deffo a time when this forum could use a "rep" system. Very good info, Leo. Kudos. :)

    -Trip
  14. Ajit

    Ajit Active Member

    Joined:
    Mar 29, 2008
    Messages:
    3,535
    Likes Received:
    0
    Trophy Points:
    36
    Occupation:
    Student
    Location:
    Texas
    Home page:
    i haven't tested this but if it truly does work which i assume from the responses that it does, i think the code itself should be stickied. MODS?
  15. L7hope

    L7hope Member

    Joined:
    Jun 30, 2008
    Messages:
    654
    Likes Received:
    0
    Trophy Points:
    16
    I agree with Ajit. It should also be in the gimp's add-on if it already isn't. :D
  16. real_life

    real_life New Member

    Joined:
    Aug 23, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    hi everyone,
    i have done what Leo in nj said in his post, but i didnt notice any change in Gimp, i am tryin to figure out how to rotate brushes, can anyone help me
  17. L7hope

    L7hope Member

    Joined:
    Jun 30, 2008
    Messages:
    654
    Likes Received:
    0
    Trophy Points:
    16
    It should show up as an option in your menus. I'm not sure where it is because I edited mine be some where different.
    If I remember correctly it's called script fu resize brush. So look for that.

    Where did you save your script? Did you save it as a .scm?

    As always, you can just rotate you layer as a fall back. :)
  18. Stonkey

    Stonkey Member

    Joined:
    Jan 3, 2008
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    Hey, is there a chance that someone could update this for 2.6? I tried it out, and the dialog opened fine, but when I went to apply the rotation to the brush, I got an error message. I don't know if that has anything to do with the version or not.
  19. Anonymous

    Anonymous Guest

    This version works in 2.6.5

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; resizebrush.scm -*-scheme-
    ;; resizes a (gbr)-brush
    ;; version 1.0 2005-11-13
    ;;
    ;; Copyright (C) 2005 by Michael Hoelzen <MichaelHoelzen@aol.com>
    ;; http://www.remoserv.de
    ;;
    ; 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.
    ;
    ; 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.
    ;
    ; version 1.1
    ; the #resiZed.gbr will now be saved in the gimp-directory instead of
    ; the gimp-data-directory which is write-protected in unix
    ;
    ; version 1.2
    ; changed \\brushes\\ to /brushes/ for unix-confirmity
    ;
    ; version 1.3 Modify by James Hwang
    ; ??????,??????????????
    ;
    ; version 1.4 Modify by James Hwang
    ; ????
    ;
    ; version 2.4 fixed for Gimp 2.4 by James Hwang
    ; ????
    (define (script-fu-resize-brush image drawable resFactor angSel mirror bgray?)
    (define brushnameResi "")
    (define filesave (string-append "" gimp-directory "/brushes/" brushnameResi "actualbrush1.gbr"))
    (define brushnameIn (car (gimp-context-get-brush)))
    (define (testIfresiZed a)
    (let* (
    (len1 0)
    (len2 0)
    (sstr "")
    )
    (set! len1 (string-length a))
    (set! len2 (string-length brushnameResi))
    (if (>= len1 len2)
    (begin
    (set! sstr (substring a (- len1 len2) len1))
    (if (string=? sstr brushnameResi)
    (begin
    (set! len1 (- len1 len2))
    (substring a 0 len1)
    )
    a
    )
    )
    a
    )
    ; (if (not (null? (string-search brushnameResi a)))
    ; (substring a 0 (string-search brushnameResi a))
    ; a
    ; )
    )
    )
    (let* (
    (actualbrush nil)
    (layer nil)
    (scolor nil)
    (bcolor nil)
    (arrayToPaint nil)
    )
    (set! actualbrush (testIfresiZed brushnameIn))
    ;(set! actualbrush brushnameIn)
    (gimp-context-set-brush actualbrush)
    (let*
    (
    (brushnameOut (string-append actualbrush brushnameResi))
    (spacing (car (gimp-brush-get-spacing actualbrush)))
    (brushDimens (gimp-brush-get-info actualbrush))
    (brushWidth (car brushDimens))
    (brushHeight (cadr brushDimens))
    (resiZedWidth (* brushWidth resFactor))
    (resiZedHeight(* brushHeight resFactor))
    (centerX (/ brushWidth 2))
    (centerY (/ brushHeight 2))
    (centerXpluseins(+ centerX 1))
    (centerYpluseins(+ centerY 1))
    (angle (* angSel (/ 3.14159 180)))
    )

    (and (> resiZedWidth 1)(> resiZedHeight 1)
    (begin
    (set! arrayToPaint (cons-array 4 'double))
    (aset arrayToPaint 0 centerX)
    (aset arrayToPaint 1 centerY)
    (aset arrayToPaint 2 centerXpluseins)
    (aset arrayToPaint 3 centerYpluseins)
    (set! image (car (gimp-image-new brushWidth brushHeight RGB)))
    (set! layer (car (gimp-layer-new image brushWidth brushHeight 1 "layer 1" 100 0)))
    (gimp-image-undo-disable image)
    (gimp-image-add-layer image layer 0)
    (gimp-drawable-fill layer 3)
    (if (= bgray? TRUE)
    (begin
    (set! scolor (car (gimp-context-get-foreground)))
    (set! bcolor (car (gimp-context-get-background)))
    (gimp-context-set-foreground '(0 0 0))
    (gimp-context-set-background '(255 255 255))
    (gimp-paintbrush-default layer 4 arrayToPaint)
    (gimp-image-scale image resiZedWidth resiZedHeight)
    (if (not (= angle 0))
    (begin
    (gimp-drawable-transform-rotate-default layer angle 1 0 0 1 0)
    (gimp-image-resize-to-layers image)
    )
    )
    (cond
    ((= mirror 1)
    (gimp-image-flip image ORIENTATION-HORIZONTAL))
    ((= mirror 2)
    (gimp-image-flip image ORIENTATION-VERTICAL))
    )
    (gimp-image-convert-grayscale image)
    (set! layer (car (gimp-image-flatten image)))
    (gimp-context-set-foreground scolor)
    (gimp-context-set-background bcolor)
    )
    (begin
    (gimp-paintbrush-default layer 4 arrayToPaint)
    (gimp-image-scale image resiZedWidth resiZedHeight)
    (if (not (= angle 0))
    (begin
    (gimp-drawable-transform-rotate-default layer angle 1 0 0 1 0)
    (gimp-image-resize-to-layers image)
    )
    )
    (cond
    ((= mirror 1)
    (gimp-image-flip image ORIENTATION-HORIZONTAL))
    ((= mirror 2)
    (gimp-image-flip image ORIENTATION-VERTICAL))
    )
    )
    )
    (file-gbr-save 1 image layer filesave filesave spacing brushnameOut)
    (gimp-image-undo-enable image)
    (gimp-image-delete image)
    (gimp-brushes-refresh)
    (gimp-context-set-brush brushnameOut)))
    )
    )
    )
    ;
    (script-fu-register "script-fu-resize-brush"
    _"_Resize Rotate Brush"
    "Resize Rotate a brush, Base on resizebrush.scm by Michael Hoelzen"
    "James Huang"
    "James Huang"
    "2008"
    ""
    SF-IMAGE "Image" 0
    SF-DRAWABLE "Drawable" 0
    SF-ADJUSTMENT _"Scale Factor" '(1.0 0.1 3.0 0.1 1 1 0)
    SF-ADJUSTMENT _"Rotate Degrees" '(0 -180 180 1 10 0 0)
    SF-OPTION _"Transform" '("None" "Mirror" "Invert")
    SF-TOGGLE "Grayscale" TRUE
    ;SF-ADJUSTMENT _"resFactor" '(1.0 0.1 3.0 0.1 1 1 0)
    ;SF-ADJUSTMENT _"Angle" '(0 0 359 1 10 0 0)
    ;SF-TOGGLE "Grayscale" TRUE
    )
    (script-fu-menu-register "script-fu-resize-brush"
    _"<Image>/Script-Fu/BrushUtil")

Share This Page