Im looking in to adding noise to get some nice natural variance to my designs but Im struggling a little to grasp it.
I have read the many forum posts and the reference etc, but I still a little unsure on whats actually going on!
heres a simple sketch I have with the noise function in use ,but the results show the radius of my circle getting larger AND smaller which is cool but Im not sure why?!
I have a sketch that focuses a of a small section of what someone is wearing.
I have loaded this into a PImage and have successfully displayed it in the corner of my sketch, now I want to take the data from the PImage and get a running average of the color data.
I could do with a little help!
Regards,
Oli
import hypermedia.video.*;
import java.awt.Rectangle;
OpenCV opencv;
// contrast/brightness values
int contrast_value = 0;
int brightness_value = 0;
int adv = 0;
PImage c;
int average;
int total = 0;
void setup() {
size( 320, 240 );
opencv = new OpenCV( this );
opencv.capture( width, height ); // open video stream
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"
I am building a project that (eventually) the user will be able to bat away balloons(it working by doing a hit test with the mouse atm),its not thrilling i know but I figured it would be a good exercise to help me work towards something a bit more interesting!
I have the ballon class working nicely, the balloons reappear once off the screen etc and the hit test works well, but when they are hit i want them to behave more like a real ballon.
I guess i need some kind of easing but not to sure how to implement it correctly.
I tried adding a targetX/Y variable and a bit of randomisation but i think due to where i placed the variable it kept looping round and changing the targetX making the movement really jittery!
Here my code I hope someone can help!!!
Regards,
Oli
PImage smile;
PImage ballon;
int numBalls = 10;
Ball [] balls = new Ball [numBalls];
void setup() {
size(500, 500);
smooth();
smile = loadImage("smile.jpg");
ballon = loadImage("teal.png");
for ( int i = 0; i < 10; i++) {
balls[i] = new Ball(random(width)+10, random(height)+10, int(random(30)+10));
}
}
void draw() {
image(smile, 0, 0);
//creates 10 different methods
for (int i = 0; i < 10; i++) {
balls[i].display();
balls[i].hit();
balls[i].move();
}
}
class Ball {
float x;
float y;
float d = dist(mouseX, mouseY, x, y);
int diameter;
Ball(float tempX, float tempY, int tempDiameter) {
x =tempX;
y = tempY;
diameter = tempDiameter;
}
//draws the ballon
void display() {
image(ballon, x, y);
}
//controls movement
void move() {
y+=2+random(0, 3); // drop speed
if (y > height + ballon.height) { // if drops off screen send to
y = 0 - ballon.height; // top - height.
x = random(width);
}
}
// check to see if the mouse is inside the image
void hit() {
if (dist(x, y, mouseX, mouseY) < ballon.height || dist(x, y, mouseX, mouseY) < ballon.width) {
I want to create an interactive projection with objects that move or disappear when triggered by motion;
I come from a max/msp background and still learning processing so I'm struggling a little,
What I need to know is the best way to approach this;
I need to load 100 images,
each image must be able to be effected independently of the other, (e.g if mouse over the object shrinks, grows, disappears etc but the other remain unchanged)
But obviously writing code to load 100 individual PImages etc is the wrong way to go about it!
Im thinking i need to write a
class and use an
array but I am struggling to get my head round how to do it.
If someone could post a little code or point me to a tutorial Id really appreciate it!!
Regards,
Oli
Heres my class but it need extending to fit my needs described above;
int numBalls = 6;
Ball [] balls = new Ball[numBalls];
void setup() {
size(500, 500);
smooth();
ellipseMode(RADIUS);
for (int i = 0; i < balls.length; i++) {
float x = random(width);
float y = random(height);
int diameter = int(random(100));
balls[i] = new Ball(x, y, diameter);
}
}
void draw() {
for (int i = 0; i <balls.length; i++) {
balls[i].display();
balls[i].hit();
}
}
class Ball {
float x;
float y;
float d = dist(mouseX, mouseY, x, y);
int diameter;
Ball(float tempX, float tempY, int tempDiameter) {
I am trying to get pixel data from my mouse location and then if the pixel value matches my
if statement it will trigger an event (in this case makes the ellipse red, woo hop!) this works BUT i was expecting a RGB value of either 0 (for the black areas) or 255 (for the white), instead i get -16777216 for black and -1 for white?
It is probably straight forward oversight on my part but whats confusing is according to the reference '
only RGB values are returned by this function.'
I hope someone would kindly shed some light on this for me.