当前位置: 首页>>代码示例>>Python>>正文


Python PNMImage.setPixel方法代码示例

本文整理汇总了Python中pandac.PandaModules.PNMImage.setPixel方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.setPixel方法的具体用法?Python PNMImage.setPixel怎么用?Python PNMImage.setPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandac.PandaModules.PNMImage的用法示例。


在下文中一共展示了PNMImage.setPixel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_heightmap_tex

# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import setPixel [as 别名]
    def get_heightmap_tex(self, size, filename = None):
        """Generate texture of map
        """
        mod = self.world_size / size
        image = PNMImage(size, size)
        for x in xrange(size):
            for y in xrange(size):
                px = x * mod
                py = y * mod
                height = self[px, py]
                color = height / 50
                r = 0
                g = 0
                b = 0
                if color > 255:
                    color = 255
                if color < 0:
                    color = abs(color)
                    b = color
                else:
                    g = color
                image.setPixel(x, y, (r, g, b))

        if filename != None:
            image.write(filename)

        #for x in xrange(-1, 2):
            #for y in xrange(-1, 2):
               #image.setPixel(int(world.chunks_map.charX)+x, int(world.chunks_map.charY)+y, (255, 0, 0))

        texture = Texture()
        texture.load(image)
        return texture
开发者ID:viatoriche,项目名称:suber,代码行数:35,代码来源:map3d.py

示例2: get_map_2d_tex

# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import setPixel [as 别名]
 def get_map_2d_tex(self, map2d, factor = 1):
     """Generate texture for map2d, factor - for size [size / factor]
     """
     size = map2d.size / factor
     image = PNMImage(size, size)
     for x in xrange(size):
         for y in xrange(size):
             px = x * factor
             py = y * factor
             if map2d[(px, py)] <= map2d.water_z:
                 image.setPixel(x, y, (0, 0, 100))
             else:
                 image.setPixel(x, y, (0, 100, 0))
     texture = Texture()
     texture.load(image)
     return texture
开发者ID:viatoriche,项目名称:suber,代码行数:18,代码来源:textures.py

示例3: generate_map_texture

# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import setPixel [as 别名]
def generate_map_texture(map_tree, factor):
    map_world = map_tree.map3d
    size = map_world.size / factor
    image = PNMImage(size, size)
    #image.fill(0,0,0)
    for x in xrange(size):
        for y in xrange(size):
            px = x * factor
            py = y * factor
            if map_world[(px, py)] <= map_world.water_z:
                image.setPixel(x, y, (0, 0, 100))
            else:
                image.setPixel(x, y, (0, 100, 0))
    char_x, char_y, char_z = map_tree.coords
    char_x = char_x / factor
    char_y = char_y / factor
    image.setPixel(char_x, char_y, (255, 0, 0))
    #if factor>2:
        #image.setPixel(char_x, char_y, (255, 0, 0))
    #else:
        #for x in xrange(char_x - 1, char_x+2):
            #cx = x
            #if cx > size-1: cx = size-1
            #if cx < 0: cx = 0
            #for y in xrange(char_y - 1, char_y+2):
                #cy = y
                #if cy > size-1: cy = size-1
                #if cy < 0: cy = 0
                #image.setPixel(cx, cy, (255, 0, 0))
    texture = Texture()
    texture.load(image)
    return texture
开发者ID:viatoriche,项目名称:suber,代码行数:34,代码来源:world.py

示例4: get_map_3d_tex

# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import setPixel [as 别名]
    def get_map_3d_tex(self, size, filename = None, charPos = None):
        """Generate texture of map
        """
        mod = self.world_size / size
        image = PNMImage(size, size)
        for x in xrange(size):
            for y in xrange(size):
                px = x * mod
                py = y * mod
                height = self[px, py]
                if height <= 0:
                    color = (abs(height) / 50) + 50
                    if color > 255:
                        color = 255
                    image.setPixel(x, y, (0, 0, 255-color))
                else:
                    if height <= self.config.low_mount_level[1]:
                        color = height / 20
                        r = 0
                        g = 50+color
                        b = 0
                        image.setPixel(x, y, (r, g, b))
                    elif height > self.config.low_mount_level[1]:
                        color = height / 50
                        r = color
                        g = color
                        b = color
                        if r > 255:
                            r = 255
                        if g > 255:
                            r = 255
                        if b > 255:
                            b = 255
                        image.setPixel(x, y, (r, g, b))

        if filename != None:
            image.write(filename)

        if charPos != None:
            charX, charY = charPos
            for x in xrange(-1, 2):
                for y in xrange(-1, 2):
                   image.setPixel(int(charX/mod)+x, int(charY/mod)+y, (255, 0, 0))

        texture = Texture()
        texture.load(image)
        return texture
开发者ID:viatoriche,项目名称:suber,代码行数:49,代码来源:map3d.py


注:本文中的pandac.PandaModules.PNMImage.setPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。