Dan K Posted March 15, 2019 Share Posted March 15, 2019 In the examples/graphics the following call is made on line 45 me.video.renderer.setColor(r); 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. Quote Link to comment Share on other sites More sharing options...
obiot Posted March 15, 2019 Share Posted March 15, 2019 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 define the current fill and stroke rendering color and is defined here for the canvas renderer : https://github.com/melonjs/melonJS/blob/master/src/video/canvas/canvas_renderer.js#L571-L586 and there for the WebGL one : https://github.com/melonjs/melonJS/blob/master/src/video/webgl/webgl_renderer.js#L591-L603 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 ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.