Open arihantparsoya opened 3 years ago
Skia does not have its own event handling, it is only a rendering library but we can use glfw to support events. Also glfw provides us with a window to show the canvas
.
https://kyamagu.github.io/skia-python/tutorial/canvas.html#opengl-window
Is there any other way I am missing out to handle events?
You are right. We should use glfw to handle events.
What do you mean by this ?
For now we can write the code for rectangle only
I meant that we can only implement the rect() API in SkiaRenderer
@parsoyaarihant Any reason why events are first queued and then called after the end of each timer loop. https://github.com/p5py/p5/blob/master/p5/sketch/Vispy2DRenderer/base.py#L117 Why are we not calling the events instantly when vispy detects it?
We need to add two new classes
SkiaSketch
andSkiaRenderer
for adding skia into p5py.SkiaSketch
The first step is to create a base class
SkiaSketch
(similar toVispySketch
https://github.com/p5py/p5/blob/master/p5/sketch/Vispy2DRenderer/base.py#L39) which we can call to initiate the sketch window.This class will run a timer function to call the
draw()
function set by the timer.Reference: https://kyamagu.github.io/skia-python/tutorial/canvas.html
SkiaRenderer
SkiaRenderer
will contain the rendering code for the shapes. For now we can write the code for rectangle only. Skia uses path API, its simple to implement than the Vispy pipeline we currently have.Reference: https://kyamagu.github.io/skia-python/tutorial/path.html#