Tag Archives: processing

JavaScript – Processing.js 2D library – part 004.

The Processing.js is available for Linux, Mac OS X, and Windows and come with the last version 3.3.7 (13 March 2018).
Today I tested processing.js for android. They say us about this issue:
Use Processing for Android to create Android apps with ease, including live wallpapers, watch faces, and VR apps. You can run your Processing sketches on Android devices (phones, tablets, watches) with little or no changes in the code, and without worrying about installing SDK files or editing layout files. Processing for Android also lets you accessing the Android API to read sensor data, and exporting your sketch as a signed package ready to upload to the Google Play Store.
To use processing.js for android you need to follow this links:

They tell us about new android processing :
The version 4.0 brings several improvements to the Android mode, incuding new functionality for creating live wallpapers, watch faces, and VR apps.

Posted in All, Android, javascript, Processing.js, Programming. Tagged with , , , , .

JavaScript – Processing.js 2D library – part 003.

In this tutorial I will show you how to use images with processing.js.
You can use image from your computer or from url.
Let’s see one simple code example:

You can see same example on openprocessing web tool.
The openprocessing web tool allow you to use Processing.js and P5.js .

Posted in All, HTML 5, javascript, Processing.js, Programming. Tagged with , , , , , , , .

Website tool for processing language.

The Studio SketchPad aims to be a open studio for individuals learning to sketch beautiful code on the web canvas with  Processing and  EtherPad.
The default licensing adopted for the sketches are the Creative Commons Attribution-ShareAlike 3.0 Unported license.
Today I will come with this tutorial about hoe to use this tool.
First you need to open all three websites from this tutorial.
The Studio SketchPad come with a good web tool to test the Processing Visualization Language with Etherpad.
About Etherpad is a highly customizable Open Source online editor providing collaborative editing in really real-time.
Open your account from Studio SketchPad. From Home menu add your first new sketch from right top of the website. If the website come with the Untitled source code the run it. This will show you how is working.
The base of the processing code is two functions: setup and draw.
The setup function will set all you need to run the draw function.
Let’s see my code:

I put comments into my source code to understand some of the processing language functions.
The variable and math are simple. Variables have a global or local “scope”. for example variables declared outside of setup() and draw() are global variables.
NOTE: If a local variable is declared with the same name as a global variable, the program will use the local variable to make its calculations within the current scope.
You can see the result here and also you can search on my website similar tutorials with processing.

Posted in All, Processing.js, Programming, web. Tagged with , , , , , , , .

JavaScript – Processing.js 2D library – part 002.

In the last tutorials I told you about studio sketchpad.
Another way to working with processing is to run your script into html files.
If you want to download the processing then you can get it from processing website.
The download will come with an integrated development environment.
If you want to use your processing sketch then you need to make some changes because I will got errors with the IDE.
The changes I make to fix that is to put into the top of your sketch Ball ball001; and MovingBall mb001;.
See the source code.

The most of this features can be found here.

Posted in All, HTML 5, javascript, Processing.js, Programming. Tagged with , , , , , , .

JavaScript – Processing.js 2D library – part 001.

This is part 001 from tutorials series about Processing.js.
The javascript library Processing help us to create one good interface with our javascript.
This library come with many features to show into canvas data and infos and also to create 2D and 3D interfaces.
I used to show this features one online editor named studio sketchpad and can be found here
Using this online editor can help you but if you want to use all features then you need to put the library into your html file.
In this tutorial I just use the online editor and later will come with another tutorials about how to set the library.
Make one account of this online editor if you want to save your work.
The development is simple and has some rules.
The script will have two functions setup – for settings and draw – basically will draw the canvas.

This will fill with functions, statements and all the commands available to Processing.js.
Take a look at page references.
On the bottom of the script can also make classes.
This will be created like this:

As can we see classes comes without void and args ().
Let’s how it’s works classes by using two : Ball and MovingBall.
If you want to make one class and then you need to used then use this steps:
– create the class Ball;
– add two functions: update and display;
– add also the possition of the class by using two float variables x,y ;
– because any class need to have one instance then you need one,so put this instance into the class and named like the class Ball;
– this instance will need to take the possition and then to used so you need also two variables: _x and _y;
– if you want to show it then also you need a display function with some 2D/3D primitives;
Also the classes can be created not just to show you the 2D/3D primitives.
Let’s see the source code of this class named Ball.

Let’s make another class named MovingBall.
This class will be like the Ball class and will be extended by Ball class.
This means the all content of Ball class can be used or not by MovingBall.

This MovingBall has the MovingBall extends the Ball with _x,_y and also used super to reference the superclass of a subclass. Take a look where is put the variables x,y and _x,_y into the Ball and MovingBall.
The Ball will get _x,_y possitions and will give it to x,y, also the MovingBall will follow the same rules.
Now I will add one function to MovingBall named drawline, see:

This will set the sets the color used to draw lines and borders around shapes with stroke function and will make one line from x,y to 0,0.
When will run this function will have one line.
Let’s see the MovingBall class:

The first step when you want to using this library is to know how to set the canvas and how to change it.
The size of this canvas can be done with this function: size.
For example : size(400,400) means 400 pixels x 400 pixels.
The background can be change it with background() function and sets the color used for the background.
The smooth function will draw all geometry with smooth (anti-aliased) edges.
Because we want to draw something then you need to fill the setup and draw functions.
Also into setup function will put the new created classes and will used into draw function to draw.
Let’s see the final source code:

You can see my example here:

Posted in All, HTML 5, javascript, Processing.js, Programming. Tagged with , , , , , , .