Discover the fun of creative coding with Processing as we explore how to make interactive shapes! 🖱️⚪ In this tutorial, we’ll learn how to draw a circle and change its color with a simple mouse click using the mousePressed() function. Perfect for beginners who want to add playful interactivity to their sketches and bring their creative ideas to life!
Steps are below:
Step 1: Setup: Start by setting up the canvas size using the size() function in the setup() function.
Step 2: Draw Function: Use the draw() function to draw shapes on the canvas.
Step 3: Set Background: Use the background() function to set the canvas color to white.
Step 4: Draw Circle: Use the ellipse() function to draw a circle at the center of the canvas.
Step 5: Change Color on Click: Use the mousePressed() function with fill(random(255), random(255), random(255)); to change the circle color whenever the mouse is clicked.
Step 6: Run the Code: Run the sketch and click on the window to see the circle change colors.
Please find the example code below: (Code starts with '/' and ends with '/')
/*
void setup() {
size(400, 400); // Set the canvas size
}
void draw() {
background(255); // Set background color to white
ellipse(200, 200, 100, 100); // Draw a circle in the center
}
void mousePressed() {
fill(random(255), random(255), random(255)); // Change circle color on click
}
*/
happy coding!!
#processingtutorial
#creativecoding
#learnToCode
#CodingBasics
#SetupAndDraw
#InteractiveArt
#VisualProgramming
#CodingWithKajal
#BeginnerFriendly
#ProcessingBasics
#CodeExploration
#AnimationTutorial
#InteractiveDesign
#DigitalArt
#ProgrammingFundamentals
#TutorialSeries
#CreativeProgramming
#ArtificialIntelligence
#AlgorithmicArt
#TechTutorial
#CodingEducation
#DigitalCreativity
#ArtAndTechnology
#CodingForArtists
#InteractiveGraphics
#CodeLearning
#ProcessingExamples
#CreativeDevelopment
#ComputerGraphics
#drawing
#DrawingWithProcessing
#animationtutorial
#drawingtechniques
#circle