当前位置: 首页>>代码示例>>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;未经允许,请勿转载。