本文整理匯總了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)