Showing posts with label processing. Show all posts
Showing posts with label processing. Show all posts

Toxic Libs for Processing



ToxicLibs is an advanced Processing library that contains many functions and concepts for complicated coding problems.

Toxiclibs is an independent, open source library collection for computational design tasks with Java & Processing developed by Karsten “toxi” Schmidt (thus far). The classes are purposefully kept fairly generic in order to maximize re-use in different contexts ranging from generative design, animation, interaction/interface design, data visualization to architecture and digital fabrication, use as teaching tool and more.

Check out examples of Toxiclibs on OpenProcessing.org

Computational Columns



This work by Michael Hansmeyer is the result of software created in Processing. He developed a mathematical algorithm to subdivide and distort the faces of a 3D model of a traditional Doric column into a complex and crystalline forms. The software then slices the 3D model and cuts each plane on a laser cutter. The columns can indeed support weight, and are made without glue. This fabrication design is a unique progression of digital computer-aided methods when creating architectural and sculptural forms.




Hansmeyer's column stands nine feet tall, weighs about 2000 pounds, and is made out of 2700 1mm-thin slices of cardboard stacked on top of wooden cores. It contains somewhere between 8 and 16 million polygonal faces -- too complex for even a 3D printer to handle, according to Hansmeyer. "Every 3D printing facility we spoke to turned us down," he tells Co.Design. "Typically those machines can't process more than 500,000 faces -- the computer memory required to process the data grows nonlinearly, and it also gets tripped up on the self-intersecting faces of the column."

Slideshow on Fast Code Design

Project Page

Guest Speaker: Joshua Nimoy



Note: Lecture Starts at 1:50.

Joshua Nimoy gives talk about his personal and professional works of design, code and art. He speaks about the evolution of programming and creative coding by giving a personal tour of his portfolio ranging from early work to his latest. Josh's work ranges from gallery exhibited media artworks, physical computing, web, and camera vision projects, to his custom-built animation pipelines and graphic animation filters for advertising and film.

Josh uses many languages, frameworks and toolkits including processing, OpenFrameworks, and his own frameworks written from scratch.

Using a BOOLEAN Variable to Store a Button State

// button variables
int buttonw = 30;
int buttonh = 20;
int buttonx = 20;
int buttony = 50;

boolean buttonON = false;

void setup()
{
size(300, 300);
}

void draw()
{
if (buttonON) {
fill(180);
}
else {
fill(0);
}
rect(buttonx, buttony, buttonw, buttonh);
}


void mouseReleased()
{
if (insideRect(mouseX, mouseY, buttonx, buttony, buttonw, buttonh)) {

// there are multiple ways to write this operation
//1
buttonON = !buttonON;

//2
// buttonON = buttonON == false ? true : false; //

//3
// if (buttonON) {
// buttonON = false;
// }
// else {
// buttonOON = true;
// }
//
//
}
}


// boolean function returns either true or false
// if an x,y point is inside a rectanglular area
boolean insideRect(float px, float py, float rx, float ry, float rw, float rh) {
return px >= rx && px <= rx+rw && py >= ry && py <= ry+rh;
}







Painting App in Processing with Toggleable Menu

Here's some code to start creating a painting app in Processing. Hold down space to access a future "menu". You may code in a color picker, or other tools in this menu. Press 's' to save your image. It's a very simple framework, but it gives you a good base to start developing your own drawing applications.

Notice how we create a new PGraphics object to draw on, which makes it easy to add other elements to our app without affecting the pixels of the canvas.

// canvas object to draw on
PGraphics canvas;

// menu toggle;
boolean menu = false;

// background color
color bgcolor = color(190);


void setup()
{
size(500, 500);
// create new PGraphics that's the same size as our app
canvas = createGraphics(width, height, P2D);
}


void draw()
{
background(bgcolor);
// if mouse is pressed and the menu isn't on
if (mousePressed && !menu) {
// start canvas drawing
canvas.beginDraw();
// draw a line from the mouse position
canvas.line(mouseX, mouseY, pmouseX, pmouseY);
// end the canvas drawing
canvas.endDraw();
}

// display the canvas object
image(canvas, 0, 0);

// if menu is on, execute menu function
if (menu) {
menu();
}
}


void keyPressed() {
// if spacebar is pressed, toggle menu boolean
if (key == ' ') {
menu = true;
}
// if 's' key is pressed, save image to out.png
if (key == 's') {
canvas.save("out.png");
}
}


void keyReleased() {
// if spacebar is released, toggle menu boolean
if (key == ' ') {
menu = false;
}
}


// menu function
void menu() {
fill(0);
rect (20, 20, 50, 50);
// draw menu here, and do menu functionality
}