Skip to content

Instantly share code, notes, and snippets.

@Steffo99
Created July 9, 2022 01:17
Show Gist options
  • Save Steffo99/710853f569464ce67fb229096ae24cd8 to your computer and use it in GitHub Desktop.
Save Steffo99/710853f569464ce67fb229096ae24cd8 to your computer and use it in GitHub Desktop.
Rotanimator script for GIMP
; Inspired by the Mura Meister Copies script
; https://gimplearn.net/viewtopic.php?f=4&t=16
(define
(script-fu-steffo-rotanimator
image
layer
num-of-copies
)
(let* (
(width (car (gimp-image-width image)))
(center-x (/ width 2))
(height (car (gimp-image-height image)))
(center-y (/ height 2))
(inc-angle (/ (* 3.141592654 2) num-of-copies))
(copy-count 0)
(rotate-angle 0)
(drawable 0)
)
(gimp-image-undo-group-start image)
(while (< copy-count num-of-copies)
(set! rotate-angle (+ rotate-angle inc-angle))
(set! copy-count (+ copy-count 1))
; Create a new layer
(set! drawable (car (gimp-layer-copy layer TRUE)))
(gimp-image-insert-layer image drawable 0 0)
; Rotate the layer
(set! drawable (car (gimp-item-transform-rotate drawable rotate-angle TRUE center-x center-y)))
; Resize layer to the image size
(gimp-layer-resize-to-image-size drawable)
; Fill the corners with the current foreground color
(gimp-context-set-sample-transparent TRUE)
(gimp-context-set-diagonal-neighbors TRUE)
(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND 0 0)
(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND 2047 0)
(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND 0 2047)
(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND 2047 2047)
;(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND 0 0)
;(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND (- width 1) 0)
;(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND 0 (- height 1))
;(gimp-drawable-edit-bucket-fill drawable FILL-BACKGROUND (- width 1) (- height 1))
)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)
(script-fu-register
"script-fu-steffo-rotanimator"
"<Image>/Filters/Steffo's/Steffo's Rotanimator..."
"Animates the rotation of an image"
"Stefano Pigozzi"
"COPYRIGHT LOLOLO"
"2022"
"RGB*, GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
SF-ADJUSTMENT "Number of Copies" '(3 0 1200 1 50 0 0)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment