+ 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

9th Jan 2017, 10:27 PM
Norberttony
Norberttony - avatar
7 Respostas
+ 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
9th Jan 2017, 10:46 PM
"IceQ" Sergej Kostenko
"IceQ" Sergej Kostenko - avatar
+ 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; }
9th Jan 2017, 10:35 PM
"IceQ" Sergej Kostenko
"IceQ" Sergej Kostenko - avatar
+ 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)))
9th Jan 2017, 10:56 PM
"IceQ" Sergej Kostenko
"IceQ" Sergej Kostenko - avatar
+ 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.
9th Jan 2017, 10:36 PM
visph
visph - avatar
+ 3
It seems like if you don't have the library which provide this function... :(
9th Jan 2017, 10:42 PM
visph
visph - avatar
+ 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
9th Jan 2017, 10:52 PM
visph
visph - avatar
+ 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...
9th Jan 2017, 10:40 PM
Norberttony
Norberttony - avatar