當前位置: 首頁>>代碼示例>>Python>>正文


Python Window.setColor方法代碼示例

本文整理匯總了Python中Window.setColor方法的典型用法代碼示例。如果您正苦於以下問題:Python Window.setColor方法的具體用法?Python Window.setColor怎麽用?Python Window.setColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Window的用法示例。


在下文中一共展示了Window.setColor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Vec2

# 需要導入模塊: import Window [as 別名]
# 或者: from Window import setColor [as 別名]

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

def inMandelbrotSet(c):
    z = 0
    h = 0
    for h in xrange(0, 100):
        z = z**2 + c
        if abs(z) > 2:
            break;
    if abs(z) >= 2:
        return -1
    else:
        return h

for x in range (0, size.x):
    real = x / 200.0 - 1.5
    for y in range(0, size.y):
        img = y / 200.0 -1.5
        c = complex(real, img)

        n = inMandelbrotSet(c)
        if n!= -1:
            #print n/100.0
            canvas.setColor(Vec2(x,y), Color.getHSBColor(n/100.0,1,0.5))
canvas.refresh()
print "done"

開發者ID:TyOverby,項目名稱:PixelMath-Shim,代碼行數:30,代碼來源:mandelbrot.py

示例2: Vec2

# 需要導入模塊: import Window [as 別名]
# 或者: from Window import setColor [as 別名]
Window.init(PixelMathBridge())

size = Vec2(100,100)
canvas = Window(size)
pmOpenImage(canvas.id,"archery.jpg")


def neighboring(position):
    yield position.plus(Vec2(-1,-1))
    yield position.plus(Vec2(-1,0))
    yield position.plus(Vec2(-1,1))
    yield position.plus(Vec2(0,-1))
    #yield position.plus(Vec2(0,0))
    yield position.plus(Vec2(0,1))
    yield position.plus(Vec2(1,-1))
    yield position.plus(Vec2(1,0))
    yield position.plus(Vec2(1,1))

for pos in canvas.positions():
    for neighbor in neighboring(pos):
        if neighbor.y < size.y and neighbor.x < size.x and neighbor.y >0 and neighbor.x >0:
            current = canvas.getColor(pos)
            next    = canvas.getColor(neighbor)
            if current.equals(next):
                canvas.setColor(pos,Color.RED)
                break

canvas.refresh()
print "done"

開發者ID:TyOverby,項目名稱:PixelMath-Shim,代碼行數:31,代碼來源:arch.py

示例3: getImageWidth

# 需要導入模塊: import Window [as 別名]
# 或者: from Window import setColor [as 別名]
    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())

marker = "*"
def sierpinski(n):
    d = [marker]
    for i in xrange(n):
        sp = " " * (2 ** i)
        d = [sp+x+sp for x in d] + [x+" "+x for x in d]
    return d


canvas = Window(Vec2(255,255))
y = 0
x = 0
for line in sierpinski(7):
    y += 1
    for char in line:
        x += 1
        if char in marker:
            canvas.setColor(Vec2(x,y),Color.RED)
    x=0
canvas.refresh()
print "done"
開發者ID:TyOverby,項目名稱:PixelMath-Shim,代碼行數:32,代碼來源:triangle.py


注:本文中的Window.setColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。