In this article we will see how we can draw arc on window in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a “heavyweight” object occupying operating system resources. Windows may appear as floating regions or can be set to fill an entire screen (fullscreen). An arc is a portion of the circumference of a circle. In the figure above, the arc is the blue part of the circle. Strictly speaking, an arc could be a portion of some other curved shape, such as an ellipse, but it almost always refers to a circle. Arc is drawn with the help of shapes module in pyglet.
We can create a window with the help of command given below
# creating a window
window = pyglet.window.Window(width, height, title)
In order to create window we use Arc method with pyglet.shapes
Syntax : shapes.Arc(arc_x, arc_y, size_arc, segments, angle, color, batch=batch)
Argument : It takes first two integer i.e arc position, third integer as size, fourth is integer i.e segments, fifth is float i.e angle, sixth is color and last is batch object
Return : It returns Arc object
Below is the implementation
Python3
import pyglet
from pyglet import shapes
width = 500
height = 500
title = "Geeksforgeeks"
window = pyglet.window.Window(width, height, title)
batch = pyglet.graphics.Batch()
arc_x = 250
arc_y = 250
size_arc = 100
segments = 5
angle = 20
color = ( 50 , 225 , 30 )
arc1 = shapes.Arc(arc_x, arc_y, size_arc, segments, angle, color, batch = batch)
arc1.opacity = 250
color = ( 255 , 30 , 30 )
segments = 10
angle = 7
arc2 = shapes.Arc(arc_x - 50 , arc_y - 50 , size_arc - 20 , segments, angle, color, batch = batch)
arc2.opacity = 255
@window .event
def on_draw():
window.clear()
batch.draw()
pyglet.app.run()
|
Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
14 Apr, 2023
Like Article
Save Article