Jump to content

Processing on the Web

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
This tutorial is a brief intro to the Processing Language
and Processing.js (Processing ported to Javascript).

The Processing Language
Here is the opening paragraph from Processing.org
Processing is an open source programming language and environment for people who want to program images, animation, and interactions. It is used by students, artists, designers, researchers, and hobbyists for learning, prototyping, and production. It is created to teach fundamentals of computer programming within a visual context and to serve as a software sketchbook and professional production tool.

Below are 2 images where I use the Processing IDE to create a simple animation and execute it.

Posted Image

Posted Image

I have to say...
Processing is by far the easiest language I've tried, but it offers some awesome graphic capabilities.
The syntax is very easy to understand, just click Help -> Reference in the IDE or click the
Reference Tab at Extended Language (API) \ Processing 1.0

Posted Image


Processing.js (Processing Language ported to javascript)
Here is the opening paragraph from Processingjs.org
Processing.js is an open programming language for people who want to program images, animation, and interactions for the web without using Flash or Java applets. Processing.js uses Javascript to draw shapes and manipulate images on the HTML5 Canvas element. The code is light-weight, simple to learn and makes an ideal tool for visualizing data, creating user-interfaces and developing web-based games.
Processing.js runs in FireFox, Safari, Opera, Chrome and will also work with Internet Explorer, using Explorer Canvas.

Processing.js requires a few javascript files/libraries which can be downloaded here:
Processing.js

Posted Image


The commands available for Processing.js are slightly reduced and can be found here:
Processing.js. It you click the "toggle all" link on this page, it shows the Processing commands that are not available to Processing.js

Posted Image

Here is a simple website using the script I created above.

<!DOCTYPE html>

<html>

<head>

  <title>Debtboy's Processing Language Site</title>

  <script src="./js/init.js"></script>

  <script src="./js/processing.js"></script>

</head>


<body>

  <center>


  <h2>Debtboy's Processing Ported to Javascript Site</h2>


  <script type="application/processing" target="debtboy_canvas">

    float a = 0.0;

    float s = 0.0;

    PImage img1;


    void setup()

    {

      size(400,400);

      noStroke();

      frameRate(20);

      img1 = loadImage( "./images/debtboy_cow.jpg" );

    }


    void draw()

    {

      background(255);

      a = a + 0.04;

      s = cos(a)*2;

  

      translate(width/2, height/2);

      scale(s); 



      image(img1,-103,-90);

    }

  </script>

  <canvas width="300" height="300" id="debtboy_canvas"></canvas>

  <br></br>

  </center>

</body>

</html>


Note the javascript libraries in the <head></head> section:
  <script src="./js/[COLOR="red"][B]init.js[/B][/COLOR]"></script>

  <script src="./js/[COLOR="red"][B]processing.js[/B][/COLOR]"></script>

Note the simple script creating this neat graphical effect:
  <script type="[COLOR="red"][B]application/processing[/B][/COLOR]" target="debtboy_canvas">

    float a = 0.0;

    float s = 0.0;

    PImage img1;


    void setup()

    {

      size(400,400);

      noStroke();

      frameRate(20);

      img1 = loadImage( "./images/debtboy_cow.jpg" );

    }


    void draw()

    {

      background(255);

      a = a + 0.04;

      s = cos(a)*2;

  

      translate(width/2, height/2);

      scale(s); 



      image(img1,-103,-90);

    }

  </script


Note that the canvas object is used:
<[COLOR="red"][B]canvas[/B][/COLOR] width="400" height="400" id="debtboy_canvas"><[COLOR="red"][B]/canvas[/B][/COLOR]>


Here is a link to my website with the animation:
Debtboy's Processing Language Site


Below are a few website images (at different points) of the running animation:

Posted Image

Posted Image

Posted Image

Posted Image

I'm quite impressed by Processing and Processing.js capabilities. I'll be experimenting quite a bit with this language on my member website. It's very easy to understand and use which are sought after features for a lazy programmer like myself :D

If you haven't already... give Processing (Processing.js) a try. :thumbup1:

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
That is so cool! The animation on your site is very smooth. Nicely formated tutorial as well!

Why didn't you attach the images or upload them to your CC site (vs your Comcast site)?

+rep!

#3
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
love this tutorial *bookmark*
ive always been interested in canvas +rep
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#4
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
Very cool! +rep :D

#5
zeroradius

zeroradius

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,406 posts
Nice tutorial + rep

Does this offer any advantages over using something such as flash, other than the user not having to download flash to use it? Does it have capabilities that make it easier than making an animated gif or is it just somthing fun to do and not for serious production?
Posted Image

#6
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
Thanks everyone for the positive feedback :thumbup1:

zeroradius said:

Nice tutorial + rep

Does this offer any advantages over using something such as flash, other than the user not having to download flash to use it? Does it have capabilities that make it easier than making an animated gif or is it just somthing fun to do and not for serious production?
It's free/open and very easy to program, but you will
have to decide for yourself. ;)

#7
zeroradius

zeroradius

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,406 posts
I guess every thing is worth trying once (^_^)
Posted Image