A community-maintained Python framework for creating mathematical animations.
A few fixes to initial point_thickness implementation
Grant Sanderson014a277a9775
diff --git a/constants.py b/constants.pyindex b50a3bd34..fed42eb48 100644--- a/constants.py+++ b/constants.py@@ -1,9 +1,6 @@import osimport numpy as np--GENERALLY_BUFFER_POINTS = True-PRODUCTION_QUALITY_DISPLAY_CONFIG = {"height" : 1440,"width" : 2560,@@ -20,6 +17,8 @@ LOW_QUALITY_DISPLAY_CONFIG = {DEFAULT_POINT_DENSITY_2D = 25DEFAULT_POINT_DENSITY_1D = 200+DEFAULT_POINT_THICKNESS = 4+#TODO, Make sure these are not needdDEFAULT_HEIGHT = PRODUCTION_QUALITY_DISPLAY_CONFIG["height"]DEFAULT_WIDTH = PRODUCTION_QUALITY_DISPLAY_CONFIG["width"]diff --git a/displayer.py b/displayer.pyindex 844948b8d..8633777ec 100644--- a/displayer.py+++ b/displayer.py@@ -55,7 +55,7 @@ def paint_mobjects(mobjects, image_array = None):points[:,1] = -1*points[:,1]*height/space_height/2 + height/2points, rgbs = add_thickness(points.astype('int'), rgbs,- mobject.point_thickness,+ mobject.point_thickness,width, height)@@ -69,11 +69,14 @@ def paint_mobjects(mobjects, image_array = None):def add_thickness(pixel_indices, rgbs, thickness, width, height):"""Imagine dragging each pixel around like a paintbrush in- a square of pixels tickness x thickness big surrounding it+ a plus-sign-shaped pixel arrangement surrounding it"""+ thickness = adjusted_thickness(thickness, width, height)original = np.array(pixel_indices)original_rgbs = np.array(rgbs)for nudge in range(-thickness/2+1, thickness/2+1):+ if nudge == 0:+ continuefor x, y in [[nudge, 0], [0, nudge]]:pixel_indices = np.append(pixel_indices,@@ -86,7 +89,12 @@ def add_thickness(pixel_indices, rgbs, thickness, width, height):(pixel_indices[:,1] >= 0) & \(pixel_indices[:,1] < height)return pixel_indices[admissibles], rgbs[admissibles]-++def adjusted_thickness(thickness, width, height):+ big_width = PRODUCTION_QUALITY_DISPLAY_CONFIG["width"]+ big_height = PRODUCTION_QUALITY_DISPLAY_CONFIG["height"]+ factor = (big_width + big_height) / (width + height)+ return 1 + (thickness-1)/factordef place_on_screen(points, rgbs, space_width, space_height):"""diff --git a/mobject/mobject.py b/mobject/mobject.pyindex 9a5e9b994..f836752ac 100644--- a/mobject/mobject.py+++ b/mobject/mobject.py@@ -21,7 +21,7 @@ class Mobject(object):#Number of numbers used to describe a point (3 for pos, 3 for normal vector)DEFAULT_CONFIG = {"color" : "white",- "point_thickness" : 4,+ "point_thickness" : DEFAULT_POINT_THICKNESS,"name" : None,}DIM = 3@@ -369,7 +369,7 @@ class Mobject2D(Mobject):"density" : DEFAULT_POINT_DENSITY_2D,}def __init__(self, **kwargs):- digest_config(self, Mobject1D, kwargs)+ digest_config(self, Mobject2D, kwargs)self.epsilon = 1.0 / self.densityMobject.__init__(self, **kwargs)