P5.JS Drawing App
I need help creating a Paint App using P5.JS in Visual Studio Code(VSC).
USE CONSTRUCTOR FUNCTIONS TO MAKE ALL OF THESE TOOLS!.
Please use the code below as an example of what I want.
Please name the tools clearly
The app should include:
-
Undo Button
-
Redo Button
-
Copy Button
-
Paste Button
-
Text Box (like Microsoft Paint.)
-
Eraser with a Slider(Slider disappears when clicked on another tool.)
-
Background Fill (Fill the Background with the colour
//CODE STARTS HERE
function FreehandTool(){
//set an icon and a name for the object
this.icon = "assets/freehand.jpg";
this.name = "freehand";
//to smoothly draw we'll draw a line from the previous mouse location
//to the current mouse location. The following values store
//the locations from the last frame. They are -1 to start with because
//we haven't started drawing yet.
var previousMouseX = -1;
var previousMouseY = -1;
this.draw = function(){
//if the mouse is pressed
if(mouseIsPressed){
//check if they previousX and Y are -1. set them to the current
//mouse X and Y if they are.
if (previousMouseX == -1){
previousMouseX = mouseX;
previousMouseY = mouseY;
}
//if we already have values for previousX and Y we can draw a line from
//there to the current mouse location
else{
line(previousMouseX, previousMouseY, mouseX, mouseY);
previousMouseX = mouseX;
previousMouseY = mouseY;
}
}
//if the user has released the mouse we want to set the previousMouse values
//back to -1.
//try and comment out these lines and see what happens!
else{
previousMouseX = -1;
previousMouseY = -1;
}
};
}
// CODE ENDS HERE
Thank you
Very cool drawing app. It’s great that this can be used for sketches for tattoos. I’m interested in everything related to this. And I found the source, which became my personal guide in the world of tattoos https://ctmtattoo.com/ For me it is a source of inspiration and interesting ideas. I can always find the best tattoo artists and bright options for tattoos.
Hi, you can choose the right option which will be helpful for you. So choose it according to your requirements. For more details check https://hanumanchalisalyrics.net/hanuman-chalisa-lyrics-in-telugu/ and get the best information.
Please post it as a request so mentors can see it :)