Basic Mouse rollover
in
Programming Questions
•
5 months ago
Hi I was wondering if anyone would be able help me with my code. I am a total beginner and I know this question must have been asked a thousand times. I have a horizontal graph with 100 lines and I just want each indivudial one to chance colour when the mouse rolls over it.
This is my code so far. I'd really appreciate if anyone could help me
Cell[][]grid;
//call x y position
int rowQty;
int x = 10;
int y = 550;
int rowQty;
int x = 10;
int y = 550;
int cols = 0;
int rows = 200;
int rows = 200;
float r = random(0, 300);
//spacing of colums
int spacing = 19;
//declare Y position spacing
int newSpacing = 5;
int newY = 24;
//spacing of colums
int spacing = 19;
//declare Y position spacing
int newSpacing = 5;
int newY = 24;
//Type of font used
PFont myFont;
void setup() {
//Declare the size of the canvas
size(screen.width, screen.height);
//Declare the size of the canvas
size(screen.width, screen.height);
//set size and font type
background(255);
background(255);
//display Image
PImage Key = loadImage("Key.png");
//Size of key image
Key.resize(400, 0);
//This positions the key image
image(Key, 600, 40);
//This loads the books image
PImage bookworm = loadImage("bookworm.png");
bookworm.resize(400, 0);
//This tints the books image
tint(255, 50);
image(bookworm, 1500, 105);
PImage Key = loadImage("Key.png");
//Size of key image
Key.resize(400, 0);
//This positions the key image
image(Key, 600, 40);
//This loads the books image
PImage bookworm = loadImage("bookworm.png");
bookworm.resize(400, 0);
//This tints the books image
tint(255, 50);
image(bookworm, 1500, 105);
//Display font type and font size
myFont = createFont("Times", 14, true);
textFont(myFont);
textAlign(RIGHT);
myFont = createFont("Times", 14, true);
textFont(myFont);
textAlign(RIGHT);
//Display csv file data
String dataLines[] = loadStrings("Book.csv");
//declare rows
rowQty = dataLines.length;
//Show the data within the csv file
String dataLines[] = loadStrings("Book.csv");
//declare rows
rowQty = dataLines.length;
//Show the data within the csv file
//States that book name is text
String[] Book;
//States that number is string
int[] Amount;
String[] Book;
//States that number is string
int[] Amount;
//declare the data types
Book = new String [rowQty];
Book = new String [rowQty];
Amount = new int [rowQty];
for (int i = 0; i < rowQty; i++) {
String[]temp= split(dataLines[i], ',');
Book[i] = (temp[0]);
Amount[i] = int(temp[1]);
}
for (int n= 0; n <rowQty; n++) {
// graph colour
fill(3, 255, 232);
rect(x, y, 20, -Amount [n]/.5);
x = x + spacing;
rotate(PI/-2);
//Book names colour
fill(#FF0000);
text(Book[n], -630, newY);
String[]temp= split(dataLines[i], ',');
Book[i] = (temp[0]);
Amount[i] = int(temp[1]);
}
for (int n= 0; n <rowQty; n++) {
// graph colour
fill(3, 255, 232);
rect(x, y, 20, -Amount [n]/.5);
x = x + spacing;
rotate(PI/-2);
//Book names colour
fill(#FF0000);
text(Book[n], -630, newY);
//Number text colour
fill (0);
fill (0);
text(Amount[n], -580, newY);
newY += newSpacing +14;
rotate(PI/2);
}
}
newY += newSpacing +14;
rotate(PI/2);
}
}
void draw() {
grid = new Cell[cols][rows];
for (int i = 0; i <cols; i ++) {
for (int j = 0; j < rows; j ++) {
grid = new Cell[cols][rows];
for (int i = 0; i <cols; i ++) {
for (int j = 0; j < rows; j ++) {
grid[i][j] = new Cell(i*10, j*10, 10, 10, i+j);
}
}
}
}
// values for columns and Rows
for (int i = 0; i <cols; i ++) {
for (int j = 0; j < rows; j ++) {
//oscilate and display each object
grid[i][j].oscillate();
grid[i][j].display();
}
}
}
for (int j = 0; j < rows; j ++) {
//oscilate and display each object
grid[i][j].oscillate();
grid[i][j].display();
}
}
}
1