A community-maintained Python framework for creating mathematical animations.
Add opengl support for Boolean Operations (#2016)
Naveen M K3f272097110f
diff --git a/manim/mobject/boolean_ops.py b/manim/mobject/boolean_ops.pyindex 03f37236f..fe14a8778 100644--- a/manim/mobject/boolean_ops.py+++ b/manim/mobject/boolean_ops.py@@ -5,12 +5,13 @@ from pathops import Path as SkiaPathfrom pathops import PathVerb, difference, intersection, union, xorfrom .. import config+from .opengl_compatibility import ConvertToOpenGLfrom .types.vectorized_mobject import VMobject__all__ = ["Union", "Intersection", "Difference", "Exclusion"]-class _BooleanOps(VMobject):+class _BooleanOps(VMobject, metaclass=ConvertToOpenGL):"""This class contains some helper functions whichhelps to convert to and from skia objects and manimobjects (:class:`~.VMobject`).@@ -76,16 +77,28 @@ class _BooleanOps(VMobject):if len(points) == 0: # what? No points so return empty pathreturn path- subpaths = vmobject.gen_subpaths_from_points_2d(points)- for subpath in subpaths:- quads = vmobject.gen_cubic_bezier_tuples_from_points(subpath)- start = subpath[0]- path.moveTo(*start[:2])- for p0, p1, p2, p3 in quads:- path.cubicTo(*p1[:2], *p2[:2], *p3[:2])+ # In OpenGL it's quadratic beizer curves while on Cairo it's cubic...+ if config.renderer == "opengl":+ subpaths = vmobject.get_subpaths_from_points(points)+ for subpath in subpaths:+ quads = vmobject.get_bezier_tuples_from_points(subpath)+ start = subpath[0]+ path.moveTo(*start[:2])+ for p0, p1, p2 in quads:+ path.quadTo(*p1[:2], *p2[:2])+ if vmobject.consider_points_equals(subpath[0], subpath[-1]):+ path.close()+ else:+ subpaths = vmobject.gen_subpaths_from_points_2d(points)+ for subpath in subpaths:+ quads = vmobject.gen_cubic_bezier_tuples_from_points(subpath)+ start = subpath[0]+ path.moveTo(*start[:2])+ for p0, p1, p2, p3 in quads:+ path.cubicTo(*p1[:2], *p2[:2], *p3[:2])- if vmobject.consider_points_equals_2d(subpath[0], subpath[-1]):- path.close()+ if vmobject.consider_points_equals_2d(subpath[0], subpath[-1]):+ path.close()return path@@ -118,10 +131,7 @@ class _BooleanOps(VMobject):parts = self._convert_2d_to_3d_array(points)vmobject.add_line_to(parts[0])elif path_verb == PathVerb.CLOSE:- if config.renderer == "opengl":- vmobject.close_path()- else:- vmobject.add_line_to(current_path_start)+ vmobject.add_line_to(current_path_start)elif path_verb == PathVerb.QUAD:n1, n2 = self._convert_2d_to_3d_array(points)vmobject.add_quadratic_bezier_curve_to(n1, n2)