本文整理汇总了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
示例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
示例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])