本文整理汇总了Python中texture.Texture类的典型用法代码示例。如果您正苦于以下问题:Python Texture类的具体用法?Python Texture怎么用?Python Texture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Texture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: SimpleScreen
class SimpleScreen(Screen):
"""A screen with a single textured quad displaying a background image"""
def __init__(self, ui, textureFile):
super(SimpleScreen, self).__init__(ui)
self._texture = Texture(textureFile)
def draw(self):
"""Draw the menu background"""
# Clear the screen
glClearColor(0, 0, 0, 1)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glEnable(GL_TEXTURE_2D)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
self._texture.bind()
glBegin(GL_QUADS)
if True:
glColor4f(1, 1, 1, 1)
glTexCoord2f(0.0, 0.0); glVertex2f(-8.0, -6.0)
glTexCoord2f(1.0, 0.0); glVertex2f( 8.0, -6.0)
glTexCoord2f(1.0, 1.0); glVertex2f( 8.0, 6.0)
glTexCoord2f(0.0, 1.0); glVertex2f(-8.0, 6.0)
glEnd()
开发者ID:aarmea,项目名称:mumei,代码行数:27,代码来源:screen.py
示例2: test_resize
def test_resize(self):
data = np.zeros((10, 10), dtype=np.uint8)
T = Texture(data=data)
T.resize((5, 5))
assert T.shape == (5, 5)
assert T._data.shape == (5, 5)
assert T._need_resize == True
assert T._need_update == False
assert len(T._pending_data) == 0
开发者ID:tatak,项目名称:experimental,代码行数:9,代码来源:test_texture.py
示例3: simple_patches_synthesizer
def simple_patches_synthesizer(args):
print "Using Simple Patches Synthesizer"
default_texture = Texture()
default_texture.load_texture(args.input_file)
patches = default_texture.create_patches(args.patch_height,
args.patch_width)
new_texture = Texture.create_simple_tex_from_patches(patches,
args.height,
args.width)
new_texture.save_texture(args.output_file)
return
开发者ID:azgo14,项目名称:CS283,代码行数:11,代码来源:texture_synthesizer.py
示例4: __init__
class Menu_log:
#-------------------------------------------------------------------------------------------------------
def __init__( self ):
self.text = Text( "menu/KGHAPPY.ttf", 27, 255 )
self.texture = Texture( "menu/exit.png", 255 )
self.type = 0
#-------------------------------------------------------------------------------------------------------
def load( self, width, height ):
self.texture.setX( width/2 - self.texture.getWidth()/2 )
self.texture.setY( height/2 - self.texture.getHeight()/2 )
self.texture.setColor( 30, 0, 255 )
self.text.createText( "m-menu b-back", [ 0xFF, 0xFF, 0xFF ] )
self.text.setX( width/2 - self.text.getWidth()/2 )
self.text.setY( height/2 - self.text.getHeight()/2 )
#-------------------------------------------------------------------------------------------------------
def draw( self, window ):
if self.type == 1:
self.texture.draw( window )
self.text.draw( window )
#-------------------------------------------------------------------------------------------------------
def getState( self ):
return self.type
#-------------------------------------------------------------------------------------------------------
def setState( self, t ):
self.type = t
#-------------------------------------------------------------------------------------------------------
def handle( self, event ):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_m:
if self.type == 0:
self.type = 1
elif self.type == 1:
self.type = 2
elif event.key == pygame.K_b:
if self.type == 1:
self.type = 0
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:53,代码来源:menu_log.py
示例5: mincut_overlap_patches_synthesizer
def mincut_overlap_patches_synthesizer(args):
print "Using Mincut Overlap Patches Synthesizer"
default_texture = Texture()
default_texture.load_texture(args.input_file)
patches = default_texture.create_patches(args.patch_height,
args.patch_width,
overlap=args.overlap_percent)
new_texture = Texture.create_mincut_tex_from_patches(patches,
args.height,
args.width)
new_texture.save_texture(args.output_file)
return
开发者ID:azgo14,项目名称:CS283,代码行数:12,代码来源:texture_synthesizer.py
示例6: __init__
def __init__(self, font_file):
self._glyphs = {}
self._kern = {}
self._page = {}
if "." not in font_file:
font_file = font_file+".zip"
with zipfile.ZipFile(font_file,'r') as z:
if font_file.lower().endswith(".zip"):
font_file = os.path.basename(font_file)[:-4]
xml = z.read(font_file+".fnt")
xroot = ET.fromstring(xml)
# misc info
com = xroot.find('common')
self._line_height = int(com.get("lineHeight"))
self._base = int(com.get("base"))
self._imgw = int(com.get("scaleW"))
self._imgh = int(com.get("scaleH"))
# load the textures
for page in xroot.find('pages').findall("page"):
id = int(page.get("id"))
img_filename = page.get("file")
img = z.read(img_filename)
surf = pygame.image.load(StringIO.StringIO(img),img_filename)
tex = Texture()
tex.setFromSurface(surf)
self._page[id] = tex
assert(id == 0) # for now, we only support single-page fonts
# load the glyph data
for char in xroot.find("chars").findall("char"):
d = {}
for f in self.Glyph._fields:
d[f] = int(char.get(f))
g=self.Glyph(**d)
self._glyphs[g.id] = g
# load the kerning data
for kern in xroot.find("kernings").findall("kerning"):
t = (int(kern.get("first")), int(kern.get("second")))
self._kern[t] = int(kern.get("amount"))
self._material = Material()
self._material.setTexture(0,self._page[0])
开发者ID:Gato-X,项目名称:sPyGlass,代码行数:52,代码来源:text.py
示例7: PointCloud
class PointCloud(GLArray):
def __init__(self, vertex_data=None, color_data=None):
GLArray.__init__(self, vertex_data, color_data)
self._sprite_texture = None
def sprite(self, filename):
print " -- initializing point sprite {}".format(filename)
self._sprite_texture = Texture(filename)
def _pre_draw(self):
GLArray._pre_draw(self)
if self._sprite_texture == None:
return
glDepthMask(GL_FALSE)
glEnable(GL_POINT_SMOOTH)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE)
self._sprite_texture.bind()
glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)
glEnable(GL_POINT_SPRITE)
glPointSize(15.0)
def _post_draw(self):
GLArray._post_draw(self)
if self._sprite_texture == None:
return
self._sprite_texture.unbind()
glDisable(GL_BLEND)
glDisable(GL_POINT_SPRITE)
def center(self):
try:
return self._center
except:
self._center = [0.0, 0.0, 0.0]
for i in range(3):
self._center[i] = sum(v[i] for v in self._vertex_data) / len(self._vertex_data)
return self._center
开发者ID:chebee7i,项目名称:vroom,代码行数:48,代码来源:point_cloud.py
示例8: __init__
def __init__( self ):
self.core = Core( 60, 1024, 768, "Ninja" )
self.intro = Intro()
self.menu_background = Texture( "menu/background.png" )
self.menu_title = Menu_title()
self.menu_play_button = Menu_play_button()
self.menu_git_button = Menu_link_button( "menu/git.png", "https://github.com/Adriqun" )
self.menu_google_button = Menu_link_button( "menu/google.png", "https://en.wikipedia.org/wiki/Ninja" )
self.menu_facebook_button = Menu_link_button( "menu/facebook.png", "nothing", True )
self.menu_twitter_button = Menu_link_button( "menu/twitter.png", "nothing", True )
self.menu_music_button = Menu_music_button( "menu/music.png" )
self.menu_chunk_button = Menu_music_button( "menu/chunk.png", 1 )
self.menu_exit_log = Menu_exit_log()
self.menu_author_log = Menu_author_log()
self.menu_game_log = Menu_link_button( "menu/game.png", "nothing", True )
self.menu_settings_log = Menu_link_button( "menu/settings.png", "nothing", True )
self.menu_score_log = Menu_score_log()
self.menu_music = Menu_music( "menu/Rayman Legends OST - Moving Ground.mp3" )
self.wall = Wall()
self.hero = Hero()
self.menu_log = Menu_log()
self.map = Map()
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:26,代码来源:engine.py
示例9: __init__
def __init__(self, name, strategy, radius, latitudes, longitudes, rotation_speed, central_body, mass,
textureimage, longitude_of_the_ascending_node, argument_of_the_perihelion, inclination_to_ecliptic,
periapsis=0., apoapsis=0., angle=1.0):
"""
Sets all the necessary attributes.
"""
self.original_radius = radius
self.name = name
self.strategy = strategy
self.position = BetterVector(periapsis, 0, 0)
self.radius = radius
self.latitudes = latitudes
self.longitudes = longitudes
self.rotation_speed = rotation_speed / 365 / 24 / 60 / 60
self.central_body = central_body
self.rotation = 0
self.mass = mass
self.textureimage = textureimage
self.angle = angle
self.periapsis = periapsis
self.apoapsis = apoapsis
self.texture = Texture(self.textureimage)
self.sphere = gluNewQuadric()
self.calc_speed()
self.longitude_of_the_ascending_node = longitude_of_the_ascending_node
self.argument_of_the_perihelion = argument_of_the_perihelion
self.inclination_to_ecliptic = inclination_to_ecliptic
self.is_real = False
self.time = 0
self.showTexture = True
self.speed = 0
gluQuadricNormals(self.sphere, GLU_SMOOTH)
gluQuadricTexture(self.sphere, GL_TRUE)
开发者ID:sgeyer-tgm,项目名称:SolarSystem,代码行数:34,代码来源:models.py
示例10: __init__
def __init__( self ):
self.sprite = Sprite( "menu/position.png", 4 )
self.window = Texture( "menu/window.png" )
self.click = pygame.mixer.Sound( "menu/click.wav" )
self.on = 0
self.type = 0
self.text = Text( "menu/KGHAPPY.ttf", 30 )
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:9,代码来源:menu_score_log.py
示例11: get
def get(self, image):
if isinstance(image, Texture):
return image
if image in self.cache:
return self.cache[image]
else:
self.cache[image] =texture= Texture.empty(image.width, image.height)
texture.upload(image.data)
return texture
开发者ID:cheery,项目名称:essence,代码行数:9,代码来源:texturecache.py
示例12: __init__
def __init__(self, map_lvl, canvas, x, y):
super().__init__()
self.map_level = map_lvl
self.texture = Texture(canvas, x, y)
self.img = self.skeleton_img
self.canvas = canvas
self.position = {'x': x, 'y': y}
self.hp = 2 * self.map_level * self.dice()
self.dp = self.map_level/2 * self.dice()
self.sp = self.map_level * self.dice()
开发者ID:greenfox-velox,项目名称:szepnapot,代码行数:11,代码来源:skeleton.py
示例13: __init__
def __init__( self, path, on = 0 ):
self.sprite = Sprite( path, 4 )
self.scratch = Texture( "menu/scratch.png" )
self.click = pygame.mixer.Sound( "menu/click.wav" )
self.type = 0
self.state = 0
self.on = on
self.mouseup = 0
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:11,代码来源:menu_music_button.py
示例14: Skeleton
class Skeleton(Character):
def __init__(self, map_lvl, canvas, x, y):
super().__init__()
self.map_level = map_lvl
self.texture = Texture(canvas, x, y)
self.img = self.skeleton_img
self.canvas = canvas
self.position = {'x': x, 'y': y}
self.hp = 2 * self.map_level * self.dice()
self.dp = self.map_level/2 * self.dice()
self.sp = self.map_level * self.dice()
def draw(self):
self.texture.draw_img(self.img)
def __str__(self):
return "(SKELETON) HP: {} | DP: {} | SP: {}".format(self.hp,
self.dp, self.sp)
开发者ID:greenfox-velox,项目名称:szepnapot,代码行数:20,代码来源:skeleton.py
示例15: draw_scanline
def draw_scanline(self, va: Vertex, vb: Vertex, y: int, texture: Texture):
x1 = int(va.position.x)
x2 = int(vb.position.x)
sign = 1 if x2 > x1 else -1
factor = 0
for x in range(x1, x2 + sign * 1, sign):
if x1 != x2:
factor = (x - x1) / (x2 - x1)
# color = interpolate(v1.color, v2.color, factor)
v = interpolate(va, vb, factor)
color = texture.sample(v.u, v.v)
self.draw_point(Vector(x, y), color)
开发者ID:happlebao,项目名称:rendererpy,代码行数:12,代码来源:canvas.py
示例16: toCompiled
def toCompiled(self, shader=None):
if shader is None:
shader = self.getShader()
assert(shader)
code = ""
# items made up of 3 floats
for what in ("diffuse_color","specular_color","ambient_color"):
loc = shader.getUniformPos(what)
if loc!=-1:
code += "\tglUniform3fv(%s, 1, mat._%s)\n"%(loc,what)
# items made up of 1 float
for what in ("specular_exp","alpha"):
loc = shader.getUniformPos(what)
if loc!=-1:
code += "\tglUniform1f(%s, mat._%s)\n"%(loc,what)
# textures
for i in xrange(3):
loc = shader.getUniformPos("texture%s"%i)
if loc!=-1:
try: # see if the texture is already loaded
self._texture[i].id()
except:
if self._texture[i] is None:
self._texture[i] = Texture.getNullTexture()
else:
self._texture[i] = R.loadTexture(self._texture[i])
code += "\tmat._texture[%s].bind(%s,%s)\n"%(i,i,loc)
if not code:
code = "def binder(): pass"
else:
code = "def binder():\n"+code
c = compile(code, "<compiled material>", "exec")
ns = dict(mat = self, glUniform3fv=glUniform3fv, glUniform1f=glUniform1f)
exec c in ns
return ns['binder']
开发者ID:Gato-X,项目名称:sPyGlass,代码行数:48,代码来源:materials.py
示例17: __init__
def __init__( self ):
self.counter = 0
self.quit = False
#Textures
self.preview = Text( "intro/Jaapokki-Regular.otf", 37 )
self.shuriken = Texture( "intro/shuriken.png" )
self.title = Text( "intro/Jaapokki-Regular.otf", 37 )
self.author = Text( "intro/Jaapokki-Regular.otf", 37 )
self.produced = Text( "intro/Jaapokki-Regular.otf", 37 )
self.text_one = Text( "intro/Jaapokki-Regular.otf", 37 )
self.text_two = Text( "intro/Jaapokki-Regular.otf", 37 )
self.text_three = Text( "intro/Jaapokki-Regular.otf", 37 )
self.text_four = Text( "intro/Jaapokki-Regular.otf", 37 )
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:16,代码来源:intro.py
示例18: __init__
def __init__(self, screen_size: tuple, screen_pos: tuple=(0, 0),
game_mode: bool=False, title: str='Default Title', **params):
width, height = screen_size
self.screen_size = screen_size
self.screen_pos = screen_pos
self.width = width
self.height = height
self.z_near = 1.0
self.z_far = 100.0
self.fov = 60.0
self.game_mode = game_mode
self.title = title
self._vbo = None
self._vao = None
self._ibo = None
self._program = None
self._texture = None
self._vertices = None
self._indexes = None
self._camera = None
self._pipeline = None
self._scale = 0.0
self._dir_light_color = 1.0, 1.0, 1.0
self._dir_light_ambient_intensity = 0.5
self._projection = ProjParams(
self.width, self.height, self.z_near, self.z_far, self.fov)
self._log = params.get("log", print)
self._clear_color = params.get("clearcolor", (0, 0, 0, 0))
self._vertex_attributes = {"Position": -1, "TexCoord": -1}
self._init_glut()
self._init_gl()
self._create_vertex_buffer()
self._create_index_buffer()
self._effect = LightingTechnique("shaders/vs.glsl", "shaders/fs_lighting.glsl")
self._effect.init()
self._effect.enable()
self._effect.set_texture_unit(0)
self._texture = Texture(GL_TEXTURE_2D, "resources/test.png")
if not self._texture.load():
raise ValueError("cannot load texture")
开发者ID:devforfu,项目名称:pyogldev,代码行数:45,代码来源:glutwindow.py
示例19: test_set_misplaced_data
def test_set_misplaced_data(self):
data = np.zeros((10, 10), dtype=np.uint8)
T = Texture(data=data)
with self.assertRaises(ValueError):
T.set_data(np.ones((5, 5)), offset=(8, 8))
开发者ID:tatak,项目名称:experimental,代码行数:5,代码来源:test_texture.py
示例20: generateVideoButton
def generateVideoButton(self):
# for i in range(len(self.shapes)):
# print " "
# print self.shapes[i].name
# for j in range(len(self.shapes[i].faces)):
# print self.shapes[i].faces[j].faceOrientation, " : ", self.shapes[i].faces[j].facePoints
mb = ModelBuilder()
Models = []
for i in self.shapes:
each_model = mb.BuildModel(i)
# Print out the 3D model's vertex and texel coordinate
# print "Print out the 3D model's vertex and texel coordinate---------------------------"
# for j in each_model:
# # j is one polygon
# print "Vertex is:"
# for k in j.Vertex:
# print k.x, k.y, k.z
# print "Texel is:"
# for n in j.Texel:
# print n.u, n.v
Models.append(each_model)
print "Models list size: ", len(Models)
img = cv2.imread("project.png",cv2.CV_LOAD_IMAGE_COLOR)
texture = Texture(img)
points = []
for i in range(0,len(Models),1):
pointsOfEachModel = []
if (i<5): # for single model building 4,11,12,13 and ground
fileIndex = i
for j in range(len(Models[i])): # j is surfaces of each model
pointsOfEachFace = texture.putTexture(Models[i][j])
pointsOfEachModel.extend(pointsOfEachFace)
elif i==5: #5-6 compound building 10
fileIndex = 5
for j in range(5, 7):
for k in range(len(Models[j])):
pointsOfEachFace = texture.putTexture(Models[j][k])
pointsOfEachModel.extend(pointsOfEachFace)
elif i==7: #7-12 compound building 9
fileIndex = 6
for j in range(7, 13):
for k in range(len(Models[j])):
pointsOfEachFace = texture.putTexture(Models[j][k])
pointsOfEachModel.extend(pointsOfEachFace)
elif (i-13)>=0 and (i-13)%2==0: #compound buildings 1-8
multiple = (i-13)/2
fileIndex = 7 + multiple
for j in range(i, i+2):
for k in range(len(Models[j])):
pointsOfEachFace = texture.putTexture(Models[j][k])
pointsOfEachModel.extend(pointsOfEachFace)
else:
continue
points = pointsOfEachModel
fileRGB = open("Models/model_"+str(fileIndex)+".dat", "w+")
for k in range(len(pointsOfEachModel)):
point = "{0},{1},{2},{r},{g},{b}\n".format(points[k].x, points[k].y,points[k].z,r=points[k].r, g=points[k].g, b=points[k].b)
fileRGB.write(point)
print "Model "+str(fileIndex)+":"+str(k)+" points generated"
print "----------UI Phase Finished----------"
print "All models have been generated, please use main.py to generate fraems of video"
开发者ID:WuPei,项目名称:cv_reconstructor,代码行数:70,代码来源:ui.py
注:本文中的texture.Texture类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论