How to "freeze" an array value

When my program runs, I want it to draw barriers at random locations ONCE and then continue to loop to allow to box to fall. The amount of barriers drawn is between 1 and 10 for each time the program is run.

I'm trying to make it so that the for loop in "createBarriers" only generates a single value for each barrier/circle. So when draw loops, it doesn't re-loop "createBarriers" and assign new x and y value to each barrier.

float x[] = new float [10]; float y[] = new float [10]; int x1 = 500; int y1 = 0; int size = 100;

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

void draw() { background(255); createBarriers();

box(x1, y1, 100); y1 = y1 + 10;

}

void circle(float x, float y, int w) { fill(0); ellipse(x, y, size, size); }

void createBarriers() { for(int n = 0; n < int(random(0, 9)); n++) { x[n] = random(0, width); y[n] = random(0, height); circle(x[n], y[n], 50);

}

}

void box(int x, int y, int size) { rectMode(CENTER); rect(x, y, size, size); }

submitted by /u/eks111
[link] [comments]

New to processing, Memory game.

Started recently trying to make a memory game in processing and after a while ended up confused. I look at it and can't quite see how I can get the cards to be displayed on screen, anyone mind steering me in the right direction.

Card [] cards; // Array of cards PImage [] icons; //Array of faces of cards PImage backOfCard; int rows = 2; int columns =13; boolean oneShowing =false; boolean twoShowing =false; int firstCard=-1, secondCard=-2; class Card { float x, y, w, h; int v, i; boolean faceUp, hide; Card(float ix, float iy, float iw, float ih, int iv, int ii) { x=ix; y=iy; w=iw; h=ih; v=iv; i=ii; faceUp=false; hide=false; } } void setup() { size(770, 250); backOfCard= loadImage("cBack.png"); cards = new Card[26]; icons = new PImage[13]; int [] values = new int [26]; for (int i=0; i<icons.length; ++i) { icons[i] =loadImage("ace_h.png"); icons[i] =loadImage("two_h.png"); icons[i] =loadImage("three_h.png"); icons[i] =loadImage("four_h.png"); icons[i] =loadImage("five_h.png"); icons[i] =loadImage("six_h.png"); icons[i] =loadImage("seven_h.png"); icons[i] =loadImage("eight_h.png"); icons[i] =loadImage("nine_h.png"); icons[i] =loadImage("ten_h.png"); icons[i] =loadImage("jack_h.png"); icons[i] =loadImage("queen_h.png"); icons[i] =loadImage("king_h.png"); values[2*i] =i; values[2*i+1] =i; } for (int i=0; i<values.length; ++i) { int r = int(random(values.length)); int t = values[i]; values[i] = values[r]; values[r] = t; } int counter = 0; for (int i=0; i<4; i++) { for (int j=0; j<4; j++) { cards[counter] = new Card (20+115*j, 20+140*i, 105, 130, values[counter], counter++); } } noStroke(); }//end setup void mouseClicked() { if (twoShowing) { if ( cards[firstCard].v == cards[secondCard].v) { cards[firstCard].hide = true; cards[secondCard].hide = true; println("Matched"); } for (int t=0; t<cards.length; cards[t++].faceUp=false); oneShowing = false; twoShowing = false; println("NotMatching"); return; } }//end mouseClicked void draw() { background(0, 255, 0); for (int t=0; t<cards.length; cards[t++].draw ()); fill(0); if (!hide) { if (!faceUp) { image(backOfCard, x, y); } else { image(icons[v], x, y); } noFill(); stroke(255, 0, 0); if (mouseOverCard()) { stroke(0, 0, 255); rect(x, y, w, h); } } } 
submitted by /u/AzurZero980
[link] [comments]

[PWC12] Pac Man

Hello Everybody, this is the twelfth Weekly Processing challenge, the challenges are decided just to give you a prompt to test your skills so it can be as simple or as complicated as you have time to write!

Start Date : 30-05-2016 End Date : 05-06-2016

