The Flying Meat Wiki : AcornReflectPlugin

HomePage :: Categories :: PageIndex :: RecentChanges :: Login/Register
Most recent edit on 2007-11-12 10:15:19 by GusMueller

Deletions:
domercaolo



Edited on 2007-11-11 21:29:17 by OloouVarel

Additions:
domercaolo



Edited on 2007-09-11 19:23:10 by GusMueller

Additions:
# trust me, TSGradient is there (it's pretty much CTGradient)
# Yes, I know this isn't documented. I'll have to do that.



Edited on 2007-09-11 19:22:09 by GusMueller

Additions:
This is an example, which will take the current layer, make a new image to draw into (adding reflections and such), and then make a new document out of it.
Here's what it looks like (the original is on the left):
Reflection




Oldest known version of this page was edited on 2007-09-11 19:17:28 by GusMueller []
Page view:

MakeNewImageWithReflection.py
import objc, os, math
from Foundation import *
from AppKit import *

ACScriptSuperMenuTitle = None
ACScriptMenuTitle = "New image with reflection"

def main(image):
    doc          = NSDocumentController.sharedDocumentController().currentDocument()
    data         = doc.dataRepresentationOfType_('public.tiff')
    nsimg        = image.NSImage()
    extent       = image.extent()
    originalSize = extent[1]
    half         = math.floor(originalSize[1] / 2)
    newSize      = (originalSize[0], originalSize[1] + half)
    newImage     = NSImage.alloc().initWithSize_(newSize)
   
    newImage.setFlipped_(True)
    newImage.lockFocus()
   
    NSColor.blueColor().set()
   
    NSBezierPath.bezierPathWithRect_(((0,0), newSize)).fill()
   
    nsimg.drawAtPoint_fromRect_operation_fraction_((0, originalSize[1]), NSZeroRect, NSCompositeCopy, 1.0);
   
    newImage.unlockFocus()
   
    newImage.setFlipped_(False)
   
    newImage.lockFocus()
   
    fade = objc.lookUpClass("TSGradient").gradientWithBeginningColor_endingColor_(NSColor.clearColor(), NSColor.blackColor())
   
    fade.fillRect_angle_(((0, half), (originalSize[0], -half)), 90.0)
   
    nsimg.drawAtPoint_fromRect_operation_fraction_((0, half), NSZeroRect, NSCompositeCopy, 1.0);
   
    newImage.unlockFocus()
   
    NSDocumentController.sharedDocumentController().newDocumentWithImageData_(newImage.TIFFRepresentation())
   
    # we're not changing the image, so we'll return nothing to put on
    return None




Back to AcornPlugins
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.0949 seconds