/*******************************************
* Test Program
* Kyle Kuepker
* 19 July 2010
*
* Simple Test Program To Draw Lines with
* Mouse
********************************************/
int array_max = 60;
int index_last = 0;
float shrink_index = 1.01;
int mx[] = new int[array_max];
int my[] = new int[array_max];
int mw[] = new int[array_max];
PImage reticle;
PFont fontA;
void setup()
{
size(400, 400);
reticle = createImage(11, 11, ARGB);
formReticleBullseye();
noCursor();
smooth();
noStroke();
fill(255, 150);
}
void draw()
{
background(50);
image(reticle, mouseX-5, mouseY-5);
if(mousePressed)
{
mx[index_last] = mouseX;
my[index_last] = mouseY;
mw[index_last] = 35;
index_last++;
}
for (int i = 0; i < array_max; i++)
{
mw[i] /= shrink_index;
if(int(mw[i]) < 1)
{
stroke(0);
fill(0);
}
else
{
noStroke();
fill(255, 150);
}
ellipse(mx[i], my[i], mw[i], mw[i]);
}
if(index_last == array_max)
{
index_last = 0;
}
}
/*************************
Form a reticle instead of a cursor
*************************/
void formReticleSquare()
{
for(int i=0; i < reticle.pixels.length; i++)
{
reticle.pixels[0] = color(255);
reticle.pixels[1] = color(255);
reticle.pixels[2] = color(255);
reticle.pixels[3] = color(255);
reticle.pixels[4] = color(255);
reticle.pixels[5] = color(255);
reticle.pixels[6] = color(255);
reticle.pixels[7] = color(255);
reticle.pixels[8] = color(255);
reticle.pixels[9] = color(255);
reticle.pixels[10] = color(255);
reticle.pixels[11] = color(255);
reticle.pixels[21] = color(255);
reticle.pixels[22] = color(255);
reticle.pixels[32] = color(255);
reticle.pixels[33] = color(255);
reticle.pixels[43] = color(255);
reticle.pixels[44] = color(255);
reticle.pixels[54] = color(255);
reticle.pixels[55] = color(255);
reticle.pixels[65] = color(255);
reticle.pixels[66] = color(255);
reticle.pixels[76] = color(255);
reticle.pixels[77] = color(255);
reticle.pixels[87] = color(255);
reticle.pixels[88] = color(255);
reticle.pixels[98] = color(255);
reticle.pixels[99] = color(255);
reticle.pixels[109] = color(255);
reticle.pixels[110] = color(255);
reticle.pixels[111] = color(255);
reticle.pixels[112] = color(255);
reticle.pixels[113] = color(255);
reticle.pixels[114] = color(255);
reticle.pixels[115] = color(255);
reticle.pixels[116] = color(255);
reticle.pixels[117] = color(255);
reticle.pixels[118] = color(255);
reticle.pixels[119] = color(255);
reticle.pixels[120] = color(255);
}
}
void formReticleBullseye()
{
for(int i=0; i < reticle.pixels.length; i++)
{
// Vertical Line
reticle.pixels[5] = color(255);
reticle.pixels[16] = color(255);
reticle.pixels[27] = color(255);
reticle.pixels[38] = color(255);
reticle.pixels[49] = color(255);
reticle.pixels[60] = color(255);
reticle.pixels[71] = color(255);
reticle.pixels[82] = color(255);
reticle.pixels[93] = color(255);
reticle.pixels[104] = color(255);
reticle.pixels[115] = color(255);
// Horizontal Line
reticle.pixels[55] = color(255);
reticle.pixels[56] = color(255);
reticle.pixels[57] = color(255);
reticle.pixels[58] = color(255);
reticle.pixels[59] = color(255);
reticle.pixels[60] = color(255);
reticle.pixels[61] = color(255);
reticle.pixels[62] = color(255);
reticle.pixels[63] = color(255);
reticle.pixels[64] = color(255);
reticle.pixels[65] = color(255);
// Circle
reticle.pixels[35] = color(255);
reticle.pixels[46] = color(255);
reticle.pixels[68] = color(255);
reticle.pixels[79] = color(255);
reticle.pixels[41] = color(255);
reticle.pixels[52] = color(255);
reticle.pixels[74] = color(255);
reticle.pixels[85] = color(255);
reticle.pixels[25] = color(255);
reticle.pixels[26] = color(255);
reticle.pixels[28] = color(255);
reticle.pixels[29] = color(255);
reticle.pixels[91] = color(255);
reticle.pixels[92] = color(255);
reticle.pixels[94] = color(255);
reticle.pixels[95] = color(255);
}
}
7.26.2010
Processing Sketch - Mouse Comet
Here is the first sketch i created. I call it Mouse Comet. Hit a mouse button to create a comet that follows your mouse cursor. Again, this was a quick test for me to get back into coding and thinking like a programmer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment