diff --git a/constants.py b/constants.py index b50a3bd3..fed42eb4 100644 --- a/constants.py +++ b/constants.py @@ -1,9 +1,6 @@ import os import 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 = 25 DEFAULT_POINT_DENSITY_1D = 200 +DEFAULT_POINT_THICKNESS = 4 + #TODO, Make sure these are not needd DEFAULT_HEIGHT = PRODUCTION_QUALITY_DISPLAY_CONFIG["height"] DEFAULT_WIDTH = PRODUCTION_QUALITY_DISPLAY_CONFIG["width"] diff --git a/displayer.py b/displayer.py index 844948b8..8633777e 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/2 points, 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: + continue for 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)/factor def place_on_screen(points, rgbs, space_width, space_height): """ diff --git a/mobject/mobject.py b/mobject/mobject.py index 9a5e9b99..f836752a 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.density Mobject.__init__(self, **kwargs)