mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
A few fixes to initial point_thickness implementation
This commit is contained in:
parent
c0994ed0a5
commit
014a277a97
3 changed files with 15 additions and 8 deletions
|
@ -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"]
|
||||
|
|
14
displayer.py
14
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):
|
||||
"""
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue