|
Post by tsh73 on Jun 28, 2019 11:45:07 GMT
Along code posted by Bluatigro at LB forum'along 'suger lump desolve sim try' by Bluatigro 'tsh73, jun 2019 ' JB hardcore ' We ain't need no stinkin' API ' LOL ' just store points in array nomainwin open "sugar dessolve" for graphics_nsb_nf as #gr #gr "down" #gr "fill black" #gr "trapclose [quit]"
#gr "home" #gr "posxy cx cy"
'look at values '#gr "\";cx;" ";cy dim e(cx*2, cy*2) x1 = int(cx*2/3) y1 = int(cy*2/3)
#gr "place ";x1;" ";y1 #gr "boxfilled ";2*x1;" ";2*y1
for x = x1 to 2*x1-1 for y = y1 to 2*y1-1 e(x,y) =1 next next
'time test. Shows array filled instantly '#gr "place ";cx;" ";cy '#gr "circle ";30
#gr "rule xor" 'so pixel is inverted in single op (no color change needed) k = 0 while 1 x=int(rnd(0)*(2*cx-2))+1 'not to get out of array e y=int(rnd(0)*(2*cy-2))+1 dx=int(rnd(0)*3)-1 dy=int(rnd(0)*3)-1 'print dx, dy 'really -1 0 1 c1=e(x,y) c2=e(x+dx, y+dy)
if c1 <> c2 then 'only if color changes e(x,y)=c2 e(x+dx, y+dy)=c1 'because of XOR it is inverted #gr "set ";x;" ";y #gr "set ";x+dx;" ";y+dy end if
k = k+1 if k mod 1000 = 0 then scan #gr "discard" end if wend
wait
[quit] close #gr end
|
|