-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSonicPainterJavaScript.pde
More file actions
75 lines (53 loc) · 1.57 KB
/
Copy pathSonicPainterJavaScript.pde
File metadata and controls
75 lines (53 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//The MIT License (MIT) - See Licence.txt for details
//Copyright (c) 2013 Mick Grierson, Matthew Yee-King, Marco Gillies
Maxim maxim;
void setup()
{
size(600, 600);
maxim = new Maxim(this);
player = maxim.loadFile("");
player.setLooping(false);
player.volume(0.45);
background(0);
rectMode(CENTER);
textSize(24);
text("Draw on the screen to get started", 10, 30);
}
//void draw()
//{
//
//}
void mouseMoved()
{
player.play();
float red = map(mouseX, 0, width, 0, 255);
float blue = map(mouseY, 0, width, 0, 255);
float green = dist(mouseX,mouseY,width/2,height/2);
float speed = dist(pmouseX, pmouseY, mouseX, mouseY);
float alpha = map(speed, 0, 20, 0, 5);
//println(alpha);
float lineWidth = map(speed, 0, 10, 10, 1);
lineWidth = constrain(lineWidth, 0, 10);
noStroke();
fill(0, alpha);
rect(width/2, height/2, width, height);
stroke(red, green, blue, 255);
strokeWeight(lineWidth);
strokeCap(ROUND);
//rect(mouseX, mouseY, speed, speed);
//line(pmouseX, pmouseY,mouseX, mouseY);
//brush1(mouseX, mouseY,speed, speed,lineWidth);
//brush2(mouseX, mouseY,speed, speed,lineWidth);
//brush3(mouseX, mouseY,speed, speed,lineWidth);
//brush4(pmouseX, pmouseY,mouseX, mouseY,lineWidth);
brush5(pmouseX, pmouseY,mouseX, mouseY, lineWidth);
//brush6(mouseX, mouseY,speed, speed,lineWidth);
//brush7(pmouseX, pmouseY,mouseX, mouseY,lineWidth);
player.setFilter(map(mouseY,0,height,50,5000),10);
player2.ramp(1.,1000);
player2.speed((float) mouseX/width/2);
}
void mouseReleased()
{
player2.ramp(0.,1000);
}