It wasn't what I expected, it appeared as though that Evan, being the tutor for this, wanted to have a break all the time. The first break was meant to be 10 minutes but turned into 45 minutes, so I was just roaming around trefforest campus like a lost sheep thinking they'd all gone to a different room or something. Then there was an hour from lunch and another 15 minute break. So all in all, it was only a 3 hour tutorial.
His work is super interesting though. He uploads a lot of his sketched to http://openprocessing.org/ which, also contains hundreds of thousands of 'sketches' as their called.
I wouldn't say I particularly learned alot, which has put me in a bit of a situation that I can't find myself getting out of.
What I did learn to do though, was make a star. and in order to do that, you configure you're code to allow you to draw using vectors, what you want to see on the screen;
I'd like to emphasise that they drawing tool itself is simple, but MY GOD the code isn't!
// simple drawing program that spits out code to draw the shape
// press spacebar to clear, or 'p' to print out drawing code
ArrayList verts = null;
PVector currentVert = null;
float maxDistToVert = 10; //max distance between mouse and a vertex for moving
void setup()
{
size(320,240);
// this will hold out drawing's vertices
verts = new ArrayList();
}
void draw()
{
background(0);
noFill();
stroke(255);
// draw the shape - do it twice, once with points
if (verts != null && verts.size() > 0)
{
beginShape();
for (int i=0; i<verts.size(); i++)
{
// get the current vertex and cast it to PVector
PVector v = (PVector)verts.get(i);
// add it to our shape
vertex(v.x, v.y);
}
endShape(CLOSE);
// now draw points using ellipses
for (int i=0; i<verts.size(); i++)
{
// get the current vertex and cast it to PVector
PVector v = (PVector)verts.get(i);
// add it to our shape
ellipse(v.x, v.y, 4,4);
}
}
// highlight and current verts
if (currentVert != null)
{
stroke(0,255,0);
ellipse(currentVert.x, currentVert.y, maxDistToVert, maxDistToVert);
}
}
void mousePressed()
{
// Find the closest point to the mouse, and
// see if the mouse if over it.
// What we do here is keep track of the
// closest point, and the distance between the mouse and that point.
// To start, we have no closest point, and we set the distance between
// the mouse and the closest point to something as large as possible
// so that we are guaranteed to find a point that is closer.
float bestDistance = MAX_FLOAT; // something really, impossibly really big
PVector closest = null;
PVector mousePos = new PVector(mouseX, mouseY);
// find the distance to each point, and
for (int i=0; i<verts.size(); i++)
{
PVector v = (PVector)verts.get(i);
float vertDist = mousePos.dist(v);
if (vertDist < bestDistance)
{
closest = v;
bestDistance = vertDist;
}
}
// Did we find a closest point? Then keep track. Otherwise, add a point.
if (closest != null && bestDistance < maxDistToVert)
{
currentVert = closest;
}
else
{
verts.add(new PVector(mouseX, mouseY));
currentVert = null;
}
}
void mouseReleased()
{
// Now we know no vertex is pressed, so stop tracking the current one
currentVert = null;
}
void mouseDragged()
{
// if we have a closest vertex, update it's position
if (currentVert != null)
{
currentVert.x = mouseX;
currentVert.y = mouseY;
}
}
void keyPressed()
{
if (key == 'p' || key =='P')
{
// prnt out drwaing code
println("beginShape();");
for (int i=0; i<verts.size(); i++)
{
PVector v = (PVector)verts.get(i);
println("vertex(" + v.x + ", " + v.y + ");");
}
println("endShape(CLOSE);");
}
else if (key == 'd' && currentVert != null)
{
verts.remove(currentVert);
currentVert = null;
}
else if (key == ' ')
{
verts.clear();
currentVert = null;
}
}
Then we draw a star as told, and then given the co-ordinates
size(200,200);
fill(0);
//the co-ords for the shape you wish to be shown like on your sketch
beginShape();
vertex(173.0, 163.0);
vertex(65.0, 69.0);
vertex(201.0, 62.0);
vertex(98.0, 137.0);
vertex(128.0, 42.0);
endShape(CLOSE);
//this adds text to the screen
text("this is a star!", 100, 30);
