(p5.dom is now part of p5js, no need to enable if using v0.10+). p5.dom library lets you use video, audio, webcam, input, and text.
Examples: Dom - Video
“Mouse Sketch” by Guillermo
https://openprocessing.org/sketch/519622
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
Move your f*cking mouse (duh).
A fork of My Sketch by Guillermo
CC Attribution ShareAlike
Mouse Sketch
xxxxxxxxxx
var x;
var m;
var n;
var o;
var p;
var diametroPupila;
var bocaAbierta;
function setup ( ) {
//We create a background declaring its dimensions: 900x500 pixels (horizontal x vertical, as always).
createCanvas (900,500);
}
function draw( ) {
//We'll tell it to give us a specific graphics speed in frames per second.
frameRate(240);
//Fixed variable for the diameter of the pupils and the opening of the mouth.
diametroPupila=2;
bocaAbierta = 10;
//Here we declare variables in order to be able to get different colors on different parts of the face depending on the mouse position.
m=map(mouseX,0,800,0,255);
n=map(mouseY,0,600,0,255);
o=255-n;
p=255-m;
q=map(0,254,0,255);
r=map(0,254,0,255);
//Colors for the background
background (o,m,p);
//Main face shape:
fill(0,0,0);
ellipse(mouseX,mouseY,60,70);
//These are the eyeballs:
//"White part"
noStroke();
fill(o);
ellipse(mouseX+11.5,mouseY-5,12,6);
ellipse(mouseX-11.5,mouseY-5,12,6);
//Iris
fill(255-o,255-m,m+p);
ellipse(mouseX+11.5,mouseY-5,6,6);
ellipse(mouseX-11.5,mouseY-5,6,6);
//Pupils
fill(0);
ellipse(mouseX+11.5,mouseY-5,diametroPupila,diametroPupila);
ellipse(mouseX-11.5,mouseY-5,diametroPupila,diametroPupila);
//Mouth
fill(255);
arc (mouseX,mouseY+17.5,25,bocaAbierta,0,PI);
//Nose
triangle(mouseX,mouseY-6,mouseX-3,mouseY+8,mouseX+3,mouseY+8);
//Eyebrows
noStroke();
arc (mouseX+13, mouseY-9,22,5,PI,TWO_PI);
arc (mouseX-13,mouseY-9,22,5,PI,TWO_PI);
//Headphones
fill(255-o,255-m,m+p);
arc(mouseX-30,mouseY,15,20,0.5*PI,1.5*PI);
arc(mouseX+30,mouseY,15,20,1.5*PI,2.5*PI);
noFill();
stroke(0);
arc(mouseX,mouseY-8,70,70,PI,TWO_PI);
//moustache
noStroke();
fill(255);
arc(mouseX,mouseY+15,38,5,PI,TWO_PI);
//beard
arc(mouseX,mouseY+30,10,15,0,PI);
}
Examples: Play - Synthesis - Microphone
p5.dom library lets you use video, audio, webcam, input, and text.
Examples: Dom - Video
See More Shortcuts