Entries must be submitted with the [PWC12] In the Title of their post. Or post them in the comments here with the same tag. This Weeks Challenge : Pac Man , I am not expecting a fully functional game so if you are a beginner just try to implement a circle moving around on arrow keys, or try to recreate the opening and closing of the mouth.

Winner from last week: u/Salanmander

submitted by /u/seoceojoe
[link] [comments]

Performance-driven Fabrication

15_syuko_structure_basement_05
Syuko Kato and Vincent Huyghe, Fabricating Performance

arabesq6
Syuko Kato and Vincent Huyghe, Fabricating Performance

Syuko Kato and Vincent Huyghe from the Interactive Architecture Lab have designed a robotic system that turns dance into architectural forms.

Fabricating Performance could maybe also be called Performing Fabrication because of the way the dancing and the building processes inform and respond to each other. The design proposal aims to explore the potential of digitalised notation for implementing fabrication of physical space from imagery of dance movement.

A circularity of human body-gesture and computer machine-gesture leads to the construction of notational spatial artefacts. Driven by the motivation of a participating performer/designer, body movement is tracked, analysed and translated into tool paths for fabrication by a robotic armature and an industrial CNC pipe bending machine. Discrete construction elements are fabricated in response to the dancer/designers performance. ’Fabricating Performance’ qualifies movement in space and raises questions of how these qualitative motion segments can be articulated in a quantitatively physical.

The videos documenting the project are mesmerizing. They reminded me a bit of Lillian and Frank Gilbreths’ chronocyclegraphs. In the early 20th century, the couple employed time-lapse photography to pare a complete factory work cycle down to the shortest and most efficient sequence of gestures. They attached a camera to a timing device and photographed workers performing various tasks. The motion paths traced by small lamps fastened to the worker’s hands or fingers were then turned into wire sculptures.

Interactive Architecture Lab, Fabricating Performance

Syuko Kato, Fabricating Performance

If you’re interested in performance, interactivity and architecture, then you might want to keep your eyes peeled for the projects that will come out of MArch Design for Performance and Interaction, a new masters programme at The Bartlett School of Architecture. I’m already looking forward to see how creatively future students and graduates will use the latest innovations in fabrication and in networked and responsive technologies.

In the meantime, i’ve had a quick chat with Syuko Kato and Vincent Huyghe about their project. The interview even features special guest appearances of Interactive Architecture Lab director Ruairi Glynn.

Hi Syuko and Vincent! What were the biggest challenges you encountered while developing this work?

Syuko: Once we’d managed to capture live movement, the question was how do we translate it into a notion that describes paths and intent with a simple line. We wanted those translations to also start to describe habitable spaces so there’s a lot of filtering and rationalisation in the software. We began with a very analogue dance investigation. Movements were described through terms such as weight, flow, speed, length and then we built it up from there.

Vincent: The bigger, longer term challenge is how do you fabricate notional elements quickly enough to create on continuous performance. We need an array of robots and bending machines if we wanted the fabrication to keep pace with a dancer. So at the moment working with just one robot, there’s a mismatch between dance and fabrication but it’s a gap we’re tightening every day.

11.-whole-set-robot-and-bending-machine_s
Bending system whole view

Does FP leave any space for the involvement of a human choreographer (other than the dancer)?

Ruairi: That’s an interesting question, we haven’t got that far with this project but that’s certainly something we’re expecting to do. Having choreographers work in a team on an interaction project is always interesting because typically a choreography is linear. Here however the spatial notation is emergent out of a back and forth process we can’t fully control or predict. So every dance, and every space it creates is unique. Luckily in the past we’ve been able to work with great choreographers like Shobana Jeyasingh & the RAMS team from YCAM who embrace this non-linearity.

Syuko: This kind of tool invites people from all sorts of disciplines to explore movement and design. It doesn’t have to be a staged dance performance. It could be about our every day movements. It would be interesting to see it used to design a bus stop or to allow children to design a playground. If dance and movement can convey a design intent, it opens up people’s ability to express themselves spatially.

Fabricating Performance also made me think about the growing role of algorithms and robots in creativity. The works of some visual artists, for example, relies heavily on the ‘creativity’ and actions of algorithms. What do you think about this increasing space that algorithms and robots are taking in creativity?

