|
Post by bluatigro on Jun 28, 2019 5:08:18 GMT -5
error : i get snow
WARNING : only crtl+alt+del stops this [/p][p]WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , hc , hDC winx = WindowWidth winy = WindowHeight nomainwin open "" for graphics as #m hw = hwnd( #m ) calldll #user32, "GetDC" _ , hw as ulong _ 'handle of window or graphicbox client area , hdc as ulong 'returns handle of Device Context - 0=failure #m "trapclose [quit]" #m "fill black" #m "backcolor white" #m "goto " ; winx / 4 ; " " ; winy / 4 #m "boxfilled " ; winx * .75 ; " " ; winy * .75 #m "up" do scan x = irange( 1 , winx - 2 ) y = irange( 1 , winy - 2 ) dx = irange( -1 , 1 ) dy = irange( -1 , 1 ) kl1 = getpixel( hDC , x , y ) kl2 = getpixel( hDC , x + dx , y + dy ) call setpixel x , y , kl2 call setpixel x + dx , y + dy , kl1 loop while Inkey$ = "" wait function irange( low , high ) irange = int( rnd(0) * ( high - low + 1 ) ) + low end function [quit] calldll #user32 , "ReleaseDC" _ , hw as ulong _ 'window handle , hdc as ulong _ 'device context , ret as long 'nonzero=success close #m end sub setpixel x , y , kl r = int( kl ) and 255 g = int( kl / 256 ) and 255 b = int( kl / 256 / 256 ) and 255 #m "color " ; r ; " " ; g ; " " ; b #m "goto " ; x ; " " ; y #m "down" #m "set " ; x ; " "; y #m "up" end sub function getpixel( hDC , x , y ) calldll #gdi32 , "GetPixel" _ , hDC as ulong _ , x as long _ , y as long _ , getpixel as ulong end function[/p][p]
|
|
|
Post by bluatigro on Jun 28, 2019 5:15:36 GMT -5
update : smal mistake solved now only a black screen
where is my suger lump ?
warning solved
WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , hc , hDC winx = WindowWidth winy = WindowHeight nomainwin open "" for graphics as #m hw = hwnd( #m ) calldll #user32, "GetDC" _ , hw as ulong _ 'handle of window or graphicbox client area , hDC as ulong 'returns handle of Device Context - 0=failure #m "trapclose [quit]" #m "fill black" #m "backcolor white" #m "goto " ; winx / 4 ; " " ; winy / 4 #m "boxfilled " ; winx * .75 ; " " ; winy * .75 #m "up" do scan x = irange( 1 , winx - 2 ) y = irange( 1 , winy - 2 ) dx = irange( -1 , 1 ) dy = irange( -1 , 1 ) kl1 = getpixel( hDC , x , y ) kl2 = getpixel( hDC , x + dx , y + dy ) call setpixel x , y , kl2 call setpixel x + dx , y + dy , kl1 loop while Inkey$ = "" wait function irange( low , high ) irange = int( rnd(0) * ( high - low + 1 ) ) + low end function [quit] calldll #user32 , "ReleaseDC" _ , hw as ulong _ 'window handle , hdc as ulong _ 'device context , ret as long 'nonzero=success close #m end sub setpixel x , y , kl r = int( kl ) and 255 g = int( kl / 256 ) and 255 b = int( kl / 256 / 256 ) and 255 #m "color " ; r ; " " ; g ; " " ; b #m "goto " ; x ; " " ; y #m "down" #m "set " ; x ; " "; y #m "up" end sub function getpixel( hDC , x , y ) calldll #gdi32 , "GetPixel" _ , hDC as ulong _ , x as long _ , y as long _ , getpixel as ulong end function
|
|
|
Post by bluatigro on Jun 28, 2019 5:41:16 GMT -5
update : 2e mistake solved
error : my lump does not desolve
WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , hc , hDC winx = WindowWidth winy = WindowHeight nomainwin open "" for graphics as #m hw = hwnd( #m ) calldll #user32, "GetDC" _ , hw as ulong _ 'handle of window or graphicbox client area , hDC as ulong 'returns handle of Device Context - 0=failure #m "trapclose [quit]" #m "fill black" #m "backcolor white" #m "goto " ; winx / 4 ; " " ; winy / 4 #m "down" #m "boxfilled " ; winx * .75 ; " " ; winy * .75 #m "up" do scan x = irange( 1 , winx - 2 ) y = irange( 1 , winy - 2 ) dx = irange( -1 , 1 ) dy = irange( -1 , 1 ) kl1 = getpixel( hDC , x , y ) kl2 = getpixel( hDC , x + dx , y + dy ) call setpixel x , y , kl2 call setpixel x + dx , y + dy , kl1 loop while Inkey$ = "" wait function irange( low , high ) irange = int( rnd(0) * ( high - low + 1 ) ) + low end function [quit] calldll #user32 , "ReleaseDC" _ , hw as ulong _ 'window handle , hdc as ulong _ 'device context , ret as long 'nonzero=success close #m end sub setpixel x , y , kl r = int( kl ) and 255 g = int( kl / 256 ) and 255 b = int( kl / 256 / 256 ) and 255 #m "color " ; r ; " " ; g ; " " ; b #m "goto " ; x ; " " ; y #m "down" #m "set " ; x ; " "; y #m "up" end sub function getpixel( hDC , x , y ) calldll #gdi32 , "GetPixel" _ , hDC as ulong _ , x as long _ , y as long _ , getpixel as ulong end function
|
|
|
Post by tsh73 on Jun 28, 2019 6:42:03 GMT -5
Hello bluatigro
Good news: your code is correct. Bad news: LB is too slow for your program to *visibly* work. (well, not exactly news) You don't see thing dissolve - just because there too many points, and mostly you get black over black or white over white - so nothing is visible.
Just try it with 300x300 pixel window.
I made some no-API version. It does work.
'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
|
|