mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
8aedb8f33e
4 changed files with 25 additions and 12 deletions
|
@ -16,6 +16,7 @@ Fixed bugs
|
|||
- Fixed chaining animation in example scenes
|
||||
- Fixed the default color of tip
|
||||
- Fixed a typo in ``ShowPassingFlashWithThinningStrokeWidth``
|
||||
- Fixed the default size of ``Text``
|
||||
|
||||
New Features
|
||||
^^^^^^^^^^^^
|
||||
|
|
|
@ -15,7 +15,7 @@ class OpeningManimExample(Scene):
|
|||
The original motivation for manim was to
|
||||
better illustrate mathematical functions
|
||||
as transformations.
|
||||
""", lsh=1.5)
|
||||
""")
|
||||
intro_words.to_edge(UP)
|
||||
|
||||
self.play(Write(intro_words))
|
||||
|
|
|
@ -21,6 +21,7 @@ from manimlib.utils.iterables import resize_with_interpolation
|
|||
from manimlib.utils.iterables import make_even
|
||||
from manimlib.utils.iterables import listify
|
||||
from manimlib.utils.bezier import interpolate
|
||||
from manimlib.utils.bezier import integer_interpolate
|
||||
from manimlib.utils.paths import straight_path
|
||||
from manimlib.utils.simple_functions import get_parameters
|
||||
from manimlib.utils.space_ops import angle_of_vector
|
||||
|
|
|
@ -3,6 +3,7 @@ import hashlib
|
|||
import os
|
||||
import re
|
||||
import typing
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -17,8 +18,8 @@ from manimlib.utils.directories import get_downloads_dir, get_text_dir
|
|||
from manimpango import PangoUtils
|
||||
from manimpango import TextSetting
|
||||
|
||||
TEXT_MOB_SCALE_FACTOR = 0.001048
|
||||
|
||||
TEXT_MOB_SCALE_FACTOR = 0.0076
|
||||
DEFAULT_LINE_SPACING_SCALE = 0.3
|
||||
|
||||
class Text(SVGMobject):
|
||||
CONFIG = {
|
||||
|
@ -30,7 +31,7 @@ class Text(SVGMobject):
|
|||
"font": '',
|
||||
"gradient": None,
|
||||
"lsh": -1,
|
||||
"size": 1,
|
||||
"size": None,
|
||||
"font_size": 48,
|
||||
"tab_width": 4,
|
||||
"slant": NORMAL,
|
||||
|
@ -46,7 +47,17 @@ class Text(SVGMobject):
|
|||
def __init__(self, text, **config):
|
||||
self.full2short(config)
|
||||
digest_config(self, config)
|
||||
self.lsh = self.size if self.lsh == -1 else self.lsh
|
||||
if self.size:
|
||||
warnings.warn(
|
||||
"self.size has been deprecated and will "
|
||||
"be removed in future.",
|
||||
DeprecationWarning
|
||||
)
|
||||
self.font_size = self.size
|
||||
if self.lsh == -1:
|
||||
self.lsh = self.font_size + self.font_size * DEFAULT_LINE_SPACING_SCALE
|
||||
else:
|
||||
self.lsh = self.font_size + self.font_size * self.lsh
|
||||
text_without_tabs = text
|
||||
if text.find('\t') != -1:
|
||||
text_without_tabs = text.replace('\t', ' ' * self.tab_width)
|
||||
|
@ -67,8 +78,8 @@ class Text(SVGMobject):
|
|||
|
||||
# anti-aliasing
|
||||
if self.height is None:
|
||||
self.scale(TEXT_MOB_SCALE_FACTOR * self.font_size)
|
||||
|
||||
self.scale(TEXT_MOB_SCALE_FACTOR)
|
||||
|
||||
# Just a temporary hack to get better triangulation
|
||||
# See pr #1552 for details
|
||||
for i in self.submobjects:
|
||||
|
@ -149,7 +160,7 @@ class Text(SVGMobject):
|
|||
def text2hash(self):
|
||||
settings = self.font + self.slant + self.weight
|
||||
settings += str(self.t2f) + str(self.t2s) + str(self.t2w)
|
||||
settings += str(self.lsh) + str(self.size)
|
||||
settings += str(self.lsh) + str(self.font_size)
|
||||
id_str = self.text + settings
|
||||
hasher = hashlib.sha256()
|
||||
hasher.update(id_str.encode())
|
||||
|
@ -203,8 +214,8 @@ class Text(SVGMobject):
|
|||
|
||||
def text2svg(self):
|
||||
# anti-aliasing
|
||||
size = self.size * 10
|
||||
lsh = self.lsh * 10
|
||||
size = self.font_size
|
||||
lsh = self.lsh
|
||||
|
||||
if self.font == '':
|
||||
self.font = get_customization()['style']['font']
|
||||
|
@ -215,8 +226,8 @@ class Text(SVGMobject):
|
|||
if os.path.exists(file_name):
|
||||
return file_name
|
||||
settings = self.text2settings()
|
||||
width = 600
|
||||
height = 400
|
||||
width = DEFAULT_PIXEL_WIDTH
|
||||
height = DEFAULT_PIXEL_HEIGHT
|
||||
disable_liga = self.disable_ligatures
|
||||
return manimpango.text2svg(
|
||||
settings,
|
||||
|
|
Loading…
Add table
Reference in a new issue