示例#1
0
        return pmOpenImage(int(id), filename)
    def newImage(self, id, title, width, height, r, g, b):
        return pmNewImage(id, title, int(width), int(height), int(r), int(g), int(b))

    def getImageWidth(self, id):
        return pmGetImageWidth(int(id))
    def getImageHeight(self, id):
        return pmGetImageHeight(int(id))

    def refresh(self, id):
        return pmUpdateDisplay(int(id))
Window.init(PixelMathBridge())

size = Vec2(500.0,500.0)
canvas = Window(size)

for pixel in canvas.pixels():
    brightness = random.random()
    brightness /= 10
    pixel.setColor(Color((int)(brightness*255),(int)(brightness*255),(int)(brightness*255)))
canvas.refresh()
pmSetPolar()
pmSetFormula("if rho <100 then RGB(0,200,0) else source1(rho, theta)")
pmSetDestination(canvas.id)
pmCompute()



print "done"

示例#2
0
    def getImageHeight(self, id):
        return pmGetImageHeight(int(id))

    def refresh(self, id):
        return pmUpdateDisplay(int(id))
Window.init(PixelMathBridge())

def inBounds(bounds, position):
    return position.x <= bounds.x and position.y <= bounds.y

size = Vec2(500.0,500.0)
middle = size.scaled(0.5)
canvas = Window(size)

others = []
for pixel in canvas.pixels():
    bright = random.randrange(0,255)
    pixel.setColor(Color(bright,bright,bright))
canvas.refresh()

for i in range(2,50,2):
    new = pmNewImage(i, str(i), int(size.x), int(size.y), 255,0,0)
    others.append(new)
    pmSetSource1(canvas.id)
    pmSetDestination(new)
    newRelSize = int(min(size.y,size.x)/i)
    offset = random.randrange(0,min(size.x,size.y)-newRelSize)
    pmSetFormula("s1(x/"+str(i)+"+"+str(offset)+",y/"+str(i)+"+"+str(offset)+")")
    pmCompute()

final = Window(size)