+ 2
I did in JavaScript this: rect(5, 5, 5, 5) to see how the size is or something, when I check the output, there isn't anything there... What could be the problem?
Halp pls
7 Answers
+ 10
Javascript rect() is used to draw a rectangle.
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
ctx.stroke();
For this example you need to define <canvas id="ctx" width="300px" height="300px"></canvas>
As output You will see a rextangle.
But it seems, on that site was external js library with custom rect() function..as visph says
+ 5
Depends on in what output You are looking.
Maybe You just need to wrap rect(5,5,5,5) in alert to see output in browser's alert box:
-> alert( rect(5,5,5,5) )
Or you can wrap it in console.log to see result in a console:
console.log( rect(5,5,5,5) )
All of this should work if Your function returns result value with. like this:
function rect(a,b,c,d) {
var result = a*b*c*d;
// return result to show it in output
return result;
}
+ 4
@Visph:
+1. I didn't know about rect method also, xD I have very very very small experience with canvas. Googled it when saw in question)))
+ 3
Not enough information...
From where come from this function ( or class? ) 'rect' ?
How do you use it exactly, in what context?
If you just execute this ( as you type it in your question ):
rect(5,5,5,5)
... and anything else, obviously you don't get any result.
Or no, you should have errors as result, because rect isn't defined anywhere.
+ 3
It seems like if you don't have the library which provide this function... :(
+ 3
@'IceQ' Sergej Kostenko:
I don't know the existence of rect() in JQuery, and don't too have really dived in <canvas> and its js specifities, so no more know rect() in js ^^
I was just supposed an arbitrary library with an arbitrary 'rect' identifier :D
+ 2
Once I took JavaScripting on a different website, and it taught me the shape drawing thingy, all you do is rect(x Size, y Size, x Position, y Position) as I remember it. It is used to create a rectangle. I am using it inside a function if that will help...