本文整理汇总了Python中pandac.PandaModules.PNMImage.setGreen方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.setGreen方法的具体用法?Python PNMImage.setGreen怎么用?Python PNMImage.setGreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.PNMImage
的用法示例。
在下文中一共展示了PNMImage.setGreen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grassTexture
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import setGreen [as 别名]
def grassTexture(imgSize=(256,256)):
"""Return a green, 'grassy' texture (PNMImage) of the given image size,
produced using 2D Perlin noise."""
# Initialuse the PNMImage object
img = PNMImage(*imgSize)
# Initalise 4 PerlinNoise2 objects to produce noise at different scales
noise1 = PerlinNoise2()
noise1.setScale(2.0)
noise2 = PerlinNoise2()
noise2.setScale(5.0)
noise3 = PerlinNoise2()
noise3.setScale(0.25)
noise4 = PerlinNoise2()
noise4.setScale(0.125)
# For each pixel in the image, set the red and blue values of the pixel to
# constant values, and set the green value of the pixel using all 4
# PerlinNoise2 objects.
red = 0.125 # Colour values in PNMImage are doubles in the range [0.0,1.0]
blue = 0.0625
for x in xrange(imgSize[0]):
for y in xrange(imgSize[1]):
img.setRed(x,y,red)
img.setBlue(x,y,blue)
pos = Vec2(1.0/32*x, 1.0/32*y)
img.setGreen(x,y,(0.5 + noise1(pos)*0.0625 + noise2(pos)*0.0625 +
noise3(pos)*0.125 + noise4(pos)*0.0625))
return img
示例2: greenNoise
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import setGreen [as 别名]
def greenNoise(imgSize=(32,32),scale=0.25):
"""Return a PNMImage of the given size containing Perlin noise at the given
scale in the green colour values of the image pixels."""
# Initialuse the PNMImage object
img = PNMImage(*imgSize)
# Initalise PerlinNoise2 object
noise = PerlinNoise2()
noise.setScale(scale)
# Fill in the pixels of img, setting the red and blue values of each pixel
# to 0 and the green value to Perlin noise.
for x in xrange(imgSize[0]):
for y in xrange(imgSize[1]):
img.setRed(x,y,0)
img.setBlue(x,y,0)
pos = Vec2(1.0/32*x, 1.0/32*y)
img.setGreen(x,y,(noise(pos)+1.0)/2.0)
return img