|
Post by tenochtitlanuk on Nov 9, 2022 17:37:17 GMT -5
Old hands on the Forum will know I do such processing with ImageMagick. Straight off the 'net I found this code line... convert 8872x6472.bmp +repage -crop 1000x1000 tiles\tile%04d.bmp worked for me from the command line. I use LB under Linux/Wine. LB can call ImageMagick ( see the examples on my website) But simpler to do it yourself directly. I create a 8872x6472.bmp colour gradient file. Image shows the images the above command created in a few seconds- all the possible tiles. Lots of help online for how to select a particular single tile... INCIDENTALLY- tsh73 (anatoly) beat me to giving a native LB code example. My immediate reaction was why not use UpperLeftX and UpperLeftY to offset the graphic window off-screen, but with my setup at least LB doesn't use negatives. And I had thought it did! EDIT Ninja'd by Anatoly...
|
|
|
Post by tenochtitlanuk on Nov 4, 2022 18:25:08 GMT -5
Makes a nice demo of color filling to call the floodfill dll after drawing te outline. Redrawing as radii is too slow to make this effective.
You need to run the code below to see it draw the shape, surround it with black then go through a cycle of HSV colours...
nomainwin
WindowWidth =800 WindowHeight =800
open "Polar graphics" for graphics_nsb as #wg
#wg "trapclose quit"
hw =hwnd( #wg) calldll #user32, "GetDC", hw as ulong, hdc as ulong
pi = 3.14159265 a =150
n = 9
global col$
#wg "down ; fill darkblue ; backcolor darkblue ; color 0 255 255 ; up ; size 1"
for theta =0 to 2 *pi step 0.001 r =a *( 1 +0.9 *cos( 8 *theta))_ *( 1 +0.1 *cos( 24 *theta))_ *( 0.9 +0.1 *cos( 200 *theta))_ *( 1 +sin( theta)) if theta >0 then #wg "down" call plot r, theta print r, theta scan next theta
#wg "backcolor 0 0 0" ' this is colour to fill WITH targetcolor = 0 +255 *2^8 +255 *2^16 ' bu *2^16 +gn *2^8 this is colour to fill out TO ie desired border
x =1 y =1
calldll #gdi32, "ExtFloodFill", hdc as ulong,_ x as long, y as long,_ targetcolor as long,_ _FLOODFILLBORDER as long, result as long ' ie fill out with black 'til cyan is met.. so black surrounds.
call delay 1000
for i =0 to 999 CC =int( 360 *rnd( 1)) call hsv2rgb i /1000 *359, 0.99, 0.99 ' hue 0-359, saturation 0-0.99, value 0-0.99 ' alters global col$ #wg "backcolor "; col$ ' this is colour to fill WITH targetcolor = 0 +255 *2^8 +255 *2^16 ' bu *2^16 +gn *2^8 this is colour to fill out TO ie desired border
x =int( 1 +600 *rnd( 1)) y =int( 1 +600 *rnd( 1))
calldll #gdi32, "GetPixel", hdc as ulong, x as long, y as long, pixcol as ulong
if pixcol <>0 then calldll #gdi32, "ExtFloodFill", hdc as ulong,_ x as long, y as long,_ targetcolor as long,_ _FLOODFILLBORDER as long, result as long ' ie fill out 'til this colour is met.. scan end if
call delay 20 next i
#wg "getbmp scr 0 0 800 800" bmpsave "scr", "hash.bmp"
wait
sub plot r, theta #wg "goto "; 400 +r *cos( theta); " "; 660 -r *sin( theta) end sub
sub quit h$ calldll #user32, "ReleaseDC", hw as ulong, hdc as ulong, ret as void 'release the DCclose #h$ close #h$ end end sub
sub delay sleeptime calldll #kernel32, "Sleep", sleeptime as long, ret as void scan end sub
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) end sub
function cosRad( t) cosRad =cos( t *pi /180) end function
function sinRad( t) sinRad =sin( t *pi /180) end function
|
|
|
Post by tenochtitlanuk on Nov 3, 2022 17:15:38 GMT -5
Happened on this on Wolfram Mathworld and just had to code it in LB! Code'll be on my website if you can't code polar coordinates!
|
|
|
Post by tenochtitlanuk on Oct 27, 2022 12:20:46 GMT -5
Did you follow the ReadMe 'alphaTestNotes.txt'?
What Pi OS do you have installed?
=== Raspberry Pi ===
Extract the lb5-353 folder to your home folder. cd to ~/lb5-353 Raspberry Pi - Use the rpi32-353 file: ./rpi32-353 lb5alpha.im
|
|
|
Post by tenochtitlanuk on Oct 19, 2022 14:21:10 GMT -5
Animated gif of result.. Looks better run in LB of course!
|
|
|
Post by tenochtitlanuk on Oct 18, 2022 16:08:20 GMT -5
We are coming up to the Fifth of November, when Brits celebrate with fire and fireworks. It has usually-forgotten origins in an attempt to overthrow a king ( hurray!) or Parliament ( Boo!) or Catholicism- but even further back in ancient autumn season celebrations. I decided to throw together a seasonal animation- set fire to a fuse which wanders round the screen but never crosses itself, and finally detonates. And use my own LB/JB fill routines so it would run on each platform, rather than the dll route.
Draw by hand a single-pixel wide trace in black on a near-black background without crossing- almost impossible 'cos you can't see the track. So, at first, use a colour like red. Yup, nice wiggly trace to the centre. Start a fill- and find it stops at some random place. Try drawing a 2-pixel trace. Now it stops somewhere and goes back to the reds it missed on its curtailed path! Do a bit of thinking and screen-magnifying.Ahah! It's a problem when you HAVE to fill diagonally. Von Neumann or Moore neighbourhoods to any one familiar with the Game of Life. So -rewrite my fill to include diagonal steps as well as vertical/horizontal. Nearly right- but there is still a hidden problem, especially if you allow thicker parts of the fuse... anyway..... here's a Zip file file which is a working version. Not optimised- I wanted a slow fuse! PS The zipfile name is a tribute to a song of my youth- dedicated to the downtrodden and oppressed of Watts and other ghettos...
|
|
|
atan2
Sept 26, 2022 11:45:30 GMT -5
Post by tenochtitlanuk on Sept 26, 2022 11:45:30 GMT -5
Just a nice graphic to confirm I CAN draw arcs reliably! Shades of Sauron's eye, with hgv colouring. This example was created with the arc-ends and radial centre marked. Wihout them and with more arcs drawn you get a smoother but less dramatic pic! This thread also led me to examine the dot.product method. Thanks, friends..
|
|
|
atan2
Sept 23, 2022 6:55:03 GMT -5
Post by tenochtitlanuk on Sept 23, 2022 6:55:03 GMT -5
Many of us have found atan2, which takes variables y and x and gives an angle, to be very useful. I know I've coded it myself, and seen/used versions by Chris Iverson /Anatoly /B+ /Steelweaver /Rod /etc. Trouble is it is only needed infrequently. Recently, playing with arcs, I realised there are two common algorithm /definition versions in circulation. Checking on wikipedia- atan2 I find there is little consistency across programming languages. Up to 8 versions can be considered to exist, depending on whether you regard angles as being measured clockwise or anti-clockwise, and from which axis/direction regarded as zero. And you can define atan2 as giving results in the range 0 to 2 pi, or from -pi/2 to +pi/2!! No wonder I've sometimes got weird results and had to do a bit of fiddling! Just another symptom of my aging brain!
|
|
|
Post by tenochtitlanuk on Sept 17, 2022 11:10:03 GMT -5
The double-spacing of the OP's code is an artefact that occurs if you cut/paste code from LB editor to the Forum. Especially if you mix Linux line ends and Windows line-ends. ) CR/LF or CR or LF are all used by different systems. The '_' expects the next line to immediately follow, not after an empty line, so it's not a LB bug.
Titus ( bluatigro) produces interesting code, but has a major vision problem, and English as a second language. Like you I suspect, I use spacing and indenting a lot to make code easier to follow. It is very different and difficult for the OP.
His contributions to the forums has been valued and has several times inspired me.
|
|
|
Post by tenochtitlanuk on Sept 10, 2022 11:28:06 GMT -5
Remids me of what I remember of the Sixties... perhaps the contra-rotating one will help you unwind...
|
|
|
Post by tenochtitlanuk on Sept 9, 2022 17:48:12 GMT -5
One of those fun things which take rather longer than you expect! Saw on the 'net an animation that is basically like a Moire pattern- two overlapping fans rotating. Screen grab ( static) below.
My immediate thought was to generate one 'fan'... ... and then superpose a second one using Xor drawing. Then repeat at various phases. BUT I'D FORGOTTEN- LB's xor-plotting doesn't work when you drawbmp an image onto a graphic window! So I tried it making each fan blade with LINES drawn by me via the Bresenham routine previously on Forum. Result- not surprisingly when you think about it- was messy and incorrect.. Then the light dawned. Result as below. Have put the code on my websitePS You can of course CONTRArotate the two 'fans'. As above both are clockwise. PS Don't stare at this too long!!
|
|
|
Post by tenochtitlanuk on Sept 3, 2022 16:27:42 GMT -5
Pretty easy to find....
|
|
|
Post by tenochtitlanuk on Aug 22, 2022 4:46:58 GMT -5
Could not resist coding a 'recreation' of a Dekatron Geiger counter- just love the neon glow. If you run it, the Dekatrons step at random intervals and you hear the 'click' Once past one thousand the electromechanical counter copes. I havent run it up to the available full 9 digit display- I'll be long-dead before it gets there! Will put a page on my website in the next couple of days. EDITDekatron Counter.
|
|
|
Post by tenochtitlanuk on Aug 19, 2022 8:36:44 GMT -5
Unfortunately the MCI calls don't work for me under Linux/Wine.
re Rod's comments in JB Forum- I'll certainly be playing with the wav-file being repeatedly created and used. In my experience audio clicks always are a decaying sin wave. Only the original electronic signal is a single logic-level pulse.
Incidentally we're heading towards a Geiger 'ratemeter'. A 'radiometer' was a lightweight paddle wheel that rotated when you shone a light on its vanes, whech were black on one side and white/silvered on the other, via heating effects and ( possibly) photon momentum effects.
|
|
|
Post by tenochtitlanuk on Aug 14, 2022 7:06:31 GMT -5
|
|