The nifty little series of nested loops below gives a neat little (if extremely slow) effect. It scans the graph screen and randomly duplicates pixels in random directions.
Ill break it down for those that are confused and could learn from this, first it sets up the graphscreen by turning off all the annoying graphing overlays, the grid, axes and so on, then it starts the main loop which is never broken, Repeat 0. Then it starts 2 for loops in order to scan the screen, T represents the
Y coordinate currently being scanned and S represents X. Then it checks if the pixel at the current T,S coordinate is on, if so then it starts the next loop, the loop that duplicates the pixel. It first stores the coordinates of the current pixel as Y,X then it stores a random integer 1-3 into V. The next For loop randomly duplicates the pixel the amount of times that V was stored as. First in the V loop W is generated 1-9, this will decide which direction the duplicated pixel is placed in correlation to the old one.
If W is…1,2,3,4,5,6,7,8,9…then the next pixel will be…Down-Left,Down,Down-Right,Left,Same-Spot,Right,Top-Left,Top,Top-Right.
4 If-Then-End loops will change X and Y depending on the location of X and Y (so that a the next pixel wont exceed the domain) and W. After X,Y is changed it turns on the pixel X,Y.
You may have noticed the Pxl-On( command before the main loop, this is to make sure that there is at least one pixel thats turned on, as the loop cant duplicate whats not there. Draw different pictures and try it on them. Even to begin with the loop is slow, but is unimaginably slow when its just reading an area of black pixels, as it still overwrites pixels if there already on. Eventually it will produce an entire black screen. If you can see an optimization, which I'm positive that it can be optimized give me a private message on wikidot or email me at moc.xobni|sorlav#moc.xobni|sorlav so I can update the code below.
Post any comments below. Non-Derogatory
AxesOff
CoordOff
GridOff
PlotsOff
FnOff
Pxl-On(32,47
Repeat 0
For(T,0,62
For(S,0,94
If pxl-Test(T,S
Then
T->Y
S->X
randInt(1,3->V
For(Z,1,V
randInt(1,9->W
Y-(Y>0 and W>6)+(Y<62 and W<4)→Y
max(0,min(94,X-max(W={1,4,7})+max(W={3,6,9→X
Pxl-On(Y,X
End
End
End
End
End
Thanks go to burr for giving the boolean expressions that replace the inefficient If-Then loops that change the values of X and Y.