Increments and multiplication question
in
Programming Questions
•
1 year ago
Hi there, I know this should be straightforward but I'm new to Processing and I've been tinkering with this code unsuccessfully for hours now and I'm in quite a muddle! Help would be greatly appreciated :)
I'm generating a sequence of images which I'd like to alter every 12 frames. I've attempted to do this in the code below using a conditional statement.
I've been trying to change the dL0 value in the line "data[loc0]=(byte)dL0++;" so that every time the image savename (sn) increases from 1 to 12 to 24 to 36 and so on, the dL0 value will increase incrementally with it.
ie if 12 frames have been written then increase the value of dL0 by 1 (so at 12 frames dL0's value would jump to 1, at 24 frames dL0's value would jump to 2 and so on)
I hope that in the code below I have provided all of the necessary lines to demonstrate the logic of my attempts so far:
public int sn = 1; // save name file number for file output
void draw() { // just to indicate that all of the code below is in draw
int a = 0;
int b = a++;// each draw the figure is increasing by 1 (if this line even works as it should! problem line??)
int dL0 = 0;
int dLi = 12 *b; // dLi dataLocIncrement is equal to 12 * the incremented value (12*1, 12*2, 12*3, etc)
if (sn>=dLi){ // i want data locs to jump every 12 frames!
data[loc0]=(byte)dL0++;
}
else {
data[loc0]=(byte)dL0;
}
sn++; //increase save name by increment of 1
I know this is probably overcomplicated, and most likely way off the mark, but if anyone can see through the mine field of faults in my logic here and point out what I should be doing I'd be very grateful.
Thank you! :)
I'm generating a sequence of images which I'd like to alter every 12 frames. I've attempted to do this in the code below using a conditional statement.
I've been trying to change the dL0 value in the line "data[loc0]=(byte)dL0++;" so that every time the image savename (sn) increases from 1 to 12 to 24 to 36 and so on, the dL0 value will increase incrementally with it.
ie if 12 frames have been written then increase the value of dL0 by 1 (so at 12 frames dL0's value would jump to 1, at 24 frames dL0's value would jump to 2 and so on)
I hope that in the code below I have provided all of the necessary lines to demonstrate the logic of my attempts so far:
public int sn = 1; // save name file number for file output
void draw() { // just to indicate that all of the code below is in draw
int a = 0;
int b = a++;// each draw the figure is increasing by 1 (if this line even works as it should! problem line??)
int dL0 = 0;
int dLi = 12 *b; // dLi dataLocIncrement is equal to 12 * the incremented value (12*1, 12*2, 12*3, etc)
if (sn>=dLi){ // i want data locs to jump every 12 frames!
data[loc0]=(byte)dL0++;
}
else {
data[loc0]=(byte)dL0;
}
sn++; //increase save name by increment of 1
I know this is probably overcomplicated, and most likely way off the mark, but if anyone can see through the mine field of faults in my logic here and point out what I should be doing I'd be very grateful.
Thank you! :)
1