mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Refactor MTex
This commit is contained in:
parent
4a03d196a6
commit
9ac1805e7e
3 changed files with 489 additions and 473 deletions
File diff suppressed because it is too large
Load diff
|
@ -172,6 +172,8 @@ class SVGMobject(VMobject):
|
||||||
else:
|
else:
|
||||||
log.warning(f"Unsupported element type: {type(shape)}")
|
log.warning(f"Unsupported element type: {type(shape)}")
|
||||||
continue
|
continue
|
||||||
|
if not mob.has_points():
|
||||||
|
continue
|
||||||
self.apply_style_to_mobject(mob, shape)
|
self.apply_style_to_mobject(mob, shape)
|
||||||
if isinstance(shape, se.Transformable) and shape.apply:
|
if isinstance(shape, se.Transformable) and shape.apply:
|
||||||
self.handle_transform(mob, shape.transform)
|
self.handle_transform(mob, shape.transform)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import itertools as it
|
|
||||||
from typing import Callable, Iterable, Sequence, TypeVar
|
from typing import Callable, Iterable, Sequence, TypeVar
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -36,10 +35,6 @@ def list_difference_update(l1: Iterable[T], l2: Iterable[T]) -> list[T]:
|
||||||
return [e for e in l1 if e not in l2]
|
return [e for e in l1 if e not in l2]
|
||||||
|
|
||||||
|
|
||||||
def all_elements_are_instances(iterable: Iterable, Class: type) -> bool:
|
|
||||||
return all([isinstance(e, Class) for e in iterable])
|
|
||||||
|
|
||||||
|
|
||||||
def adjacent_n_tuples(objects: Iterable[T], n: int) -> zip[tuple[T, T]]:
|
def adjacent_n_tuples(objects: Iterable[T], n: int) -> zip[tuple[T, T]]:
|
||||||
return zip(*[
|
return zip(*[
|
||||||
[*objects[k:], *objects[:k]]
|
[*objects[k:], *objects[:k]]
|
||||||
|
@ -133,30 +128,6 @@ def make_even(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def make_even_by_cycling(
|
|
||||||
iterable_1: Iterable[T],
|
|
||||||
iterable_2: Iterable[S]
|
|
||||||
) -> tuple[list[T], list[S]]:
|
|
||||||
length = max(len(iterable_1), len(iterable_2))
|
|
||||||
cycle1 = it.cycle(iterable_1)
|
|
||||||
cycle2 = it.cycle(iterable_2)
|
|
||||||
return (
|
|
||||||
[next(cycle1) for x in range(length)],
|
|
||||||
[next(cycle2) for x in range(length)]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_nones(sequence: Iterable) -> list:
|
|
||||||
return [x for x in sequence if x]
|
|
||||||
|
|
||||||
|
|
||||||
# Note this is redundant with it.chain
|
|
||||||
|
|
||||||
|
|
||||||
def concatenate_lists(*list_of_lists):
|
|
||||||
return [item for l in list_of_lists for item in l]
|
|
||||||
|
|
||||||
|
|
||||||
def hash_obj(obj: object) -> int:
|
def hash_obj(obj: object) -> int:
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
new_obj = {k: hash_obj(v) for k, v in obj.items()}
|
new_obj = {k: hash_obj(v) for k, v in obj.items()}
|
||||||
|
|
Loading…
Add table
Reference in a new issue