;; -*-scheme-*- ;; Copyright, Alan Horkan 2004. (define (script-fu-invert-tachyon image drawable) (gimp-image-undo-group-start image) ;; what you see is not always what you get ;; if the canvas has been resized the drawable can be offscreen ;; making selection gets only onscreen parts of the drawable (if (= (car (gimp-selection-is-empty image)) TRUE) (gimp-selection-all image) ) ;; it is easier to copy, paste and promote than to create a new layer ;; and need to mess about trying to position it. ;; copy the original layer or selection (gimp-edit-copy drawable) ;; set this as layer one, even if it is not a proper layer yet (set! layer-1 (car (gimp-edit-paste drawable FALSE))) (gimp-floating-sel-to-layer layer-1) ;; but it is now ;; dont want a layer called "Pasted Layer", so change it ;(gimp-drawable-set-name layer-1 _"Greyscale Inverse") ;; copy layer (set! layer-2 (car (gimp-layer-copy layer-1 TRUE))) (gimp-image-add-layer image layer-2 -1) ;; good to have layer names, but unnecessary for the final result ;(gimp-drawable-set-name layer-2 _"Colour Mode") ;; convert to grayscale/black and white/desaturate ; (gimp-desaturate layer-1) ;; turns out this isn't even necessary, the invert is what is important ;; invert the grayscale/desaturated layer (gimp-invert layer-1) ;; add the colours back, colour mode (13) (gimp-layer-set-mode layer-2 13) ;; colour mode change is done last so that it will feel faster because of ;; seeing the final result all at once. with any luck it is more effecient too. ;; merge the layers temporary layers together into the final layer (set! layer-3 (car (gimp-image-merge-down image layer-2 0))) ;; give the resulting layer a name (gimp-drawable-set-name layer-3 _"Tachyon Effect") ;; one could merge again and be left with just the one layer but ;; better to keep the layer for future modifications and adjustment (gimp-image-undo-group-end image) (gimp-displays-flush) ) ;; alternative location. put in same place as the other invert ;(set! menu-path _"/Layer/Colors/") ;(set! menu-path _"/Filters/") ;(set! menu-path _"/Filters/Colours/") ;; incomplete localisation forces me to use American English. (set! menu-path _"/Filters/Colors/") ;; alternative names: Tachyon, Invert Brightness, Luma Negative. ;(set! item-name _"Tachyon") (set! item-name _"Invert Light") (set! authors "Alan Horkan. ") (set! rights "Alan Horkan, 2004. ") (set! date "2004 04 02 UTC") (script-fu-register "script-fu-invert-tachyon" ;; (string-append menu-path item-name) _"/Filters/Colors/" ;; help description _"Invert the colours without changing the Light and dark. If you Invert the picture again using the standard Invert 'Layers, Colours, Invert' the resulting image has normal light but inverted colours. Blue people! Inspired by the Tachyon plug-in from Flaming Pear. http://flamingpear.com " "Alan Horkan" rights date "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 ) ;; DONE just about everything ;; DONE write-up a detailed descriptive help section ;; TODO: see about making it adjustable, perhaps by using this ;; (gimp-hue-saturation drawable hue_range hue_offset lightness saturation) ;; ideally though an adjustable version would need a preview ;; WONTFIX: Support all image types ;; could support all image types, but would have to convert indexed images to rgb ;; because desaturate does not work on indexed images. running this on a grayscale ;; image is pointless, same effect as a standard invert only slower. ;; HISTORY and Implementation Notes ;; ;; desaturate, invert, and colour mode could be done in any order but ;; following this order means you only see the final effect all at once ;; and hopefully that means less time wasted updating display at each stage ;; Even if it does not make a technical difference i think the snappy change ;; does at least make a differnce in perception and make it feel faster. ;; ;; http://www.flamingpear.com Flaming Pear, Freebies: Tachyon. ;; Tachyon ("Tak-ee-on," a faster-than-light particle) inverts the the bright and dark areas of your picture, but does not change the hues. ;; Ordinary inversion would change blue to yellow, for example ;; ;; PhotoWiz PhotoFreebies http://www.thepluginsite.com ;; - Luma Negative: Turns the image into a negative without changing the colors. ;; Luma Negative (at 100%) is equivalent to Tachyon ;; Luma Negative allows a gradual change, a blend from 0,255.