Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
charliebr
charliebr's Profile
2
Posts
14
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Mouse over on bar chart
[20 Replies]
12-Jul-2012 06:19 PM
Forum:
Programming Questions
Hello.
I need help doing a bar chart from a array of four numbers.
This is a simple example of a similar sketch i'm doing with a bar chart that reads the data from a cvs.
1. I want to do a mouse over each chart and the color changes individually;
1.1. Theres an if/else on the code, but i think i must create a for loop to do the over on each bar.
2. The next phase is when i click on each bar they fix on a color.
What i need to do to make topic 1 and 2.
Thanks
––––
float [] dados = {
100, 200, 150, 50
};
boolean barrasOver = false;
boolean locked = false;
color f=0;
//float x = 20;
float w = 50;
float espBarras = 10;
float yBarras = 0;
float xBarras;
void setup () {
size (600, 400);
background(255);
smooth();
}
void draw() {
barras (xBarras, w);
}
void barras (float xBarras, float w) {
for (int j=0; j < dados.length; j++) {
xBarras = xBarras + w + espBarras;
noStroke();
yBarras = 300 - dados[j];
fill(f);
rect(xBarras, yBarras, w, dados[j]);
overBarras();
}
}
void overBarras () {
if (mouseX > xBarras && mouseX < xBarras+w+espBarras) {
barrasOver = true;
if (!locked) {
f=200;
}
}
else {
f=0;
barrasOver = false;
}
}
Access image pixels
[10 Replies]
27-May-2012 07:12 PM
Forum:
Programming Questions
Hello i'm new to processing and i've no programming background.
I'm using processing to make things related to design.
So here is my question:
1. I want to analyse images accessing each pixel;
2. Store de RBG value of each pixel;
3. Calculate the average of each color value;
4. Fill the screen with the average color;
5. In the future i want the 2nd and 3rd most used colors too, but now i'm happy with one color;
I'm very basic with this language.
I've started with the code above and i want to develop it gradually if anyone can help.
Thanks
-----------------------
PImage img;
color [] imageColors;
void setup() {
size(533, 750);
background(0);
smooth();
img = loadImage( "almanaque.jpg");
}
void draw() {
loadPixels ();
img.loadPixels ();
// search each line and row of the image
for (int x=0; x < img.width; x++) {
for (int y=0; y < img.height; y++) {
int loc = x + y*img.width;
float r = red (img.pixels [loc]);
float g = green (img.pixels [loc]);
float b = blue (img.pixels [loc]);
}
}
}
«Prev
Next »
Moderate user : charliebr
Forum