Syuko: Dance has been codifying movement algorithmically for a very long time. Laban’s notional system for example has its own rules (or algorithms) that inspired a lot of our early discussions on how to analyze movement.

The translations of complex movement to simplified geometries is a translation where a lot of information gets lost but rather than see that as a negative thing we think it opens up room for individual interpretation, play and creativity. So the emergent properties of the system is where the creativity springs out of this in a way that leaves you as a dancer feeling like you’re dancing with a partner rather than on your own.

Ruairi: We now have 10 industrial robots arms at the Bartlett, and dozens of Makerbots. Its extraordinary how robotics is changing the way we think about design and making architecture but the typical approach is to treat the robot as the end of a linear process of design to fabrication. Basically big dumb blind machines doing what we tell them to do. So what we’re interested in is challenging that model moving from linear to circular feedback processes of production. Interaction in fabrication is a really rich untapped territory.

jambbbbbe1
Syuko Kato and Vincent Huyghe, Fabricating Performance

penchee03
Syuko Kato and Vincent Huyghe, Fabricating Performance

Syuko, you are also a dancer. So what did Fabricating Performance teach you as a dancer? About movement, human body, choreography or other?

Syuko: At each stage of the research process, I developed more understandings toward the design space in relation to my body. I’ve watched the software’s evaluation of the movement data a lot, and this helped me to decide how I would move to try and develop a space I had in my mind. Once the space starts to build up, you stop thinking about your original idea and respond more to what is around you. As I gained more experience, it became more of a free flowing and creative process.

Thanks Syuko, Vincent and Ruairi!

Help with controlling the compression amounts in live video export.

Hiya everyone!

I am currently working on an interactive art project that would require the ability to have a video feed go from a high fidelity feed to a lossy feed and then back to the high fidelity feed.

Basically I want to assign depth values to compression rates using a Kinect and raspberry pi. However, I am a little lost on how I would best go about achieving control over video output compression rates.

Any ideas?

Thanks!!!

submitted by /u/gnomegardener
[link] [comments]

[PWC11] Newton’s Cradle

Unfortunately I don't quite have the brain-space today to work out an easing function to make the physics of this more realistic.

float Theta, LeftTheta, RightTheta; float range = radians(45); float Delta = 1.0; void setup() { size(800, 450); Theta = HALF_PI + range; } void draw() { background(0); stroke(255); line(200, 50, 600, 50); for (int i=0; i<3; ++i) { line(300+(100*i), 50, 300+(100*i), 300); ellipse(300+(100*i), 300, 100, 100); } if (Theta > HALF_PI) { LeftTheta = Theta; RightTheta = HALF_PI; } else { LeftTheta = HALF_PI; RightTheta = Theta; } line(200, 50, cos(LeftTheta)*200+200, sin(LeftTheta)*200+50); ellipse((cos(LeftTheta)*250)+200, (sin(LeftTheta)*250)+50, 100, 100); line(600, 50, cos(RightTheta)*200+600, sin(RightTheta)*200+50); ellipse((cos(RightTheta)*250)+600, (sin(RightTheta)*250)+50, 100, 100); if ((Theta > HALF_PI) && (Theta < HALF_PI + range)) { Theta += radians(Delta); Theta = Theta % TWO_PI; } if ((Theta < HALF_PI) && (Theta > HALF_PI - range)) { Theta += radians(Delta); Theta = Theta % TWO_PI; } if ((Theta >= HALF_PI + range) || (Theta <= HALF_PI - range)) { Delta *= -1.0; Theta += radians(Delta); Theta = Theta % TWO_PI; } } 
submitted by /u/ChuckEye
[link] [comments]

Looking for ways to switch between multiple sketches during VJ set

Newbie here, have been experimenting with Processing 3 over the last few months with incremental progress.

My first VJ set is happening in a few months and I'm trying to figure out how to switch between multiple sketches. I looked into the Mother library and it seems to be out of date. Has anyone here had success switching between sketches quickly for a live audience?

submitted by /u/foodfyte
[link] [comments]