找不到关于如何在圆周围绘制边框的信息。只需像BorderedRectangle函数一样绘制一个带有黑色边框的圆。
import pyglet
from pyglet import shapes
def display_get_width():
display = pyglet.canvas.get_display()
screen = display.get_default_screen()
return screen.width
def display_get_height():
display = pyglet.canvas.get_display()
screen = display.get_default_screen()
return screen.height
screen_width = display_get_width()
screen_height = display_get_height()
print(screen_width, screen_height)
window = pyglet.window.Window(screen_width//2,screen_height//2)
batch = pyglet.graphics.Batch()
rectangle = shapes.BorderedRectangle(250, 300, 600, 300, border=1, color=(255, 255, 255), border_color=(100, 100, 100), batch=batch)
rectangle2 = shapes.BorderedRectangle(300, 350, 300, 150, border=1, color=(255, 255, 255), border_color=(100, 100, 100), batch=batch)
circle = shapes.Circle(550, 450, 100, color=(50, 225, 30), batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.app.run()
已经一年半了,但我刚才也有同样的问题。我通过画形状解决了这个问题。ARC和使用GL功能设置宽度:
pyglet.gl.glLineWidth(5)
arc = shapes.Arc(200, 200, 150, color=(255, 0, 0), batch = batch)
省略";角度";在创建Arc实例时,参数假定角度为2π-一个完整的圆。
你可以在另一个圆圈里做一个圆圈:
circle = shapes.Circle(550, 450, 100, color=(50, 225, 30), batch=batch)
insideCircle = shapes.Circle(550, 450, 80, color=(30, 205, 10), batch=batch)