question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set_color(COLOR) (and some other methods mostly used for manipulating the size, position etc. of objects on canvas) dont change the attributes associated with the object.

See original GitHub issue

I don’t know if this is intentional but the setting methods especially those used for manipulating the position/color of objects on manim canvas don’t actually change these attributes. For example, here I am trying to change the color of the TextMobject using set_color() but it is not changing the color property associated with the object although its appearance on the canvas has been changed to the desired color.

class Testing(Scene):
    def construct(self):
        some_text = TextMobject("This is some text")
        print("Color of the variable before applying set_color(): ",some_text.color)
        self.play(Write(some_text))
        self.wait()
        self.remove(some_text)
        some_text.set_color(GREEN_D)
        print("Color of the variable after applying set_color(): ",some_text.color)
        self.play(ShowCreation(some_text))
        self.wait()

Here is the output: Testing

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Ammar34commented, Aug 24, 2020

@Ammar34 would you be interested in opening a PR for this? 😃

Yes sir. I was a little busy for the past two weeks. I will PR tomorrow if that is okay!

1reaction
Ammar34commented, Aug 7, 2020

The vectorized M object class has its own set_color(COLOR) method defined where the COLOR passed is not set to the color attribute of the object. Looking at the method resolution order, TextMobject looks for the method set_color(COLOR) in VMobject.

https://github.com/ManimCommunity/manim/blob/70c0d53a01ee6cd1da9a74c0338ed404f67b9123/manim/mobject/types/vectorized_mobject.py#L227-L230

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Applying styles and colors - Web APIs | MDN
Here we will explore the canvas options we have at our disposal to make our ... You will learn how to add different...
Read more >
Custom Graphics Programming - Java Programming Tutorial
In Java, custom painting is done via the java.awt.Graphics class, which manages a graphics context, and provides a set of device-independent methods for...
Read more >
turtle — Turtle graphics — Python 3.11.1 documentation
The TurtleScreen class defines graphics windows as a playground for the drawing turtles. Its constructor needs a tkinter.Canvas or a ScrolledCanvas as argument....
Read more >
TkDocs Tutorial - Canvas
A canvas widget manages a 2D collection of graphical objects — lines, circles, text, images, other widgets, and more. Tk's canvas is an...
Read more >
HTML Canvas Reference - W3Schools
Colors, Styles, and Shadows ; createPattern(), Repeats a specified element in the specified direction ; createRadialGradient(), Creates a radial/circular gradient ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found