# Path: p5/core/p5.py

# 
# Path: p5/core/constants.py
# class SType(Enum):
#     POINTS = 'POINTS'
#     LINES = 'LINES'
#     LINE_STRIP = 'LINE_STRIP'
#     TRIANGLES = 'TRIANGLES'
#     TRIANGLE_FAN = 'TRIANGLE_FAN'
#     TRIANGLE_STRIP = 'TRIANGLE_STRIP'
#     QUADS = 'QUADS'
#     QUAD_STRIP = 'QUAD_STRIP'
#     TESS = 'TESS'
# 
# ROUND = "ROUND"
# 
# MITER = "MITER"
# 
# Path: p5/sketch/Vispy2DRenderer/shape.py
# class Arc(PShape):
#     def __init__(self, center, radii, start_angle, stop_angle,
#                  mode=None, fill_color='auto',
#                  stroke_color='auto', stroke_weight="auto",
#                  stroke_join="auto", stroke_cap="auto", **kwargs):
#         self._center = center
#         self._radii = radii
#         self._start_angle = start_angle
#         self._stop_angle = stop_angle
#         self.arc_mode = mode
# 
#         gl_type = SType.TESS if mode in [
#             'OPEN', 'CHORD'] else SType.TRIANGLE_FAN
#         super().__init__(fill_color=fill_color,
#                          stroke_color=stroke_color, stroke_weight=stroke_weight,
#                          stroke_join=stroke_join, stroke_cap=stroke_cap, shape_type=gl_type, **kwargs)
#         self._tessellate()
# 
#     def _tessellate(self):
#         """Generate vertex and face data using radii.
#         """
#         rx = self._radii[0]
#         ry = self._radii[1]
# 
#         c1x = self._center[0]
#         c1y = self._center[1]
#         s1 = p5.renderer.transform_matrix.dot(np.array([c1x, c1y, 0, 1]))
# 
#         c2x = c1x + rx
#         c2y = c1y + ry
#         s2 = p5.renderer.transform_matrix.dot(np.array([c2x, c2y, 0, 1]))
# 
#         sdiff = (s2 - s1)
#         size_acc = (np.sqrt(np.sum(sdiff * sdiff)) *
#                     math.pi * 2) / POINT_ACCURACY_FACTOR
# 
#         acc = min(MAX_POINT_ACCURACY, max(MIN_POINT_ACCURACY, int(size_acc)))
#         inc = int(len(SINCOS) / acc)
# 
#         sclen = len(SINCOS)
#         start_index = int((self._start_angle / (math.pi * 2)) * sclen)
#         end_index = int((self._stop_angle / (math.pi * 2)) * sclen)
# 
#         vertices = [(c1x, c1y, 0)] if self.arc_mode in ['PIE', None] else []
#         for idx in range(start_index, end_index, inc):
#             i = idx % sclen
#             vertices.append((
#                 c1x + rx * SINCOS[i][1],
#                 c1y + ry * SINCOS[i][0],
#                 0
#             ))
#         vertices.append((
#             c1x + rx * SINCOS[end_index % sclen][1],
#             c1y + ry * SINCOS[end_index % sclen][0],
#             0
#         ))
#         if self.arc_mode == 'CHORD' or self.arc_mode == 'PIE':
#             vertices.append(vertices[0])
#         self.vertices = vertices


from abc import ABC
from p5.core import p5
from p5.core.constants import SType, ROUND, MITER
from .shape import Arc
from dataclasses import dataclass
from vispy.gloo import Program, VertexBuffer, FrameBuffer, IndexBuffer
from OpenGL.GLU import gluTessBeginPolygon, gluTessBeginContour, gluTessEndPolygon, gluTessEndContour, gluTessVertex
import numpy as np
        render_primitives += p5.tess.get_result()
    return render_primitives


def get_render_primitives(shape):
    """Given a shape, return a list of render primitives in the form of [type, vertices, indices]
    """
    _check_shape(shape)
    render_primitives = []
    if isinstance(shape, Arc):
        # Render meshes
        if p5.renderer.style.fill_enabled:
            render_primitives.extend(_get_meshes(shape))
        # Render borders
        if p5.renderer.style.stroke_enabled:
            if shape.arc_mode in [
                    'CHORD', 'OPEN']:  # Implies shape.shape_type == TESS
                render_primitives.extend(_get_borders(shape))
            elif shape.arc_mode is None:  # Implies shape.shape_type == TRIANGLE_FAN
                render_primitives.append(
                    _get_line_from_verts(shape.vertices[1:]))
            elif shape.arc_mode == 'PIE':  # Implies shape.shape_type == TRIANGLE_FAN
                render_primitives.append(_get_line_from_verts(shape.vertices))
    else:
        # Render points
        if shape.shape_type == SType.POINTS:
            render_primitives.append(
                _vertices_to_render_primitive(
                    render_primitives, 'points'))
        # Render meshes

# Path: p5/core/p5.py

