五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

氣輕pyglet22 導入字體

2023-04-06 08:05 作者:氣輕  | 我要投稿

?

Pyglet可以導入字體,函數(shù)font.add_file(fontname)可導入指定字體,函數(shù)font.add_directory(dirname)可導入文件夾dirname中左右字體。

?

from pyglet.gl import *

from pyglet.window import mouse

from pyglet import font

import os

##from WindowShot import *

?

WIDTH = 800

HEIGHT = 600

?

wtitlt = 'pyglet font'

?

class Window(pyglet.window.Window):

?

??? def __init__(self,*args,**kwargs):

??????? super().__init__(*args,**kwargs)

??????? self.batch = pyglet.graphics.Batch()

??????? pyglet.clock.schedule_interval(self.callback,1/30)

?

??????? font.add_directory('C:\Windows\Fonts')????????? # 添加指定文件夾中字體

??????? self.LabelList = []

??????? self.ShowList = []

??????? self.labelshow = LabelManager()

??????? self.labelshow.LabelAppend(self.LabelList,5)

?

??????? self.labelshow.LabelDraw(self.LabelList,self.ShowList,self.batch)

?

??? def on_mouse_press(self, x, y, symbol, modifiers):

??????? if symbol == mouse.LEFT:

??????????? self.close()

?

??? def on_draw(self):

??????? window.clear()

??????? self.batch.draw()

?

??? def callback(self,dt):

??????? for s in self.ShowList:

??????????? s.delete()

??????? self.labelshow.LabelDraw(self.LabelList,self.ShowList,self.batch)

??????? self.labelshow.LabelAppend(self.LabelList,dt)

?

??????? if self.labelshow.i == 4 and self.LabelList[-1].finish:

??????????? pyglet.app.exit()

?

class LabelManager:

??? def __init__(self):

??????? self.dt = 0

??????? self.pos = [[800,?? 0, 200, 500],

??????????????????? [800, 800, 350, 350],

??????????????????? [0, 0, 500, 200],

??????????????????? [0, 600, 650,? 50]]

??????? self.i = 0

??????? self.label = ['中文字體 華文彩云','中文字體 華文琥珀','日本語フォント','日本語フォント']

??????? self.fnames = ['華文彩云',

????????????????? '華文琥珀',

????????????????? 'MS PMincho',

????????????????? 'UD Digi Kyokasho N-B',

????????????????? ]

??????? self.c = [(192, 100, 0,255),(0, 255, 0,255),

????????????????? (0, 0, 255,255),(0, 100, 100,255)]

?

??? def LabelAppend( self,labelslist,dt ):

??????? self.dt += dt

??????? n = len(labelslist)

??????? if self.dt > 4 and n < 4:

??????????? self.dt = 0

??????????? labelslist.append(LabelGenerator(self.pos[self.i]))

??????????? self.i += 1

?

??? def LabelDraw(self,labelslist,showlist,batch):

??????? for i, t in enumerate(labelslist):

???????? ???t.OnShow(showlist,self.fnames[i],self.c[i],self.label[i],batch)

?

class LabelGenerator:

??? def __init__(self,coordinate):

??????? self.x,self.y,self.tx,self.ty = coordinate

??????? self.inc = 5

??????? self.finish = False

?

??? def OnShow( self,LabelBuf,fname,c,label,batch ):

??????? label = pyglet.text.Label(label, font_name=fname,

??????????? font_size=26, color=c, x=self.x, y=self.y,

??????????? anchor_x='center', anchor_y='center', batch=batch)

??????? LabelBuf.append(label)

?

??????? if self.x != self.tx:

??????????? self.x = MovetoSite( self.tx,self.x,self.inc )

??????? if self.y != self.ty:

??????????? self.y = MovetoSite( self.ty,self.y,self.inc )

??????? if self.x == self.tx and self.y == self.ty:

??????????? self.finish = True

?

def MovetoSite( p0,p,dp ):

?

??? newp = p - (p-p0)/abs(p-p0)*dp

??? if abs(newp - p0) < dp:

??????? newp = p0

?

??? return newp

?

if __name__ == '__main__':

??? window = Window(width=WIDTH,height=HEIGHT,caption=wtitlt)

??? window.set_location(200, 200)

??? pyglet.gl.glClearColor(0.8,0.8,0.8,0)

??? pyglet.app.run()

?

執(zhí)行結(jié)果


氣輕pyglet22 導入字體的評論 (共 條)

分享到微博請遵守國家法律
永仁县| 遵义市| 岳普湖县| 荆州市| 揭东县| 蓬安县| 姜堰市| 耿马| 察哈| 神木县| 江源县| 揭阳市| 临清市| 绥中县| 平定县| 金秀| 石柱| 龙南县| 杭锦旗| 农安县| 张掖市| 湘阴县| 得荣县| 资源县| 隆昌县| 集安市| 伊川县| 青神县| 出国| 澜沧| 安仁县| 黄龙县| 浦江县| 绥化市| 南充市| 巩义市| 清水河县| 屏东县| 新安县| 宜黄县| 宣威市|