Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
result += self.use_to_mobjects(element)
elif element.tagName == 'rect':
result.append(self.rect_to_mobject(element))
elif element.tagName == 'circle':
result.append(self.circle_to_mobject(element))
elif element.tagName == 'ellipse':
result.append(self.ellipse_to_mobject(element))
elif element.tagName in ['polygon', 'polyline']:
result.append(self.polygon_to_mobject(element))
else:
pass # TODO
# warnings.warn("Unknown element type: " + element.tagName)
result = [m for m in result if m is not None]
self.handle_transforms(element, VGroup(*result))
if len(result) > 1 and not self.unpack_groups:
result = [VGroup(*result)]
return result
def __init__(self, bubble, **kwargs):
digest_config(self, kwargs)
create_bubble = self.bubble_animation_class(
bubble, *self.bubble_animation_args, **self.bubble_animation_kwargs
)
create_content = self.content_animation_class(
VGroup(*bubble.content), *self.content_animation_args, **self.content_animation_kwargs
)
AnimationGroup.__init__(
self, create_bubble, create_content, **kwargs
)
def get_highlight_rectangles(self, n):
return VGroup(*[
self.get_highlight_rectangle(term_tex, k)
for term_tex, k in zip(self.prod_tex[:-1], self.k_list[n])
])
def __init__(self, pi_creature=None, **kwargs):
digest_config(self, kwargs)
SVGMobject.__init__(self, file_name=self.file_name, **kwargs)
self.stretch(self.y_stretch_factor, 1)
self.set_height(self.height)
self.set_stroke(width=0)
self.set_fill(color=self.color)
if pi_creature is not None:
eyes = pi_creature.eyes
self.set_height(3 * eyes.get_height())
self.move_to(eyes, DOWN)
self.shift(DOWN * eyes.get_height() / 4)
class Clock(VGroup):
CONFIG = {}
def __init__(self, **kwargs):
circle = Circle(color=WHITE)
ticks = []
for x in range(12):
alpha = x / 12.
point = complex_to_R3(
np.exp(2 * np.pi * alpha * complex(0, 1))
)
length = 0.2 if x % 3 == 0 else 0.1
ticks.append(
Line(point, (1 - length) * point)
)
self.hour_hand = Line(ORIGIN, 0.3 * UP)
self.minute_hand = Line(ORIGIN, 0.6 * UP)
def g_to_mobjects(self, g_element):
mob = VGroup(*self.get_mobjects_from(g_element))
self.handle_transforms(g_element, mob)
return mob.submobjects
-TAU / n_spikes / 2,
about_point=ORIGIN
)
layer.brown_index = index
else:
half_spikes = [
right_half_triangle.copy(),
left_half_triangle.copy().rotate(
90 * DEGREES, about_point=ORIGIN,
),
right_half_triangle.copy().rotate(
90 * DEGREES, about_point=ORIGIN,
),
left_half_triangle.copy()
]
layer = VGroup(*it.chain(
half_spikes[:1],
full_spikes[1:index],
half_spikes[1:3],
full_spikes[index + 1:],
half_spikes[3:],
))
layer.brown_index = index + 1
layers.add(layer)
# Color spikes
blues = self.blue_spike_colors
browns = self.brown_spike_colors
for layer, blue, brown in zip(layers, blues, browns):
index = layer.brown_index
layer[:index].set_color(blue)
def vgroup_expansion(mobs):
"""Flatten a nested VGroup object ``mobs``."""
while any(map(lambda x: isinstance(x, VGroup), mobs)):
expanded_mobs = []
for mob in mobs.submobjects:
expanded_mobs.extend(mob)
mobs = VGroup(expanded_mobs)
return mobs
def get_times_symbols(self):
return VGroup(*[term_tex[-1] for term_tex in self.prod_tex[:-1]])
def cut_pupil(self):
pupil = self.pupil
center = pupil.get_center()
new_pupil = VGroup(*[
pupil.copy().pointwise_become_partial(pupil, a, b)
for (a, b) in [(0.25, 1), (0, 0.25)]
])
for sector in new_pupil:
sector.add_cubic_bezier_curve_to([
sector.points[-1],
*[center] * 3,
*[sector.points[0]] * 2
])
self.remove(pupil)
self.add(new_pupil)
self.pupil = new_pupil
def __init__(self, values, **kwargs):
VGroup.__init__(self, **kwargs)
if self.max_value is None:
self.max_value = max(values)
self.add_axes()
self.add_bars(values)
self.center()