+ 2

Why does this code not show a rectangle ? Please help does it have anything to do with p5.js.

https://code.sololearn.com/WL8Xtd7jEG1a/?ref=app

10th May 2017, 12:23 AM
Shedrick Williams
Shedrick Williams - avatar
20 ответов
+ 6
It doesn't for me... But it doesn't still show enough: add again some size to your createCanvas, or reduce the drawed rectangle ^^
10th May 2017, 4:25 AM
visph
visph - avatar
+ 6
But better way to do complete html: <!DOCTYPE html> <html> <head> <title>Page Title</title> <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/p5.js"></script> <script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/addons/p5.dom.js"></script> </head> <body> </body> </html>
10th May 2017, 4:32 AM
visph
visph - avatar
+ 5
@Utkarsh: It works, just with modifications I indicate previously ;)
10th May 2017, 3:37 AM
visph
visph - avatar
+ 5
@visph It isn't working in my device with those changes also , but by adding the links i provided worked without any changes . I think dom library is important to create canvas 🤔 edited : i am friendly with p5 , background() will work in setup() , but yeah the 10x10 canvas is really small the rect looked more like a dot (^^)
10th May 2017, 3:44 AM
Utkαrsh
Utkαrsh - avatar
+ 4
@shedric I see two function declaration but no invocation. what do you expect?
10th May 2017, 3:33 AM
Apel Mahmod
Apel Mahmod - avatar
+ 4
@Apel Mahmod: They are called by p5.js library ^^
10th May 2017, 3:34 AM
visph
visph - avatar
+ 4
I think your links are incomplete , you forgot to add the dom library of p5 , try using these <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/p5.js"></script> <script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/addons/p5.dom.js"></script> and one more thing there's an e missing in (createCanvas) you wrote - (creatCanvas)
10th May 2017, 3:36 AM
Utkαrsh
Utkαrsh - avatar
+ 3
check out this site: https://p5js.org/get-started/
10th May 2017, 1:03 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 3
I'm not user of p5.js, but with the link provided by @Ulisses Cruz, some tests and complementary searches, I can tell you have to do some changes to your code, to make it working: - syntax error ( creatCanvas instead of createCanvas ) in function setup()change - size of canvas too much little ( unit is pixels ^^ : 10x10 isn't enough ) - background() function seems to have effect only in draw() function, not in setup() ( strangely, fill() does ) - size of drawed rectangle null ( (2,2,2,2) draw a rectangle from dot 2,2 to dot... 2,2... so side size is zero :P ) function setup(){ createCanvas(100, 100); } function draw(){ background(255, 2, 2); fill(255, 255, 255); rect( 2, 2, 98, 98); }
10th May 2017, 3:23 AM
visph
visph - avatar
+ 3
Maybe a problem of support for not enough uptodate browsers/os :P
10th May 2017, 3:47 AM
visph
visph - avatar
+ 3
You have just to copy/paste... and almost try it by yourself is the best way to improve your skills ;)
10th May 2017, 3:49 AM
visph
visph - avatar
+ 3
You can copy: use the post menu ( right top corner of a post -- 3 vertical dots )
10th May 2017, 3:51 AM
visph
visph - avatar
+ 1
Are you trying to use the canvas to draw a rectangle?
10th May 2017, 12:35 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
Ok. I understand now that you are trying to use the p5.js module. It is not working because you did not reference it in your html. Add this line in the head of the html page: <script src="//cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/p5.js"></script>
10th May 2017, 12:43 AM
Ulisses Cruz
Ulisses Cruz - avatar
10th May 2017, 12:59 AM
Shedrick Williams
Shedrick Williams - avatar
+ 1
can you make the same program correctly for me then send it to me
10th May 2017, 3:48 AM
Shedrick Williams
Shedrick Williams - avatar
+ 1
i cant copy paste in this chat
10th May 2017, 3:50 AM
Shedrick Williams
Shedrick Williams - avatar
+ 1
not javascript i meant html
10th May 2017, 3:51 AM
Shedrick Williams
Shedrick Williams - avatar
+ 1
10th May 2017, 4:16 AM
Shedrick Williams
Shedrick Williams - avatar
0
i suck at javascript
10th May 2017, 3:50 AM
Shedrick Williams
Shedrick Williams - avatar