Solid Lines (p5) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Solid Lines (p5)

How can I draw a solid line between my previous mouseClick and the next mouseClick. I have tried using pmouse but it still draws blobs. How can I achieve lines like Emma's Paint Project. https://code.sololearn.com/Wfy2pEgAdY91/?ref=app

1st Jun 2019, 6:41 PM
Clueless Coder
Clueless Coder - avatar
13 Answers
+ 11
why do you use mouseDragged and not mousePressed for instance?
1st Jun 2019, 7:23 PM
marjel101
marjel101 - avatar
+ 13
Perhaps could you add more color and different size of line...
1st Jun 2019, 7:54 PM
Laurent Chretien
Laurent Chretien - avatar
+ 12
☕__JavaScripter__💐 glad that works. 😃 You can also include a mouseReleased with the same code as the mousePressed. When i draw a line now and try a second line nothing appears on screen. The third line works again etcetera. You can avoid that with an added mouseReleased...
1st Jun 2019, 7:36 PM
marjel101
marjel101 - avatar
+ 11
☕__JavaScripter__💐 i’m not sure. I have the feeling that painting in the Y direction does not react as well as in the X direction. You can see that best when you draw a horizontal line (perfect) and a vertical line (there’s a delay). No idea why that is, but it could be a nice puzzle to solve... 🧐
1st Jun 2019, 7:49 PM
marjel101
marjel101 - avatar
+ 10
☕__JavaScripter__💐 also, i would put a position:fixed in your CSS for the canvas, so the screen doesn’t move when you drag your finger over the screen 😊
1st Jun 2019, 7:29 PM
marjel101
marjel101 - avatar
+ 9
okay, but see what happens if you use mousePressed and mouseReleased instead. Does that give the result you want?
1st Jun 2019, 7:27 PM
marjel101
marjel101 - avatar
+ 7
☕__JavaScripter__💐 okay, another ios issue probably 🤣🤣🤣🤣
1st Jun 2019, 8:16 PM
marjel101
marjel101 - avatar
+ 5
What else could you recommend for this app. I made this bored (again) and I'm wondering how I can improve it.
1st Jun 2019, 7:43 PM
Clueless Coder
Clueless Coder - avatar
+ 5
🤔 I don't notice a difference on my end
1st Jun 2019, 7:51 PM
Clueless Coder
Clueless Coder - avatar
+ 4
Because I thought mouseDragged drags the mouse across the screen, I thought mousePressed is stationary
1st Jun 2019, 7:25 PM
Clueless Coder
Clueless Coder - avatar
+ 4
It works!
1st Jun 2019, 7:26 PM
Clueless Coder
Clueless Coder - avatar
+ 4
I'm surprised that's all it took! Thanks!
1st Jun 2019, 7:26 PM
Clueless Coder
Clueless Coder - avatar
+ 4
Thank you for the help! I already have the result I want. I thought mousePressed was a stationery event while mouseDragged was not that's why I used it
1st Jun 2019, 7:31 PM
Clueless Coder
Clueless Coder - avatar