本文整理汇总了Python中pyglet.font.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_items
def _draw_items( self ):
width, height = director.get_window_size()
fo = font.load( self.font_items, self.font_items_size )
fo_selected = font.load( self.font_items, self.font_items_selected_size )
fo_height = int( (fo.ascent - fo.descent) * 0.9 )
if self.menu_halign == CENTER:
pos_x = width / 2
elif self.menu_halign == RIGHT:
pos_x = width - 2
elif self.menu_halign == LEFT:
pos_x = 2
else:
raise Exception("Invalid halign value for menu")
for idx,item in enumerate( self.items ):
if self.menu_valign == CENTER:
pos_y = height / 2 + (fo_height * len(self.items) )/2 - (idx * fo_height )
elif self.menu_valign == TOP:
pos_y = height - (idx * fo_height )
elif self.menu_valign == BOTTOM:
pos_y = 0 + fo_height * len(self.items) - (idx * fo_height )
item._init_font( pos_x, pos_y, self.font_items, self.font_items_selected_size, self.font_items_size )
示例2: on_enter
def on_enter(self):
super(ControlLayer, self).on_enter()
ft_title = font.load("Arial", 32)
ft_subtitle = font.load("Arial", 18)
ft_help = font.load("Arial", 16)
self.text_title = font.Text(ft_title, "Transition Demos",
x=5,
y=480,
anchor_x=font.Text.LEFT,
anchor_y=font.Text.TOP)
self.text_subtitle = font.Text(ft_subtitle, transition_list[current_transition].__name__,
x=5,
y=400,
anchor_x=font.Text.LEFT,
anchor_y=font.Text.TOP)
self.text_help = font.Text(ft_help, "Press LEFT / RIGHT for prev/next example, "
"ENTER to restart example",
x=320,
y=20,
anchor_x=font.Text.CENTER,
anchor_y=font.Text.CENTER)
示例3: __init__
def __init__(self, handler):
mode.Renderer.__init__(self, handler)
font.add_file('resources/amsterdam.ttf')
self.amsterdam = font.load('Amsterdam Graffiti', 45)
self.amsterdam_detail = font.load('Amsterdam Graffiti', 24)
if(not self.handler.menu_boxes):
self.handler.menu_boxes = []
for i in range(10):
self.handler.menu_boxes.append((50, 700,
575 - i * BAR_HEIGHT, 575 - (i + 1) * BAR_HEIGHT))
示例4: __init__
def __init__(self, win):
helv = font.load('Helvetica', win.width / 15.0)
self.text = font.Text(
helv,
'Hello!',
x=win.width / 2,
y=win.height / 2,
halign=font.Text.CENTER,
valign=font.Text.CENTER,
color=(1, 1, 1, 0.5),
)
h = font.load('Helvetica', 15)
self.help = font.Text(h, 'to exit: type "smash" and press escape', x=10, y=win.height-25, color=(1,1,1,.5))
self.fps = clock.ClockDisplay()
示例5: __init__
def __init__(self, x, y, width, height, font_name='Helvetica', size=10,\
bck_color = (0.9,0.9,0.9,1.0), text_color = (0.0,0.0,0.0,1.0)):
"""
Initialize all the default widget properties like position,
size, background and foreground color, and other generic
properties
"""
#Ortho coords
self._x, self._y = x,y
#Ortho dimensions
self._width, self._height = width, height
#Font loader
self._size = size
self._font = font.load(font_name,size)
#Other properties
self._line_color = bck_color
self._text_color = text_color
self._loaded = False
self._line = Sprite.Sprite(self._x, self._y, self._width,\
self._height, None, self._line_color)
self._text = font.Text(self._font, "", self._x, self._y,\
halign = font.Text.LEFT, \
valign = font.Text.BOTTOM, \
color = self._text_color)
示例6: __init__
def __init__(self, caption="Simulation"):
"""Initialisiert das Fenster."""
# Fenster öffnen
try:
config = Config(sample_buffers=1, samples=1, double_buffer=True)
super(PendulumWindow, self).__init__(config=config,
resizable=True,
caption=caption)
except:
super(PendulumWindow, self).__init__(resizable=True,
caption=caption)
# Schrift laden
self.font_sans = font.load(None, 16)
# FPS
self.fps_display = clock.ClockDisplay()
# Pendel aufhängen
self.single_pendulum = SinglePendulum(length=9.0, phi=pi / 5)
self.double_pendulum = DoublePendulum()
# Einstellungsfenster
self.settings_window = SettingsWindow(self,
pendulum=self.double_pendulum,
position=(15, 15))
self.settings_window.reset()
示例7: ranges
def ranges(self, start, end):
from pyglet import font
for start, end, styles in self.zip_iter.ranges(start, end):
font_name, font_size, bold, italic = styles
ft = font.load(font_name, font_size, bold=bool(bold), italic=bool(italic), dpi=self.dpi)
yield start, end, ft
示例8: __init__
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.keys = window.key.KeyStateHandler()
self.push_handlers(self.keys)
# self.set_exclusive_mouse()
self.width, self.height, self.rat3d, self.ratex = 640, 480, 1.05, 0.5
self.zoom, self.expand, self.mapping, self.blend = 0, 0, 0, 1
self.fgc, self.bgc = (1.0, 1.0, 1.0, 0.9), (0.1, 0.1, 0.1, 0.1)
self.loadfgc, self.loadbgc = (0.4, 0.2, 0.4, 0.3), (0.6, 0.3, 0.6, 0.9)
self.instfgc, self.instbgc = (0.1, 0.1, 0.5, 0.9), (0.5, 0.9, 0.9, 0.8)
self.instbkwidth, self.instbkheight = 480, 400
bmplen = (self.instbkwidth / 8) * self.instbkheight
self.instbkbmp = (ctypes.c_ubyte * bmplen)(*([255] * bmplen))
self.ticktimer, self.tick, self.insttimer, self.inst = 0.5, 0.0, 30, 1
self.printing, self.solver = 1, deque()
self.stat = [None, 0, Queue.Queue(512)] # (key(1-9), direc), count, queue
self.cmax, self.tanim = 18, [6, 3, 1, 3] # frames in rotate moving, speeds
self.tcos, self.tsin = [1.0] * (self.cmax + 1), [0.0] * (self.cmax + 1)
for i in xrange(1, self.cmax):
t = i * math.pi / (2.0 * self.cmax) # 0 < t < pi/2
self.tcos[i], self.tsin[i] = math.cos(t), math.sin(t)
self.tcos[self.cmax], self.tsin[self.cmax] = 0.0, 1.0 # pi/2 regulation
self.InitRot()
self.InitAxis()
self.InitGL(self.width, self.height)
self.textures = [None] * (len(self.ary_norm) * 2 + 1 + len(TEXIMG_CHAR))
self.loading, self.dat = 0, [('', 0, 0)] * len(self.textures)
resource.add_font(FONT_FILE)
self.font = font.load(FONT_FACE, 20)
self.fontcolor = (0.5, 0.8, 0.5, 0.9)
self.fps_display = clock.ClockDisplay(font=self.font, color=self.fontcolor)
self.fps_pos = (-60.0, 30.0, -60.0)
clock.set_fps_limit(60)
clock.schedule_interval(self.update, 1.0 / 60.0)
示例9: __init__
def __init__(self, parent, title="Window", position=None,
constraints=(300, 250)):
"""Creates the window."""
super(Window, self).__init__()
# If no position is given, center the window.
if position is None:
self.x = (parent.width - constraints[0]) / 2
self.y = (parent.height - constraints[1]) / 2
else:
self.x, self.y = position
self.parent = parent
self.title = title
self.width, self.height = constraints
# title bar dragging
self._is_dragging = False
self._drag_x, self._drag_y = (0, 0)
# Load a font for the titlebar.
self._titlebarheight = 15
self.font = font.load(None, self._titlebarheight * 0.9, dpi=72)
# manage widgets as a list
self.widgets = []
parent.push_handlers(self)
示例10: __init__
def __init__(self, *args, **kwargs):
#Let all of the arguments pass through
self.win = window.Window.__init__(self, *args, **kwargs)
self.maxaliens = 50 # max num of aliens simultaneously on the screen
clock.schedule_interval(self.create_alien, 0.5)
clock.schedule_interval(self.update, 1.0/30) # update at FPS of Hz
#clock.set_fps_limit(30)
# setting text objects
ft = font.load('Tahoma', 20) #Create a font for our FPS clock
self.fpstext = font.Text(ft, y=10) # object to display the FPS
self.score = font.Text(ft, x=self.width, y=self.height,
halign=pyglet.font.Text.RIGHT,
valign=pyglet.font.Text.TOP)
# reading and saving images
self.spaceship_image = pyglet.image.load('images/ship3.png')
self.alien_image = pyglet.image.load('images/invader.png')
self.bullet_image = pyglet.image.load('images/bullet_white_16.png')
# create one spaceship
self.spaceship = Spaceship(self.spaceship_image, x=50, y=50)
self.aliens=[] # list of Alien objects
self.bullets=[] # list of Bullet objects
示例11: __init__
def __init__(self, client, points=9, eye=1, wait=1, randomize=1, auto=0, speed=1, level=3):
super(CalibrationLayer, self).__init__(0, 0, 255, 255)
self.client = client
self.points = points
self.eye = eye
self.wait = wait
self.randomize = randomize
self.auto = auto
self.speed = speed
self.level = level
self.on_success = None
self.on_failure = None
self.window = director.window.get_size()
self.screen = director.get_window_size()
self.center_x = self.screen[0] / 2
self.center_y = self.screen[1] / 2
self.win_scale = (self.screen[0] / self.window[0], self.screen[1] / self.window[1])
self.font = font.load("Cut Outs for 3D FX", 32)
self.circle_img = self.font.get_glyphs("E")[0].get_texture(True)
self.circle_img.anchor_x = "center"
self.circle_img.anchor_y = "center"
self.pnt_img = self.font.get_glyphs("Y")[0].get_texture(True)
self.pnt_img.anchor_x = "center"
self.pnt_img.anchor_y = "center"
self.circle = Sprite(self.circle_img, color=(255, 255, 0), scale=1, opacity=0)
self.spinner = Sprite(
resource.image("spinner.png"), position=(self.screen[0] / 2, self.screen[1] / 2), color=(255, 255, 255)
)
示例12: render
def render(self, dt):
self.window.clear()
self.set_projection()
font.add_file('./font/Pure-ThinDuranGo.ttf')
arial = font.load('Roman', 9, dpi=96)
text = 'Hello, world!'
glyphs = arial.get_glyphs(text)
#gs = GlyphString(text, glyphs)
# glyph_string.draw()
#for g in gs:
# g.blit(x, y, z=0, width=None, height=None)
label = pyglet.text.Label('Hello, world a',
#font_name='./font/Pure-ThinDuranGo.ttf',
font_size=14,
x=10, y=10
)
label.draw()
#glBegin(GL_LINES)
#for ob in self.model:
# self.render_ob(*ob)
#glEnd()
self.window.flip()
示例13: __init__
def __init__(self, title, lines):
super(BulletListLayer, self).__init__()
x, y = director.get_window_size()
self.title = text.Label(
title, (x/2, y-50), font_name = 'Gill Sans',
font_size = 64, anchor_x='center', anchor_y='center' )
self.add( self.title )
start_y = (y/12)*8
font_size = 52 / (len(lines)/2.2+1)
font_size = min(font_size, 52)
line_font = font.load('Gill Sans', font_size)
tot_height = 0
max_width = 0
rendered_lines = []
step = 300/ max(len(lines),1)
i = 0
for line in lines:
line_text = text.Label(
line, (x/2, y-150-step*i), font_name = 'Gill Sans',
font_size = font_size, anchor_x='center', anchor_y='center' )
i += 1
self.add( line_text )
示例14: __init__
def __init__(self, title, lines):
super(BulletListLayer, self).__init__()
x, y = director.get_window_size()
self.title = text.Label(
title, (x // 2, y - 100), font_name='Consolas',
font_size=46, anchor_x='center', anchor_y='center')
self.add(self.title)
start_y = (y // 12) * 8
font_size = 22
line_font = font.load('Consolas', font_size)
tot_height = 0
max_width = 0
rendered_lines = []
step = 40
i = 0
for line in lines:
line_text = text.Label(
line, (x // 2, y - 185 - step * i), font_name='Consolas',
font_size=font_size, anchor_x='center', anchor_y='center')
i += 1
self.add(line_text)
bgimage = Sprite('background.jpg')
bgimage.scale = 0.8
bgimage.position = x/2, y/2 - 200
self.add(bgimage, z=-1)
示例15: __init__
def __init__(self, client):
super(HeadPositionLayer, self).__init__()
self.client = client
self.screen = director.get_window_size()
self.font = font.load('Cut Outs for 3D FX', 384)
arrow1_img = self.font.get_glyphs("I")[0].get_texture(True)
arrow1_img.anchor_x = 'center'
arrow1_img.anchor_y = 'center'
arrow2_img = self.font.get_glyphs("J")[0].get_texture(True)
arrow2_img.anchor_x = 'center'
arrow2_img.anchor_y = 'center'
self.arrows = [Sprite(arrow1_img, position=(self.screen[0] / 2, self.screen[1] / 8 * 7), color=(255, 0, 0), opacity=0, scale=.75, rotation=270),
Sprite(arrow1_img, position=(self.screen[0] / 2, self.screen[1] / 8 * 7), color=(255, 0, 0), opacity=0, scale=.75, rotation=90),
Sprite(arrow1_img, position=(self.screen[0] / 8, self.screen[1] / 2), color=(255, 0, 0), opacity=0, scale=.75, rotation=0),
Sprite(arrow1_img, position=(self.screen[0] / 8 * 7, self.screen[1] / 2), color=(255, 0, 0), opacity=0, scale=.75, rotation=180),
Sprite(arrow2_img, position=(self.screen[0] / 2, self.screen[1] / 8), color=(255, 0, 0), opacity=0, scale=.75, rotation=90),
Sprite(arrow2_img, position=(self.screen[0] / 2, self.screen[1] / 8), color=(255, 0, 0), opacity=0, scale=.75, rotation=270)]
for arrow in self.arrows:
self.add(arrow)
self.head = (0,0,0)