A community-maintained Python framework for creating mathematical animations.
Remove deprecated function `set_filly_by_value` from `opengl_surface` (#3103)
Alex Lembcke87dbd0362219
diff --git a/manim/mobject/opengl/opengl_surface.py b/manim/mobject/opengl/opengl_surface.pyindex 64cbd43f5..dec54c98e 100644--- a/manim/mobject/opengl/opengl_surface.py+++ b/manim/mobject/opengl/opengl_surface.py@@ -341,91 +341,6 @@ class OpenGLSurface(OpenGLMobject):def get_shader_vert_indices(self):return self.get_triangle_indices()- @deprecated(- since="v0.16.0",- message="Use colorscale attribute instead.",- )- def set_fill_by_value(self, axes, colors):- # directly copied from three_dimensions.py with some compatibility changes.- """Sets the color of each mobject of a parametric surface to a color relative to its z-value-- Parameters- ----------- axes :- The axes for the parametric surface, which will be used to map z-values to colors.- colors :- A list of colors, ordered from lower z-values to higher z-values. If a list of tuples is passed- containing colors paired with numbers, then those numbers will be used as the pivots.-- Returns- -------- :class:`~.Surface`- The parametric surface with a gradient applied by value. For chaining.-- Examples- --------- .. manim:: FillByValueExample- :save_last_frame:-- class FillByValueExample(ThreeDScene):- def construct(self):- resolution_fa = 42- self.set_camera_orientation(phi=75 * DEGREES, theta=-120 * DEGREES)- axes = ThreeDAxes(x_range=(0, 5, 1), y_range=(0, 5, 1), z_range=(-1, 1, 0.5))- def param_surface(u, v):- x = u- y = v- z = np.sin(x) * np.cos(y)- return z- surface_plane = Surface(- lambda u, v: axes.c2p(u, v, param_surface(u, v)),- resolution=(resolution_fa, resolution_fa),- v_range=[0, 5],- u_range=[0, 5],- )- # surface_plane.set_style(fill_opacity=1)- surface_plane.set_fill_by_value(axes=axes, colors=[(RED, -0.4), (YELLOW, 0), (GREEN, 0.4)])- self.add(axes, surface_plane)- """- if type(colors[0]) is tuple:- new_colors, pivots = [[i for i, j in colors], [j for i, j in colors]]- else:- new_colors = colors-- pivot_min = axes.z_range[0]- pivot_max = axes.z_range[1]- pivot_frequency = (pivot_max - pivot_min) / (len(new_colors) - 1)- pivots = np.arange(- start=pivot_min,- stop=pivot_max + pivot_frequency,- step=pivot_frequency,- )-- for mob in self.family_members_with_points():- # import ipdb; ipdb.set_trace(context=7)- z_value = axes.point_to_coords(mob.get_midpoint())[2]- if z_value <= pivots[0]:- mob.set_color(new_colors[0])- elif z_value >= pivots[-1]:- mob.set_color(new_colors[-1])- else:- for i, pivot in enumerate(pivots):- if pivot > z_value:- color_index = (z_value - pivots[i - 1]) / (- pivots[i] - pivots[i - 1]- )- color_index = min(color_index, 1)- mob_color = interpolate_color(- new_colors[i - 1],- new_colors[i],- color_index,- )- mob.set_color(mob_color, recurse=False)-- break-- return self-class OpenGLSurfaceGroup(OpenGLSurface):def __init__(self, *parametric_surfaces, resolution=None, **kwargs):