Post by tenochtitlanuk on Apr 10, 2020 15:42:40 GMT -5
There have been interesting posts recently here and on JB forim about these programming exercises.
Flood filling algorithms written in LB are very slow.
Fills using triangles filled line-at-a-time are better. But many polygon shapes cannot be created with triangles from one point ( think in r-theta terms. You need polycorners with steady increase in theta)
Seems a bit like trying to do something because it CAN be done, rather than is NEEDED to be done this way ( in JB)
Why don't we encourage people to sample the ( free trial) LB and the ease of using the flood fill GDI call?
Also the debate about ways to produce large BMPs. I seldom go above 1000x1000, and am very happy at that size. Above it I can go to near 1920x1080 on my screen.
For even larger resolution I can go the route of getting screen as a bmp and using graphic print OR the technique not recently mentioned of dividing large image into say 500x500 tiles and drawing each, then stitching the bmp files together programmatically.
Anyway, couldn't resist this fill-demo.. I see interesting colour contours round this scary beast! ( Runs at this speed in LB)
You need a suitable black and white starter bmp, and may want to alter the target colour and the centre to fill from....
UpperLeftX = 1 UpperLeftY = 1
WindowWidth =400 WindowHeight =480
open "Fill Stars" for graphics_nsb as #wg
#wg "trapclose [quit]"
hw =hwnd( #wg) calldll #user32, "GetDC", hw as ulong, hdc as ulong
loadbmp "scr", "rabbit.bmp" #wg "down ; drawbmp scr 0 0" x =200 y =200
for i =1 to 50 scan r =int( 40 +216 *rnd( 1)) g =int( 40 +216 *rnd( 1)) b =int( 40 +216 *rnd( 1)) fillCol$ =str$( r) +" " +str$( g); " " +str$( b) #wg "backcolor "; fillCol$ targetcolor =0 ' this is the colour of the outline to fill out to.
calldll #gdi32, "ExtFloodFill",_ hdc as ulong,_ x as long,_ y as long,_ targetcolor as long,_ _FLOODFILLBORDER as long,_ ' ' ie fill out 'til this colour is met... result as long
calldll #kernel32, "Sleep", 100 as long, ret as void #wg "getbmp scr 0 0 400 480" bmpsave "scr", "aniRabbit" +right$( "000" +str$( i), 3) +".bmp" next i
[quit] calldll #user32, "ReleaseDC", hw as ulong, hdc as ulong, ret as void 'release the DC close #wg end
calldll #kernel32, "Sleep", 2000 as long, ret as void ' flood-fill the areas one at a time at 10/second."
for i =1 to 20 r =int( 256 *rnd( 1)) g =int( 256 *rnd( 1)) b =int( 256 *rnd( 1)) fillCol$ =str$( r) +" " +str$( g); " " +str$( b) if fillCol$ <>"0 0 0" then #w.gb "color "; fillCol$; " ; up ; backcolor "; fillCol$
xVar =int( 500 *rnd( 1)) yVar =int( 500 *rnd( 1)) targetcolor =0 ' this is the colour of the outline to fill out to.
calldll #gdi32, "ExtFloodFill",_ hdc as ulong,_ xVar as long,_ yVar as long,_ targetcolor as long,_ _FLOODFILLBORDER as long,_ ' ' ie fill out 'til this colour is met... <<<<<<<<<<<<<<<<<<<<<<<<<< result as long
calldll #kernel32, "Sleep", 100 as long, ret as void scan end if next i
Post by tenochtitlanuk on Mar 18, 2020 18:24:41 GMT -5
I wonder if it would look more realistic with toroidal geometry, ie going of one edge you reappear on the opposite one? But then I feel bouncing off the walls is metaphorically how the world feels to me at the moment...
Post by tenochtitlanuk on Mar 16, 2020 12:20:03 GMT -5
I used to love all sorts of cold-cathode devices. Nixies, but also Dekatrons, Magic-Eye volume indicators, and even the humble neon tube whose negative resistance made bistables and oscillators so easy.
Here's my Nixie clock- this one uses 'net images of real Nixies with supplementary LED neopixel illumination added!
sub hsv2rgb h, s, v ' hue 0-360, saturation 0-1, value 0-1 c =v *s ' chroma h =h x =c *( 1 -abs( ( ( h /60) mod 2) -1)) m =v -c ' matching adjustment
select case case h < 60 r = c: g = x: b = 0 case h <120 r = x: g = c: b = 0 case h <180 r = 0: g = c: b = x case h <240 r = 0: g = x: b = c case h <300 r = x: g = 0: b = c case else r = c: g = 0: b = x end select
rd = abs( int( 256 *( r + m))) gn = abs( int( 256 *( g + m))) bu = abs( int( 256 *( b + m))) col$ =right$( " " +str$( rd), 3) +" " +right$( " " +str$( gn), 3) +" " +right$( " " +str$( bu), 3)
Post by tenochtitlanuk on Mar 14, 2020 5:30:49 GMT -5
Great hearing of old 'LB friends' from way back- as well as seeing activity from new faces. I run LB under Linux, so needed to change a line to '#main "font Arial 6"' since Linux takes case of font names seriously! Nally's wireworld greatly impressed me when I first met it... I prefer to think of us as 'LB pioneer generation' ( was a comparatively late-comer on LB 1.4) rather than 'coronavirus at-risk generation'. LB will give me something to enjoy if I have to self-isolate!
Post by tenochtitlanuk on Mar 1, 2020 13:42:09 GMT -5
Colour fun is my favourite computer graphic activity. With its three variables my colour choice gave all the following when used with slightly different parameters on the RC XOR-pattern we had fun with some time back. rosettacode.org/wiki/Munching_squares