I was looking at one of my favorite sketches by Algirdas Rascius (
http://www.openprocessing.org/sketch/2256) in Processing v2.0, and noticed that it looks very different from how it did in Processing 1.5.1 and earlier.
I made a few changes to the syntax and function calls to match what's available in Processing v2.0, but the sketch still looks different -- and it seems like it's the blur that doesn't seem to work well in the PGraphics buffer.
Did the functionality of filter(BLUR) somehow change in Processing 2.0, or is there something else in this sketch that's not the same in Processing 2.0?
The code (kaleidoscope.pde), updated for Processing v2.0 as best as I can, is below (though to run it you'll need to get ColorPalettes.pde and ShapeGenerator.pde from the openprocessing site).
A few of us in Boston are starting a biweekly 'computer graphics' get-together, basically meaning that we get together to read about an algorithm, implement it, and subsequently geek out about the possibilities. Our second meeting will be on Wednesday February 20 at 369 Congress St (7th Floor); our reading will be the first 3 chapters of Daniel Shiffman's The Nature of Code.
Our general plan is to show up, show off any projects (if anyone has anything to share that resulted from the reading) followed by general hanging out / coding / getting help if your code didn't work.
Feel free to come by, and ask me for any questions if you want to know more!
So, your sketch finally works. You've spent hours and hours troubleshooting the underlying algorithm; you've minimized the number of loops, your code is clear and readable, and the end result is what you would expect from your algorithm.
But it still doesn't really, well, look like
art. What (simple, algorithm-agnostic) things do you try to turn your hard-earned algorithm into something beautiful to share?
From my own experience, two things come to mind:
1) Color palettes. I can't believe how many of my sketches have been utterly transformed by intelligently picking a color palette rather than just relying on high-contrast black / white / red / blue / green. Adding subtle shades and contrasts (and carefully selected colors) seems to go a long way.
2) Transparency and blur. Similarly, transparency (especially in dynamic sketches) and blur (in static ones) can smooth things out in a really aesthetically appealing way. It often takes away the edges of sharp computer-drawn shapes and can give them an aura or make them appear more organic.
What do you guys typically try? I'd love to learn some new tricks for making my sketches a bit more polished looking!
I'm working on a sketch to implement frieze groups as a class, with the class containing methods for each of the frieze transformations. This would allow me to easily generate many, many variations of freeze patterns based off of the seven simple transformations.
I wrote up a version using the code below, and it works -- except for the last transformation, spin_sidle().
spin_sidle() is the last line.
It should look like: \/ /\ \/ /\ \/ /\ \/ /\ \/ /\ \/ /\ \/ /\
but, as you can see, the spacing isn't quite right. The rotations get very tricky around here, because when you rotate by PI, translating forwards actually moves the image *backwards* down the line -- and I believe this is the root of my problem. However, I haven't found a neat, elegant solution to it yet.
Anyone have suggestions for how to implement spin_sidle elegantly? (I'll also take suggestions for implementing the others!)
code below:
//-----------------Globals
Frieze freeze = new Frieze(25.0, 50.0);
float ycounter = 0;
//-----------------Setup
void setup() {
size(1000, 800, P2D);
background(0);
stroke(255);
noFill();
smooth();
strokeWeight(3);
translate(0,freeze.cell_height);
for (int i = 0; i < 40; i++) {
freeze.hop();
}
translate(0, 2.0*freeze.cell_height);
freeze.current_pos = 0;
for (int i = 0; i <= 40; i++) {
freeze.step();
}
translate(0, 2.0*freeze.cell_height);
freeze.current_pos = 0;
for (int i = 0; i <= 40; i++) {
freeze.jump();
}
translate(0, 2.0*freeze.cell_height);
freeze.current_pos = 0;
for (int i = 0; i <= 40; i++) {
freeze.sidle();
}
translate(0, 2.0*freeze.cell_height);
freeze.current_pos = 0;
for (int i = 0; i <= 40; i++) {
freeze.spin_hop();
}
translate(0, 2.0*freeze.cell_height);
freeze.current_pos = 0;
for (int i = 0; i <= 40; i++) {
freeze.spin_jump();
}
translate(0, 2.0*freeze.cell_height);
freeze.current_pos = 0;
for (int i = 0; i <= 40; i++) {
freeze.spin_sidle();
}
}
//-----------------Defined Classes
class Frieze {
float cell_height;
float cell_width;
float current_pos;
int current_scale = 1;
float current_angle;
Frieze(float cell_width, float cell_height) {
this.cell_height = cell_height;
this.cell_width = cell_width;
}
void primitive() {
/*This is the primitive cell and should be added by extending this class*/
I'm trying to get Kinect to run on the newest Processing release (2b7) on Xubuntu 12.10. I installed everything as suggested by the SimpleOpenNi page (
http://code.google.com/p/simple-openni/) and it was very straightforward. However, if I run the DepthImage example from the library, the standard output reads:
count = 0 : 045e/02b0@1/8
SimpleOpenNI Version 0.27
and then no image shows up! However, there seems to be no error -- just no image at all. The green light is blinking on the kinect to show that its connected, and I can see the red beam scanning. But still no image :(
I went to the Samples and tried an OpenNi Sample (SimpleViewer) -- however, no image shows up there.
If I use 'sudo ./Sample-NiSimpleViewer' then I get the following error:
Read failed: A timeout has occurred when waiting for new data!
Read failed: A timeout has occurred when waiting for new data!
but I get a frame of the image! it then just suddenly stops. So it appears that at least part of the issue is one of permissions.
Any suggestions on how to troubleshoot this from here?
I'm working on a sketch that needs to do collision detection for hundreds (or possibly thousands) of particles, so in an effort to optimize it I decided to try a spatial partitioning algorithm. I was surprised that I couldn't find any good (simple) examples; everything was either O(n^2) collision detection or jumped straight to Quadtrees. I thought that something in the middle would be a good place to start, and hopefully a good example for others to learn from.
Here's the code:
class Grid {
float binSize;
int noBinsX;
int noBinsY;
ArrayList[] particleBuckets = new ArrayList[noBinsY];
Grid(float _binSize, int windowWidth, int windowHeight) {
However, getting things to work with the 2D ArrayList is a bit tricky. I'm currently stumped with an error occuring at line 33:
"The type of expression must be an array type but it resolved to ArrayList"
This seems to be because I can't use double indices for ArrayLists. Do I need to get() a sublist and then place the element in the subList? If that's the case, then do I need to replace the list with the new one also?
Is there a way to add a particle to a bin in-place, or is the only way to do it by copying the subarray and copying it back in?
I'm curious how people who do artistic/creative works manage their code.
Version control like git is great when you want to add features that will eventually be added to the main code -- but how do you deal with multiple variations of the same code that you want to save, perhaps with only just a line or two of code different between them? Or artistic works where changing a few parameters creates vastly different works -- how do you track which parameters give what results?
On September 28-29, 2012 Artisan's Asylum (a hacker/maker space located in Somerville, MA) is hosting a day-long workshop to introduce people to Processing!
The format of the class is to spend Friday evening getting the software downloaded and a (brief) introduction to Processing. Saturday will focus on a short-ish lecture to give everyone some basic ideas of Processing, followed by a few hours of project-based learning. By working through projects, participants will learn how to do various tasks in Processing.
The course can currently seat 12, though there's the potential to increase this total if there's interest. If you know anyone that is interested in learning Processing, please pass on the word :)
I'm writing a diffuse-react algorithm and am getting odd results. Right now I only have diffusion (no reaction or chemical sources), so that I would have some intuition for whether the results were correct (as a check on the code). However, the diffusivities seem to be very sensitive to odd behavior.
If the diffusivities (diffU and diffV) are set to be 0.1-0.4, then I get normal diffusion behavior:
However, if I set them to 0.5, I get /extremely/ odd behavior that seems to cause preferential diffusion towards (0,0).
Does anyone with experience in this algorithm have any suggestions?
I'm trying to make a 'falling' effect, such that an object simply translates down the screen. However, instead of the object falling, all I get is the object takes up the entire length of the screen.
The rest of the code essentially randomly places some ellipses (the aesthetic I'm eventually looking for is icicles) along the top of the screen, and the icicles slowly grow down. After a certain amount of time, I'd like them to 'detach' from the top of the screen and fall. The 'creep' works just fine, but the falling has some work to be done to it.
I'm not sure if I need a way to clear the screen in the fall() for loop, so that the icicles don't seem to streak down the screen, and I can't figure out why they're not detaching from the top. Any suggestions?
//-----------------Globals
Icicle icicle1;
Icicle icicle2;
Icicle icicle3;
int count = 0;
float delta = 0;
int numIce = 5;
Icicle[] ice = new Icicle[numIce];
//-----------------Setup
void setup(){
size(500,750);
background(255);
smooth();
noStroke();
for (int i = 0; i < ice.length; i++) {
ice[i] = new Icicle(color(0,0,255), random(width), random(0.25*height), 10);