Nov 24, 2012 at 6:20pm
I have posted some example js code below that is giving me trouble. The problem I am encountering is that
When I call fillrgb(100), it actually calls the function fillrgb(v1, v2, v3, alpha) with
autowatch = 1;
var width = 500;
// init drawing context
var outmatrix = new JitterMatrix(4, “char”, width, height);
Nov 24, 2012 at 9:47pm
You can’t have two functions named the same. There’s no way the computer would know which one you want to run. You might want to try testing for the number of arguments inside the code and if setting the rgba values accordingly with an if statement.
Nov 25, 2012 at 4:09am
Java does not have a problem with functions with the same name. It tells
Nov 25, 2012 at 10:53am
Nov 25, 2012 at 6:36pm
Basically, what your code is doing is declaring an identifier “fillrgb”, setting it to a function definition, then immediately redefining the identifier to point to a different function definition. By the time your code is executed, the interpreter has entirely forgotten that a single-parameter version of fillrgb() ever existed. When you call fillrgb(), you are *always* calling the triple-parameter version. If you don’t specify the second and third parameter they are, of course, set to default values.
Nov 26, 2012 at 2:31am
Thanks guys for the pointers. I will look into the arguments property.
You must be logged in to reply to this topic.