cours processing 1.21 # principe de mouvement souris avec inertie

l’on peu crée des curiosités dans le suivi du curseur …

changez  la valeur de la variable “inertie”  pour voir

float

 

C
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
///////////////////////////////////////////////////////////
///////////////////////// http://www.ebooki.fr 2012////
////////////////////////////////////////////////////////////
float x;
float y;
float inertie= 0.01;
void setup()
{
size(600, 360);
background(100);
}
void draw()
{
float objectifX=mouseX;
float objectifY=mouseY;
x=x+(objectifX-x)* inertie;
y=y+(objectifY-y)* inertie;
background(100);
smooth();
fill(0, 0, 255);
strokeWeight(30);  //
stroke(255,0,0);
ellipse(x, y, 100, 100);
stroke(0, 255, 0);
line(x-100,y,x+100,y);
}

cours processing # 1.3 dessin simple + interaction souris x y + Clics

En plus du mouvement X Y du mulot il y’a des boutons sur une souris !

mousePressed  , int   ( encore un truc inutile mais bon…)

C
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
///////////////////////////////////////////////////////////
///////////////////////// http://www.ebooki.fr 2012////
////////////////////////////////////////////////////////////
//couleur Fill
int rFill=0;
int vFill= 0;
int bFill= 255;
//couleur Stroke
int rStroke=255;
int vStroke= 0;
int bStroke=0;
//couleur Line
int rLine=0;
int vLine= 255;
int bLine=0;
void setup()
{
size(600, 360);
background(100);
smooth();
}
void draw()
{
//clic=0;
background(100);
// smooth();
fill(rFill, vFill, bFill);
strokeWeight(30); //
stroke(rStroke,vStroke,bStroke);
if (mousePressed == true)
{
// si clic modif les couleurs
rFill=255;
vFill= 255;
bFill= 0;
rStroke=0;
vStroke= 255;
bStroke=255;
rLine=255;
vLine= 0;
bLine=255;
}
else{
// si non
rFill=0;
vFill= 0;
bFill= 255;
rStroke=255;
vStroke= 0;
bStroke=0;
rLine=0;
vLine= 255;
bLine=0;
}
ellipse(mouseX, mouseY, 100, 100);
stroke(rLine, vLine, bLine);
line(mouseX-100,mouseY,mouseX+100,mouseY);
}