# 
# Path: p5/core/constants.py
# class SType(Enum):
#     POINTS = 'POINTS'
#     LINES = 'LINES'
#     LINE_STRIP = 'LINE_STRIP'
#     TRIANGLES = 'TRIANGLES'
#     TRIANGLE_FAN = 'TRIANGLE_FAN'
#     TRIANGLE_STRIP = 'TRIANGLE_STRIP'
#     QUADS = 'QUADS'
#     QUAD_STRIP = 'QUAD_STRIP'
#     TESS = 'TESS'
# 
# ROUND = "ROUND"
# 
# MITER = "MITER"
# 
# Path: p5/sketch/Vispy2DRenderer/shape.py
# class Arc(PShape):
#     def __init__(self, center, radii, start_angle, stop_angle,
#                  mode=None, fill_color='auto',
#                  stroke_color='auto', stroke_weight="auto",
#                  stroke_join="auto", stroke_cap="auto", **kwargs):
#         self._center = center
#         self._radii = radii
#         self._start_angle = start_angle
#         self._stop_angle = stop_angle
#         self.arc_mode = mode
# 
#         gl_type = SType.TESS if mode in [
#             'OPEN', 'CHORD'] else SType.TRIANGLE_FAN
#         super().__init__(fill_color=fill_color,
#                          stroke_color=stroke_color, stroke_weight=stroke_weight,
#                          stroke_join=stroke_join, stroke_cap=stroke_cap, shape_type=gl_type, **kwargs)
#         self._tessellate()
# 
#     def _tessellate(self):
#         """Generate vertex and face data using radii.
#         """
#         rx = self._radii[0]
#         ry = self._radii[1]
# 
#         c1x = self._center[0]
#         c1y = self._center[1]
#         s1 = p5.renderer.transform_matrix.dot(np.array([c1x, c1y, 0, 1]))
# 
#         c2x = c1x + rx
#         c2y = c1y + ry
#         s2 = p5.renderer.transform_matrix.dot(np.array([c2x, c2y, 0, 1]))
# 
#         sdiff = (s2 - s1)
#         size_acc = (np.sqrt(np.sum(sdiff * sdiff)) *
#                     math.pi * 2) / POINT_ACCURACY_FACTOR
# 
#         acc = min(MAX_POINT_ACCURACY, max(MIN_POINT_ACCURACY, int(size_acc)))
#         inc = int(len(SINCOS) / acc)
# 
#         sclen = len(SINCOS)
#         start_index = int((self._start_angle / (math.pi * 2)) * sclen)
#         end_index = int((self._stop_angle / (math.pi * 2)) * sclen)
# 
#         vertices = [(c1x, c1y, 0)] if self.arc_mode in ['PIE', None] else []
#         for idx in range(start_index, end_index, inc):
#             i = idx % sclen
#             vertices.append((
#                 c1x + rx * SINCOS[i][1],
#                 c1y + ry * SINCOS[i][0],
#                 0
#             ))
#         vertices.append((
#             c1x + rx * SINCOS[end_index % sclen][1],
#             c1y + ry * SINCOS[end_index % sclen][0],
#             0
#         ))
#         if self.arc_mode == 'CHORD' or self.arc_mode == 'PIE':
#             vertices.append(vertices[0])
#         self.vertices = vertices


# Path: p5/sketch/Vispy2DRenderer/openglrenderer.py
from abc import ABC
from p5.core import p5
from p5.core.constants import SType, ROUND, MITER
from .shape import Arc
from dataclasses import dataclass
from vispy.gloo import Program, VertexBuffer, FrameBuffer, IndexBuffer
from OpenGL.GLU import gluTessBeginPolygon, gluTessBeginContour, gluTessEndPolygon, gluTessEndContour, gluTessVertex
import numpy as np

        render_primitives += p5.tess.get_result()
    return render_primitives


def get_render_primitives(shape):
    """Given a shape, return a list of render primitives in the form of [type, vertices, indices]
    """
    _check_shape(shape)
    render_primitives = []
    if isinstance(shape, Arc):
        # Render meshes
        if p5.renderer.style.fill_enabled:
            render_primitives.extend(_get_meshes(shape))
        # Render borders
        if p5.renderer.style.stroke_enabled:
            if shape.arc_mode in [
                    'CHORD', 'OPEN']:  # Implies shape.shape_type == TESS
                render_primitives.extend(_get_borders(shape))
            elif shape.arc_mode is None:  # Implies shape.shape_type == TRIANGLE_FAN
                render_primitives.append(
                    _get_line_from_verts(shape.vertices[1:]))
            elif shape.arc_mode == 'PIE':  # Implies shape.shape_type == TRIANGLE_FAN
                render_primitives.append(_get_line_from_verts(shape.vertices))
    else:
        # Render points
        if shape.shape_type == SType.POINTS:
            render_primitives.append(
                _vertices_to_render_primitive(
                    render_primitives, 'points'))
        # Render meshes

        if p5.renderer.style.fill_enabled: