Playing with code

Learning code is really useful. Lots of employers are looking for people who can code their own websites and so learning basic skills is a very important thing. With this in mind, I have been asked to create some designs using an app called Processing. The Processing software is used by thousands of visual designers, artists, and architects to create their works.

Projects created with Processing have been featured at the Museum of Modern Art in New York, the Victoria and Albert Museum in London, the Centre Georges Pompidou in Paris, and many other prominent venues. Processing is used to create projected stage designs for dance and music performances; to generate images for music videos and film; to export images for posters, magazines, and books; and to create interactive installations in galleries, in museums, and on the street.

Some prominent projects include the House of Cards video for Radiohead, the MIT Media Lab’s generative logo, and the Chronograph projected software mural for the Frank Gehry-designed New World Center in Miami. But the most important thing about Processing and culture is not high-profile results – it’s how the software has engaged a new generation of visual artists to consider programming as an essential part of their creative practice.

void setup() {
  size(1920, 1080);
}

void draw() {
  if (mousePressed) {
    fill(0);
  } else {
    fill(255);
  }
  ellipse(mouseX, mouseY, 80, 80);
}

This program creates a window that is 1920 pixels wide and 1080 pixels high, and then starts drawing white circles at the position of the mouse. When a mouse button is pressed, the circle color changes to black.

Interactive programs are drawn as a series of frames, which you can create by adding functions titled setup() and draw() as shown in the code below. The setup() block runs once, and the draw() block runs repeatedly. Because the background() function is used only once, the screen will fill with lines as the mouse is moved.

void setup() {
 size(1920, 1080);
 stroke(255);
 background(192, 64, 0);
 }

void draw() {
 line(150, 25, mouseX, mouseY);
 }

The Processing variables mouseX and mouseY (note the capital X and Y) store the x-coordinate and y-coordinate of the cursor relative to the origin in the upper-left corner of the display window. When a program starts, the mouseX and mouseY values are 0. If the cursor moves into the display window, the values are set to the current position of the cursor. The mouse position is most commonly used to control the location of visual elements on screen.

void setup() {
 size(1920, 1080);
}

void draw() {
 background(204);
 if (mousePressed == true) {
 cursor(HAND); // Draw cursor as hand
 } else {
 cursor(CROSS);
 }
 line(mouseX, 0, mouseX, height);
 line(0, mouseY, width, mouseY);
}

The pmouseX and pmouseY variables store the cursor coordinates from the previous frame, but there is no built-in way to access the cursor values from earlier frames. At every frame, the mouseX, mouseY, pmouseX, and pmouseY variables are replaced with new numbers and their previous numbers are discarded. Creating an array is the easiest way to store the history of these values.

int num = 50;
int[] x = new int[num];
int[] y = new int[num];

void setup() { 
 size(1920, 1080);
 noStroke();
 fill(255, 102);
}

void draw() {
 background(0);
 // Shift the values to the right
 for (int i = num-1; i > 0; i--) {
 x[i] = x[i-1];
 y[i] = y[i-1];
 }
 
 x[0] = mouseX;
 y[0] = mouseY;
 // Draw the circles
 for (int i = 0; i < num; i++) {
 ellipse(x[i], y[i], i/2.0, i/2.0);
 }
}


		
Follow:
Share:

23 Comments

  1. 27/09/2018 / 4:39 pm

    My family every time say that I am wasting my time here at web,
    except I know I am getting knowledge daily by reading thes pleasant articles or reviews.

  2. 02/10/2018 / 1:53 pm

    I studied in a few faculties for performing.

  3. 04/10/2018 / 4:46 am

    I simply couldn’t go away your site prior to suggesting that
    I actually enjoyed the usual info a person supply on your
    guests? Is going to be again continuously in order to investigate cross-check new
    posts

  4. 04/10/2018 / 1:08 pm

    Very nice blog post. I absolutely love this site. Continue
    the good work!

  5. 04/10/2018 / 7:00 pm

    I have read so many posts concerning the blogger lovers however this paragraph is
    truly a pleasant article, keep it up.

  6. 05/10/2018 / 1:41 am

    What’s Going down i am new to this, I stumbled upon this I’ve discovered It absolutely useful and it has helped me out loads.
    I hope to give a contribution & assist other customers like its helped
    me. Good job.

  7. 05/10/2018 / 3:43 pm

    Hmm is anyone else encountering problems with the images on this blog loading?
    I’m trying to figure out if its a problem on my end or if it’s the blog.

    Any suggestions would be greatly appreciated.

  8. 06/10/2018 / 4:07 pm

    I believe everything published was actually very reasonable.
    But, what about this? suppose you were to create a
    awesome post title? I am not saying your information is not
    good., but what if you added something that makes people
    desire more? I mean Playing with code –
    tea and a pencil is a little plain. You could look at Yahoo’s front page and
    note how they create post headlines to grab viewers to click.
    You might try adding a video or a related picture or two to
    grab readers interested about what you’ve got to say.
    Just my opinion, it would bring your posts
    a little livelier.

  9. 07/10/2018 / 6:49 am

    What’s up, the whole thing is going sound here and ofcourse every one is sharing data, that’s in fact excellent, keep up writing.

  10. 07/10/2018 / 6:38 pm

    I would like to thank you for the efforts you have put in penning this website.
    I really hope to see the same high-grade content from you later on as well.

    In fact, your creative writing abilities has encouraged me to get my own, personal website now
    😉

  11. 07/10/2018 / 10:42 pm

    If some one wants to be updated with most up-to-date
    technologies therefore he must be go to see this web page and be up to date every day.

  12. 08/10/2018 / 2:50 am

    I like the helpful information you provide in your articles.
    I will bookmark your blog and check again here regularly. I
    am quite sure I’ll learn plenty of new stuff right here!

    Good luck for the next!

  13. 09/10/2018 / 3:50 am

    Thank you for some other informative web site. The place else may just I get that
    kind of information written in such a perfect approach?
    I have a undertaking that I am just now operating on, and I’ve been at
    the glance out for such information.

  14. 09/10/2018 / 3:36 pm

    Your way of telling everything in this article is really good, all be capable of without difficulty understand it, Thanks a lot.

  15. 09/10/2018 / 5:47 pm

    That is really fascinating, You’re a very skilled blogger.
    I’ve joined your rss feed and look forward to looking for more of your fantastic post.
    Also, I’ve shared your site in my social networks

  16. 09/10/2018 / 9:36 pm

    6. New York Academy for Performing and Film.

  17. 10/10/2018 / 8:11 am

    Wonderful items from you, man. I have take into accout your stuff prior to and you
    are simply too fantastic. I actually like what you have acquired
    right here, certainly like what you are saying and the way
    through which you say it. You’re making it entertaining and you
    continue to care for to keep it sensible. I can’t wait to
    learn much more from you. That is really a great website.

  18. 10/10/2018 / 8:16 am

    Undeniably consider that which you stated. Your favourite justification appeared to be on the net the easiest thing to understand
    of. I say to you, I definitely get annoyed at the same time as other people consider worries that they
    just do not recognize about. You controlled to hit the nail upon the top and also defined out the whole thing without having
    side-effects , other folks can take a signal.

    Will likely be again to get more. Thank you

  19. 10/10/2018 / 9:28 am

    Excellent site you have got here.. It’s hard to find high quality writing like yours nowadays.
    I seriously appreciate people like you! Take care!!

  20. 10/10/2018 / 9:44 am

    I love what you guys are usually up too. Such clever work and
    reporting! Keep up the good works guys I’ve added you guys to my blogroll.

  21. 19/10/2018 / 9:38 pm

    I read this article fully concerning the resemblance of most up-to-date
    and earlier technologies, it’s awesome article.

Leave a Reply

Your email address will not be published.