Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MarkupText #1557

Merged
merged 1 commit into from
Jul 28, 2021
Merged

Add MarkupText #1557

merged 1 commit into from
Jul 28, 2021

Conversation

naveen521kk
Copy link
Contributor

Motivation

Add MarkupText which is previously in Community Edition
This would use a Pango specific markup that looks like HTML.

Proposed changes

There are some specific implementation here about <color>
and <gradient>
Pango doesn't support <gradient> or <color> instead it works with color attribute and the gradient isn't supported.
Since SVGMobject doesn't know about parsing colours from SVG image and implementation of <color> and <gradient> is added.

  • Add a new class MarkupText

Comments

Most parts of the code were authored by PhilippImhof and copied from Manim Community. I have added him as co-author in that commit

Test

Code:

class TextExample(Scene):
    def construct(self):
        a1 = MarkupText('<span style="italic">italic</span>')
        a2 = MarkupText('<span weight="bold">bold</span>')
        a3 = MarkupText('<span font="Roboto">Roboto Font</span>')
        a4 = MarkupText('<span font="Cursive">Cursive Font</span>')
        a5 = MarkupText('<color col="RED"><span font="Cursive">Red</span></color>')
        a6 = MarkupText('<gradient from="RED" to="BLUE">Gradient</gradient>')
        v = VGroup(a1, a2, a3, a4, a5, a6).arrange_in_grid()
        self.play(FadeIn(v))

Result:

TextExample.mp4

This would use a Pango specific markup which looks like html.

There are some specific implementation here about `<color>`
and `<gradient>`
Pango doesn't support `<gradient>`  or `<color> ` instead it works
with `color` attribute and gradient isn't supported.
Since, `SVGMobject` doesn't know about parsing colors from SVG image
and implmentation of `<color>` and `<gradient>` is added.

Co-authored-by: Philipp Imhof <52650214+PhilippImhof@users.noreply.github.com>
Signed-off-by: Naveen M K <naveen@syrusdark.website>
@naveen521kk
Copy link
Contributor Author

@3b1b does this look good to you?

@3b1b 3b1b merged commit fd8904e into 3b1b:master Jul 28, 2021
@naveen521kk naveen521kk deleted the add-markuptext branch July 28, 2021 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants