本文整理汇总了Python中Window.pixels方法的典型用法代码示例。如果您正苦于以下问题:Python Window.pixels方法的具体用法?Python Window.pixels怎么用?Python Window.pixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window.pixels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pmOpenImage
# 需要导入模块: import Window [as 别名]
# 或者: from Window import pixels [as 别名]
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: getImageHeight
# 需要导入模块: import Window [as 别名]
# 或者: from Window import pixels [as 别名]
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)