Sign in to follow this  
Dan K

Where is the renderer.setColor() function coming from?

Recommended Posts

In the examples/graphics the following call is made on line 45;

But where does the setColor function come from?  the renderer is a me.Object and there is no setColor Funciton in the renderer class.

The function does seem to refer to the declaration in me.Color.setColor  but this function just returns a color, so to me its unclear how the canvas context knows that the color is set.

Even if the setColor is a prototype function, I still don't see where it become part of the renderer object.

--- To supplement this thought.  I would suggest moving color related functions (the active setting / changing not the Color manipulation functions) inside of the me.Renderer  even if it just referencs the function in the me.Color class.    It is logical that the programmer will be using the 'renderer' class for custom drawing functions and it would be natural to expect to find references on how to set the color here.


Share this post

Link to post
Share on other sites

me.Renderer is just a base class for both the Canvas and WebGL renderer to prevent duplicated code as half of it is anyway common to both.

as for the setColor() methods, this is used to defined the current fill and stroke rendering color and is defined here for the canvas renderer :

and there for the WebGL one :

reason of this one not being in the base Renderer class is that, as you can see, the implementation is different based on the target renderer.


hope this helps ! 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.