zoukankan      html  css  js  c++  java
  • pyglet----画一个矩形

    这里列出一种在窗口Window中画图的程序框架。。。。。。。。。。

    #-*- coding:utf-8 -*-
    from pyglet.gl import *
    
    def draw_rect(x, y, width, height):
        glBegin(GL_LINE_LOOP)
        glVertex2f(x, y)
        glVertex2f(x + width, y)
        glVertex2f(x + width, y + height)
        glVertex2f(x, y + height)
        glEnd()
        
    
    class Button():
        def draw(self):
            draw_rect(0.0,0.0,10.0,10.0)
            
    class MyWindow(pyglet.window.Window):
        def __init__(self):
            super(MyWindow,self).__init__()
            #按钮
            self.button=Button()
            self.need_draw=[
                    self.button,
                                ]
        def on_draw(self):
            print('g')
            self.clear()
            for draw_object in self.need_draw:
                draw_object.draw()
            
    
    if __name__ == "__main__":
        wn=MyWindow()
    pyglet.app.run()
        
            
  • 相关阅读:
    sqhhb
    12333
    12

    今日份
    12
    彻底理解 Cookie、Session、Token
    https原理
    12312
    uiower
  • 原文地址:https://www.cnblogs.com/yinwei-space/p/4604685.html
Copyright © 2011-2022 走看看