I'm playing around with Sonia to do some synthesis and am confused about the user of the Stream Size and Buffers. For example, what is the use of a line like this:
LiveOutput.start(streamSize,streamSize*2); // Start LiveOutput with a buffer.
I am working on a fractal koch snowflake, but I am having trouble getting the image to stay in the middle of the screen. I guess it has something to do with my translate commands, but I can't figure out what's going wrong.
int generations = 5;
int sideLen = 400;
String initiator = "F--F--F";
String fRule = "F+F--F+F";
float angle = PI/3;
void setup()
{
size(600, 600);
background(0);
stroke(255);
noLoop();
}
void draw()
{
// Move to starting position
int startX = width/2 - (sideLen/2);
int startY = height/2 + (sideLen/3);
translate(startX, startY);
String rules = generateState(initiator, 0);
// Map string to graphics
for (int i = 0; i < rules.length(); i++) {
turtleGraphics(rules.charAt(i));
}
}
// Take the initiator and number of generations and compute final state
String generateState(String initial, int generations) {
I am writing a 2D cellular automata that uses a 16x16 grid of objects. The objects are stored in a multi-dimensional array representing the grid. To calculate the values of the next generation, I need to check the state of the surrounding cells (either on or off). If the cell to be checked is at the edge of the grid, then I'd like to have the method wrap around the grid,
I am doing this using the method below method, but am running into problems using the modulo operator: