I started out creative coding on Processing, but lately I have been working with openFrameworks. While these two communities are pretty close I find that a lot of information pertaining to creative coding is spread across the internet, interspersed throughout blog posts, artist's websites and community forums. However, much of this information is relevant to any and all development platforms.
For example, If I want to have a sphere travel in an elliptical orbit, I might have to search the processing forums, the openFrameworks forums, stackOverflow as well as blogs. Couldn't this appear in a wiki as some subsection of animation?and perhaps have code snippets for the most popular frameworks?
Would it be valuable to have centralized wiki to collect and link all of these resources, or is this something better left to the respective communities?
I'm trying to connect to a MySQL database on a remote server using
Florian Jenett's Mysql library. However i feel as though the library is only meant to be used for local SQL databases. It seems as though even when I try to change the server it's still trying to connect to a local database.
SQL.connect(): Could not connect to the database ( jdbc:mysql://173.236.223.166:3306/evanliv_democ ).
java.sql.SQLException: Access denied for user 'democ'@'159.28.155.185' (using password: YES)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:798)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3700)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1203)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2572)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at de.bezier.data.sql.SQL.connect(Unknown Source)
at MySQL_example1.setup(MySQL_example1.java:55)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Is it possible to connect to a remote database with this library?
It's possible to auto arrange controls in a ControlGroup in ControlP5 and it's possible to have multiple ControlGroups in one window, but is it possible to auto arrange multiple controlGroups in one window?
I appreciate an help, I realize this is an esoteric question.
I'm attempting to break apart videos into their frames and save them as jpgs. I'd like to then work with each individual jpg. Hypothetically I will end up with hundreds of thousands of jpgs. Is there a way to programmatically add these files to the sketch folder. I really don't want to do this manually. It seems like I should be able to loop through a folder of files.
I'm generating probability tables for one color appearing to the right of another. I have accomplished all of this. I store the tables in objects which are created for each color value. My problem is, that when I generate a new image, I'd like to create pixel 0, then make a weighted random decision for the color that will appear to the right. I think my problem is that I'm trying to read data from image I'm constructing, and write to it in the same loop. I'm not sure how processing deals with this, and I seem to be getting strange errors, often, many of my pixels are black. I believe all of my problems are occurring the third time I loop through all of the pixels (lines 60-78), and try to write pixels to the new image.
you can see in the output of println statement the colors that should be written to the new image.
Is there something I'm missing?
This is the first time I've used classes and objects to code, so please forgive any clunkiness.
Thanks in advance for any help anyone can offer.
PImage src;
PImage dstn;
HashMap library;
int counter;
color d = (0);
color seed = (0);
color ds = (0);
void setup() {
library = new HashMap<Integer, Object>();
size(200, 200);
src = loadImage("sunflower.jpg");
dstn = createImage(src.width, src.height, RGB);
src.loadPixels();
int acc = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;
color d = src.get(x,y); // get pixel color at desired location
if (library.containsKey(d)) {
// Get the AColor object and increase the count
// We access objects from the library via its key, the String
AColor c = (AColor) library.get(d);
c.count(); // touch the counter everytime the a color is read
c.the_color(d); // add the color to the object
//c.output();
} else {
// Otherwise make a new entry in library
AColor c = new AColor(d);
// And add to the library
// put() takes two arguments, "key" and "value"
// The key for us is the String and the value is the AColor object
library.put(d, c);
} // all colors are in library now
AColor c = (AColor) library.get(d);
if (x < width - 1 ) { //If statement to ensure null pixles are not added to transition matrix
color z = src.get(x+1,y);
c.access_matrix_right(z);
} else { // this is a nasty shortcut that wraps the probability of the rightmost pixel to the leftmost pixel
color z = src.get(x,y);
c.access_matrix_right(z);
}
}
}
}
void draw() {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
color d = src.get(x,y);
AColor c = (AColor) library.get(d);
c.sort_matrix(); // add and construct all of the ArrayLists for each object
println("first loop");
}
}
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc1 = ((x + y*width));
color seed = src.get(x,y);
dstn.pixels[0] = seed;
color ds = src.get(x,y); // copy pixel 0 from src to dstn image
AColor c = (AColor) library.get(ds);
float chance;
int acc = 0;
chance = random(1);
float probAccum = (c.probs.get(acc));
while (chance > probAccum) {
acc++;
probAccum = probAccum + (c.probs.get(acc));
int colorToTheRight = c.colors.get(acc);
dstn.pixels[loc1] = colorToTheRight; // <-If I put this outside of the while lopp, the image is more or less normal looking.
HashMap<Object, Integer> matrix = new HashMap<Object, Integer>();
ArrayList<Float> probs;
ArrayList<Integer> colors = new ArrayList<Integer>(); //an ArrayList is used here. Perhaps it would be better to use an Array and iterate over the hashmap to set the length
AColor(int theColorTemp) {
theColor = theColorTemp;
count = 1;
}
void the_color(int theColorTemp) {
theColor = theColorTemp;
}
void count() {
count++;
}
void access_matrix_right(int colorRightTemp) {
colorRight = colorRightTemp;
if (matrix.containsKey(colorRight)) { // if library has entry for current pixel
int val = ((Integer) matrix.get(colorRight)).intValue(); //accumulator
matrix.put(colorRight, new Integer(val + 1)); // add 1 to
}
else {
matrix.put(colorRight,1); //adds entry & a value of 1 if entry does not exist
colors.add(colorRight);
}
}
void sort_matrix() {
probs = new ArrayList<Float>();
for (int i = 0; i <= colors.size()-1; i++) { //for number elements in list
probs.add((matrix.get(colors.get(i))) / count); // add element in array probs (number of occurrances of a color on the right/ total pixels on right )
I'm trying to take the RGB value of pixels make them into hashmaps, inside of a hashmap. However, I cannot figure out how to dynamically create hashmaps. I tried converting the hashmap to a string and then inserting it as a key in the master hashmap, but then I have not created a hashmap inside of the master.
There must be a way to do this
HashMap hm=new HashMap();
HashMap library=new HashMap(); // Master HashMap
PImage src;
PImage dstn;
void setup() {
size(10, 10);
src = loadImage("plus.jpg");
dstn = createImage(src.width, src.height, RGB);
}
void draw() {
color temp = (0);
src.loadPixels();
src.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;
color d = src.get(2,5);
dstn.pixels[loc] = color(d);
temp = d;
}
}
dstn.updatePixels();
image(dstn,0,0);
HashMap current_pixel = hm; // assign the current pixel a hashmap
if (library.containsKey(current_pixel)) { // if library has entry for current pixel
int val = ((Integer) library.get(current_pixel)).intValue(); //accumulator
library.put(current_pixel, new Integer(val + 1)); // add 1 to
}
else {
library.put(current_pixel,0); //adds entry & a value of 1 if entry does not exist
}
String neigh = "255,0,0"; // variable of neighbor pixel
if (current_pixel.containsKey(neigh)) { // if neighbor pixel is in hashmap -
int val = ((Integer) current_pixel.get(neigh)).intValue(); //accumulator
current_pixel.put(neigh, new Integer(val + 1));
}
else {
current_pixel.put(neigh,1); //adds entry & a value of 1 if entry does not exist