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


Python Texture.peek方法代码示例

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


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

示例1: peek_tex_with_clear_color

# 需要导入模块: from panda3d.core import Texture [as 别名]
# 或者: from panda3d.core.Texture import peek [as 别名]
def peek_tex_with_clear_color(component_type, format, clear_color):
    """ Creates a 1-pixel texture with the given settings and clear color,
    then peeks the value at this pixel and returns it. """

    tex = Texture("")
    tex.setup_1d_texture(1, component_type, format)
    tex.set_clear_color(clear_color)
    tex.make_ram_image()

    col = LColor()
    tex.peek().fetch_pixel(col, 0, 0)
    return col
开发者ID:Moteesh,项目名称:panda3d,代码行数:14,代码来源:test_texture.py

示例2: peeker_from_pixel

# 需要导入模块: from panda3d.core import Texture [as 别名]
# 或者: from panda3d.core.Texture import peek [as 别名]
def peeker_from_pixel(component_type, format, data):
    """ Creates a 1-pixel texture with the given settings and pixel data,
    then returns a TexturePeeker as result of calling texture.peek(). """

    tex = Texture("")
    tex.setup_1d_texture(1, component_type, format)
    tex.set_ram_image(data)
    peeker = tex.peek()
    assert peeker.has_pixel(0, 0)
    return peeker
开发者ID:Moteesh,项目名称:panda3d,代码行数:12,代码来源:test_texture_peek.py

示例3: PTAUchar

# 需要导入模块: from panda3d.core import Texture [as 别名]
# 或者: from panda3d.core.Texture import peek [as 别名]
# linearized in reverse order of axes. So as we have an [x, y, c] array here,
# the data will be linearized in the order seen above, monotonically ascending.
# This can be seen if you PTAUchar(a_np).get_subdata(0, 18). First all c-columns
# in x=0 get written in order of y, then all in x=1.
# However, Texture.set_ram_image will delinearize the data slightly different.
# c-column order can be manipulated with an additional argument to
# set_ram_image_as, but x/y-wise, it will first write along the x-axis in y=0,
# then y=1 and so on.
# So to preserve x/y coordinate equality between numpy and Panda3D, the array
# first has to be transposed, swapping its x and y axes. That in turn seems to
# somehow "dirty" the returned array, making it necessary to copy it first.
# So basically you have the choice between one additional copy of the whole
# array that you're transferring, or you think of numpy arrays as [y, x, c]
# images.

a_np_t = a_np.transpose(1, 0, 2).copy()
a_p3d = PTAUchar(a_np_t)

tex = Texture()
# Note that if the Texture's dimentions and component type don't match that of
# your numpy array, you're gonna have a bad time.
tex.setup_2d_texture (2, 3, Texture.T_unsigned_byte, Texture.F_rgb)
tex.set_ram_image_as(a_p3d, 'RGB')

# Now let's see the data that we've just moved around.
p = LVecBase4f()
for x in range(2):
    for y in range(3):
        tex.peek().fetch_pixel(p, x, y); print(x,y,p*256, a_np[x,y])

开发者ID:TheCheapestPixels,项目名称:panda_examples,代码行数:31,代码来源:terse_description.py


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