Make your nametag

My nametag, made with Processing

My nametag, made with Processing

Processing is a great way to learn basic concepts of programming by making cool graphics and games.  Because it’s a visually focused language, you can get started immediately – there’s nothing like seeing your code in action. When you’ve got some code working in a quick ‘sketch’, you can post your files to the web and your sketch is visible in any browser.

To get started you can download Processing from processing.org.
Once you’ve installed it, open a new sketch, paste in the code below, press the arrow button (Sketch->Run) see what appears:

ellipse(20,20,50,50);

Now copy the longer section of code below, run it and use it to make your nametag.

    1. Try pressing the keys B, W, and R to change the colour you’re using in your drawing.
  • Once you’re happy with the nametag you’ve created, press ‘S’ to save the file.
  • Now take a look at the code you used. How do you think it works? Don’t try to read everything, but see whether there’s anything in the code that you can decipher.

Here are some examples of what other students created:

Copy and run this code in Processing

void setup() {

size(480, 120);
smooth();
background(232,28,28);
}

void draw() {
if (mousePressed) {
fill(7,124,20);
} else {
fill(255);
}

if ((key == 'b') || (key == 'B')) {
fill(0);
}
if ((key == 'r') || (key == 'R')) {
fill(255,0,0);
}
if ((key == 'b') || (key == 'B')) {
fill(0);
}
if ((key == 'w') || (key == 'W')) {
fill(255);
}

ellipse(mouseX, mouseY, 20, 20);
}

void keyPressed() {
if ((key == 's') || (key == 'S')) {
save("mypicture.png");
}
}
Advertisements

3 thoughts on “Make your nametag

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s