mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 21:12:35 +08:00
Get rid of sheen factor
This commit is contained in:
@ -100,10 +100,7 @@ class VMobject(Mobject):
|
|||||||
width=self.stroke_width,
|
width=self.stroke_width,
|
||||||
opacity=self.stroke_opacity,
|
opacity=self.stroke_opacity,
|
||||||
)
|
)
|
||||||
self.set_sheen(
|
self.set_gloss(self.gloss)
|
||||||
factor=self.sheen_factor,
|
|
||||||
direction=self.sheen_direction,
|
|
||||||
)
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def generate_rgba_array(self, color, opacity):
|
def generate_rgba_array(self, color, opacity):
|
||||||
@ -161,8 +158,7 @@ class VMobject(Mobject):
|
|||||||
stroke_color=None,
|
stroke_color=None,
|
||||||
stroke_width=None,
|
stroke_width=None,
|
||||||
stroke_opacity=None,
|
stroke_opacity=None,
|
||||||
sheen_factor=None,
|
gloss=None,
|
||||||
sheen_direction=None,
|
|
||||||
background_image_file=None,
|
background_image_file=None,
|
||||||
family=True):
|
family=True):
|
||||||
self.set_fill(
|
self.set_fill(
|
||||||
@ -176,12 +172,8 @@ class VMobject(Mobject):
|
|||||||
opacity=stroke_opacity,
|
opacity=stroke_opacity,
|
||||||
family=family,
|
family=family,
|
||||||
)
|
)
|
||||||
if sheen_factor:
|
if gloss:
|
||||||
self.set_sheen(
|
self.set_gloss(gloss, family=family)
|
||||||
factor=sheen_factor,
|
|
||||||
direction=sheen_direction,
|
|
||||||
family=family,
|
|
||||||
)
|
|
||||||
if background_image_file:
|
if background_image_file:
|
||||||
self.color_using_background_image(background_image_file)
|
self.color_using_background_image(background_image_file)
|
||||||
return self
|
return self
|
||||||
@ -193,8 +185,7 @@ class VMobject(Mobject):
|
|||||||
"stroke_color": self.get_stroke_colors(),
|
"stroke_color": self.get_stroke_colors(),
|
||||||
"stroke_width": self.get_stroke_width(),
|
"stroke_width": self.get_stroke_width(),
|
||||||
"stroke_opacity": self.get_stroke_opacity(),
|
"stroke_opacity": self.get_stroke_opacity(),
|
||||||
"sheen_factor": self.get_sheen_factor(),
|
"gloss": self.get_gloss(),
|
||||||
"sheen_direction": self.get_sheen_direction(),
|
|
||||||
"background_image_file": self.get_background_image_file(),
|
"background_image_file": self.get_background_image_file(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +235,9 @@ class VMobject(Mobject):
|
|||||||
self.gloss = gloss
|
self.gloss = gloss
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def get_gloss(self):
|
||||||
|
return self.gloss
|
||||||
|
|
||||||
def get_fill_rgbas(self):
|
def get_fill_rgbas(self):
|
||||||
try:
|
try:
|
||||||
return self.fill_rgbas
|
return self.fill_rgbas
|
||||||
@ -280,6 +274,7 @@ class VMobject(Mobject):
|
|||||||
return np.zeros((1, 4))
|
return np.zeros((1, 4))
|
||||||
|
|
||||||
# TODO, it's weird for these to return the first of various lists
|
# TODO, it's weird for these to return the first of various lists
|
||||||
|
# rather than the full information
|
||||||
def get_stroke_color(self):
|
def get_stroke_color(self):
|
||||||
return self.get_stroke_colors()[0]
|
return self.get_stroke_colors()[0]
|
||||||
|
|
||||||
@ -303,50 +298,7 @@ class VMobject(Mobject):
|
|||||||
return self.get_stroke_color()
|
return self.get_stroke_color()
|
||||||
return self.get_fill_color()
|
return self.get_fill_color()
|
||||||
|
|
||||||
# TODO, sheen currently has no effect
|
# TODO, this currently does nothing
|
||||||
def set_sheen_direction(self, direction, family=True):
|
|
||||||
direction = np.array(direction)
|
|
||||||
if family:
|
|
||||||
for submob in self.get_family():
|
|
||||||
submob.sheen_direction = direction
|
|
||||||
else:
|
|
||||||
self.sheen_direction = direction
|
|
||||||
return self
|
|
||||||
|
|
||||||
def set_sheen(self, factor, direction=None, family=True):
|
|
||||||
if family:
|
|
||||||
for submob in self.submobjects:
|
|
||||||
submob.set_sheen(factor, direction, family)
|
|
||||||
self.sheen_factor = factor
|
|
||||||
if direction is not None:
|
|
||||||
# family set to false because recursion will
|
|
||||||
# already be handled above
|
|
||||||
self.set_sheen_direction(direction, family=False)
|
|
||||||
# Reset color to put sheen_factor into effect
|
|
||||||
if factor != 0:
|
|
||||||
self.set_stroke(self.get_stroke_color(), family=family)
|
|
||||||
self.set_fill(self.get_fill_color(), family=family)
|
|
||||||
return self
|
|
||||||
|
|
||||||
def get_sheen_direction(self):
|
|
||||||
return np.array(self.sheen_direction)
|
|
||||||
|
|
||||||
def get_sheen_factor(self):
|
|
||||||
return self.sheen_factor
|
|
||||||
|
|
||||||
def get_gradient_start_and_end_points(self):
|
|
||||||
if self.shade_in_3d:
|
|
||||||
return get_3d_vmob_gradient_start_and_end_points(self)
|
|
||||||
else:
|
|
||||||
direction = self.get_sheen_direction()
|
|
||||||
c = self.get_center()
|
|
||||||
bases = np.array([
|
|
||||||
self.get_edge_center(vect) - c
|
|
||||||
for vect in [RIGHT, UP, OUT]
|
|
||||||
]).transpose()
|
|
||||||
offset = np.dot(bases, direction)
|
|
||||||
return (c - offset, c + offset)
|
|
||||||
|
|
||||||
def color_using_background_image(self, background_image_file):
|
def color_using_background_image(self, background_image_file):
|
||||||
self.background_image_file = background_image_file
|
self.background_image_file = background_image_file
|
||||||
self.set_color(WHITE)
|
self.set_color(WHITE)
|
||||||
@ -921,7 +873,8 @@ class VMobject(Mobject):
|
|||||||
data = back_stroke_data
|
data = back_stroke_data
|
||||||
else:
|
else:
|
||||||
data = stroke_data
|
data = stroke_data
|
||||||
data.append(submob.get_stroke_shader_data())
|
new_data = submob.get_stroke_shader_data()
|
||||||
|
data.append(new_data)
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
if back_stroke_data:
|
if back_stroke_data:
|
||||||
|
Reference in New Issue
Block a user