I am making a slider that changes the tint of an image. I looked some of the code from here
http://processing.org/learning/topics/scrollbar.html. However i want the slider to change according to a given min and max value in the constructor. In this case 0 to 255, and the slider needs to be relative to the screen size. This is how i did it, the screen size of 600 is the same as the max value of 255. Now 255 is the same as 100% of the width. Now i calculated this with a decrease ratio to get the same value of 255. However the calculation acts in a sort of Fibonacci style :). My question is can this be done with min() and max(). The slider need to be relative to the screen and the min, max values need to be 100%.
I just started learning processing (again), and now i have some questions. I have one class called Square and it draws squares when clicked and it stores them in an ArrayList. The ArrayList adds it's elements dynamically. Now i wanted to add PVector lines from one point to another. When i create two squares on different coordinates i want them to connect with a line. When i create three squares i want them all to be connected. So by my logic i stored the coordinates in point1 and point2. But i don't know how to do this, so help :). Here is the code:
This is my first post and as you might guess i am sort of new to processing. I made this code which has a array for storing values of 0 and 1 when the rectangle is clicked with the left or right mouse button. Values are added only if the arraylist is empty, but changed if the position has a value. As you might have noticed the rectangle is the entire 640, 480 screen. Here is the code:
import java.util.Collections;
int value; int cols = 13; int rows = 3; int sizeX, sizeY; boolean light = false;
void mousePressed() { if (mouseButton == LEFT) { value = 1; if (ledArray.isEmpty()) { ledArray.add(0, value); } else { ledArray.set(0, value); } println("Light is on " + value); fill(255, 0, 0); } if (mouseButton == RIGHT) { value = 0; if (ledArray.isEmpty()) { ledArray.add(0, value); } else { ledArray.set(0, value); } println("Light is off " + value); fill(0); } else { } //inverts the array list //Collections.reverse(ledArray); println("Array list:" + ledArray); println("Array size:" + ledArray.size()); println("------------------------"); }
This works fine (so far), but what i want to do is divide the screen. It must have 13 columns and 3 rows on screen. SizeX and sizeY give the distance needed between the rectangles. There are two things that i don't know how to do:
1. Even if i change the screen to another resolution the rectangles should divide across the screen (that's why i added sizeX and sizeY).
2. Each of the rectangles must store a value of 0 or 1 in the arraylist. So in total 39 values for the 39 rectangles. I really don't know how to do this.(if i go with a separate mouseX and mouseY postions i lose the dynamic sizing of the rectangles).
Rectangles == buttons :)