Hi there, I need some help. I'm fairly new to the whole processing thing and am trying to write a script that takes a grid in a 600x600 screen and analyses the number of black pixels there are in each grid square.
The final aim is to take the numerical value and extrude the grid square into 3 dimensions with a height that is dependant on the number of black pixels found in the square.
From looking around the internet I'm guessing that 'blobscanner' is the library to use, however I'm not sure how to apply the pixel count to an array.
Any help would be so very appreciated. The code as it stands is as below....
import Blobscanner.*;
Tile [][] grid;
//number of rows and columns
int cols;
int rows;
PImage img;
void setup() {
img = loadImage("scan - 067.png");
size(600, 600);
background(img);
cols=width;
rows=height;
//the array dimensions are equal to n.of rows/columns
grid = new Tile[cols][rows];
//loop through cols and rows
for (int i=0; i<cols; i++) {
for (int j=0; j<rows; j++) {
//initiate objects
grid[i][j] = new Tile (i*15, j*15, 60, 200);
}
}
}
void draw() {
noFill();
for (int i=0; i<cols; i++) {
for (int j=0; j<rows; j++) {
//display the grid
grid[i][j].display();
}
}
}
void keyPressed(){
if(key == 'g'){
grid[4][4].black();
}
}
The tile class is as follows:
class Tile {
float x, y;
float side;
int col;
Tile (float tempX, float tempY, float tempSide, int tempCol) {
Hi again, only me. So, I was wondering if anyone could help me with how you go about converting a java sketch to javascript. I want to run it on the web. When i change the button on the top right from standard to javascript and then run it, the page appears as a blank grey page...... :(
This is going to be the death of me. If anyone could help that'd be swell...FANX!
HELP! I'm having some problems with the screen size of my processing sketch. It's too big to fit on the screen and with the amount of co-ordinates that i've put into it i'm hoping there is a simple way, that I haven't thought of, to export to a better resolution to fit the screen or something like that anyway?
I thought about putting it onto the openprocessing website but it only accepts javascript and I've done it in Java. When trying to convert it, it just goes blank. I'm a complete n00b at this so any help would be much appreciated. I'll post my script below......THANKS!
PImage bg;
PImage img;
// array, that stores if ellipses should be drawn or not
boolean[] ellipseToggle = new boolean[6];
void setup() {
size(2362, 945); //size always goes first
smooth();
// no loop of draw needed, because nothing is animated
noLoop();
bg = loadImage("Map2 dwg.jpg");
background(bg);
// Create the font
textFont(createFont("Helvetica", 12));
img = loadImage("Deprivation Map 1.jpg");
noLoop();
}
void draw() {
// clear background
background(bg);
tint (255, 126); //Display at half opacity
fill (243, 112, 34, 190);
stroke (243, 112, 34, 190);
ellipse(27, 47, 20, 20);
rect (1230, 30, 10, 20);
tint (255, 126); //Display at half opacity
fill (244, 193, 15, 190);
stroke (244, 193, 15, 190);
ellipse(27, 77, 20, 20);
rect (1230, 60, 10, 20);
tint (255, 126); //Display at half opacity
fill (63, 200, 26, 190);
stroke (63, 200, 26, 190);
ellipse(27, 105, 20, 20);
tint (255, 126); //Display at half opacity
fill (33, 112, 12, 190);
stroke (63, 200, 26, 190);
ellipse(27, 135, 20, 20);
tint (255, 126); //Display at half opacity
fill (01, 126);
stroke (01, 126);
rect (1230, 90, 10, 20);
tint (255, 126); //Display at half opacity
fill (159, 28, 227, 126);
stroke (159, 28, 227, 126);
rect (1230, 120, 10, 20);
tint (255, 126); //Display at half opacity
fill (25, 154, 236, 126);
stroke (25, 154, 236, 126);
rect (1230, 150, 10, 20);
fill(01);
text("Locations Targeted During Riots", 47, 50);
text("Number of Rioters at Locations During Riots", 1250, 50);
text("Locations of People Arrested over Riots", 47, 80);
text("Number of People Arrested During Riots", 1250, 80);
text("Number of Reports by International Newspapers", 1250, 110);
text("Number of Reports by National Newspapers", 1250, 140);
text("Number of Reports by Local Newspapers", 1250, 170);
text("Reported by International Newspapers", 47, 170);
SO, I'm a complete n00b when it comes to processing, only been working at it for a a day or so now, but i've come a cropper trying to write a script in which the 'QWERT' keys turn on an ellipse, but I can't get them to turn off. I want to have it so by pressing the same key again the respective ellipse is turned off. I've posted my code below. I have the feeling this is really simple, but any help would be much appreciated......THANKS!