Board Logo
« Spark Discharge »

Welcome Guest. Please Login or Register.
Sep 23rd, 2017, 3:13pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 veryhotthread  Author  Topic: Spark Discharge  (Read 407 times)
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3089
xx Spark Discharge
« Thread started on: Aug 21st, 2017, 11:02am »

Anyone got any code examples of a multipath spark discharge simulation. You know the kind of thing, mini lightning strike between two electrodes?
User IP Logged

bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: Spark Discharge
« Reply #1 on: Aug 21st, 2017, 3:24pm »

Hot summer night back in the hills of Ohio...

Code:
'recurring lightning.txt for JB (B+=MGA) 2017-08-21

global H$, XMAX, YMAX
H$ = "gr"
XMAX = 800
YMAX = 600

nomainwin

WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200 - XMAX) / 2
UpperLeftY = (700 - YMAX) / 2
ttl$ = "press or click any to quit.";space$(65);"Heat Lightning..."
open ttl$ for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "when leftButtonUp lButtonUp"
#gr "when characterInput charIn"
#gr "down"
#gr "fill black"
#gr "size 1"  'or 2?

call drawLandscape
#gr "getbmp land 0 0 ";XMAX;" ";YMAX
#gr "background land"


while 1
    scan
    #gr "drawsprites"
    call pause 65      '<< adjust time as needed for your system
    scan
    call hue 0, 0, 0
    call fbox 0, 0, XMAX, YMAX
    rPause = rand(30, 2500)
    call pause rPause
    rStop = rand(1, 4)
    xo = rand(.25*XMAX, .75*XMAX)
    yo = rand(0, .35*YMAX)
    for i = 1 to rStop
        scan
        xe = rand(0, XMAX)
        ye = rand(0, .5 * YMAX)
        dist = distance(xo, yo, xe, ye)
        d = rand(.3 * dist, .9 * dist)
        call Lightning xo, yo, xe, ye, d
    next
    call pause 30
wend

function rand(lo, hi)
    rand = int((hi - lo + 1) * rnd(0)) + lo
end function

sub Lightning x1,y1,x2,y2,d
    scan
    if d < 5 then
        call hue 225, 225, 245
        call aline x1,y1,x2,y2
    else
        mx = (x2+x1)/2
        my = (y2+y1)/2
        mx = mx + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        my = my + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        call Lightning x1, y1, mx, my, d/2
        call Lightning x2, y2, mx, my, d/2
    end if
end sub

sub drawLandscape
    'the sky
    call hue 180, 200, 220
    call fbox 0, 0, XMAX, YMAX

    'the land
    startH = YMAX - 200
    rr = 70 : gg = 70 : bb = 90
    for mountain = 1 to 6
      Xright = 0
      y = startH
      while Xright < XMAX
        ' upDown = local up / down over range, change along Y
        ' range = how far up / down, along X
        upDown = (rnd(1)*.8 - .35) * (mountain *.5)
        range = Xright + rand(15, 25) * 2.5/mountain
        for x = Xright -1 to range
          y = y + upDown
          call hue rr, gg, bb
          call aline x, y, x, YMAX
        next
        Xright = range
      wend
      rr = rand(rr - 15, rr) : gg = rand(gg - 15, gg) : bb = rand(bb - 25, bb)
      if rr < 0 then rr = 0
      if gg < 0 then gg = 0
      if bb < 0 then bb = 0
      startH = startH + rand(5, 20)
    next
end sub

function distance(x1, y1, x2, y2)
    distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
end function

sub aline x0, y0, x1, y1
    #gr "line ";x0;" ";y0;" ";x1+1;" ";y1+1  'add 1 to end point
end sub

sub fcirc x, y, radius
    #gr "place ";x;" ";y;"; circlefilled ";radius
end sub
sub hue r, g, b 'fore and back
    #gr "color ";r;" ";g;" ";b
    #gr "backcolor ";r;" ";g;" ";b
end sub

sub fbox x0, y0, x1, y1
    #gr "place ";x0;" ";y0
    #gr "boxfilled ";x1+1;" ";y1+1
end sub

sub lButtonUp H$, mx, my  'must have handle and mouse x,y
    call quit H$          '<=== H$ global window handle
end sub

sub charIn H$, c$ 
    call quit H$
end sub

sub quit H$
    close #H$ '<=== this needs Global H$ = "gr"
    end       'Thanks Facundo, close graphic wo error
end sub

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub
 
User IP Logged

B+
rtr
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 22
xx Re: Spark Discharge
« Reply #2 on: Aug 22nd, 2017, 01:58am »

on Aug 21st, 2017, 3:24pm, bplus wrote:
Hot summer night back in the hills of Ohio...

I take my hat off to you; this is a beautiful program.

Richard.
User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3089
xx Re: Spark Discharge
« Reply #3 on: Aug 22nd, 2017, 02:27am »

Yes very nice and easy to follow. Its nearly what I want, the lightning needs to go point to point.

The lightning line drawing is exactly what I was looking for I just need to tweak it to land on a known point.
User IP Logged

Valentin
Junior Member
ImageImageImage


member is offline

Avatar




PM


Posts: 114
xx Re: Spark Discharge
« Reply #4 on: Aug 22nd, 2017, 02:41am »

The light should decrease more gradually, less abruptly.
thank you very much bplus+++
User IP Logged

rtr
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 22
xx Re: Spark Discharge
« Reply #5 on: Aug 22nd, 2017, 07:48am »

on Aug 22nd, 2017, 02:41am, Valentin wrote:
The light should decrease more gradually, less abruptly.

As a result of what physical mechanism? Light travels at the speed of light (!) so I would expect it to stop abruptly as soon as the lightning discharge ends.

Richard.
User IP Logged

bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: Spark Discharge
« Reply #6 on: Aug 22nd, 2017, 10:19am »

Thanks all!

Rod, the Lightning sub does go from 1 point to another: x1, y1 to x2, y2, and d controls how much it fools around going from one place to the other. The higher the d, the longer the arc can be.

Also play with different values than 5 in this line from Lightning sub.
if d < 5 then
As I recall, this controls how jagged or shaky the arc.

« Last Edit: Aug 22nd, 2017, 10:29am by bplus » User IP Logged

B+
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3089
xx Re: Spark Discharge
« Reply #7 on: Aug 22nd, 2017, 10:46am »

Quote:
As a result of what physical mechanism?


Organic really, our eyes, persistence of vision. Not enough light from the screen to trigger it but real lightning leaves your eyes swamped for a while.
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3553
xx Re: Spark Discharge
« Reply #8 on: Aug 22nd, 2017, 11:27am »

Take double wow - from me and my son.
"Dad can we download that program"?
wink
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: Spark Discharge
« Reply #9 on: Aug 22nd, 2017, 2:22pm »

Caution: Not for epileptics

Code:
'Tripoint Flux Capacitor.txt for JB (B+=MGA) 2017-08-22

global H$, XMAX, YMAX, PI, xc, yc, dist
H$ = "gr"
XMAX = 700
YMAX = 700
PI = acs(-1)
xc = XMAX/2
yc = YMAX/2 + 20
dim tp(2, 1), tp2(2, 1)

nomainwin

WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200 - XMAX) / 2
UpperLeftY = (700 - YMAX) / 2
ttl$ = "press or click any to quit.";space$(35);"Tripoint Flux Capacitor..."
open ttl$ for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "when leftButtonUp lButtonUp"
#gr "when characterInput charIn"
#gr "down"
#gr "fill black"
#gr "size 2"  'or 2?

call drawTripoint 'sets global points too
#gr "getbmp TriP 0 0 ";XMAX;" ";YMAX
#gr "background TriP"

while 1
    scan
    #gr "drawsprites"
    call pause 45      '<< adjust time as needed for your system
    scan
    call hue 0, 0, 0
    call fbox 0, 0, XMAX, YMAX
    call pause 40
    for i = 0 to 2
        scan
        xe = tp2(i, 0)
        ye = tp2(i, 1)
        d = rand(.1 * dist, .7 * dist)
        call Lightning xc, yc, xe, ye, d
    next
    call pause 20
wend

sub drawTripoint
    '3 main points for array tp()
    pRadius = 40 : cRadius = 1.5 * pRadius
    a3 = 2 * PI / 3 : r = YMAX/2 - cRadius
    ao = PI/6 : a = ao
    for rr = r to 0 step -10
        call midInk 255, 255, 255, 0, 0, 128, rr/r
        call fcirc xc, yc, rr
    next
    for i = 0 to 2
        tp(i,0) = xc + r * cos(a)
        tp(i,1) = yc + r * sin(a)
        for rr = cRadius to pRadius step -1
            call hue (rr-pRadius)/(cRadius-pRadius) * 255 * (cRadius-rr + pRadius)/cRadius, 0, 0
            xx = tp(i, 0) : yy = tp(i,1)
            call fcirc xx, yy, rr
        next
        a = a + a3
    next
    dist = distance(tp(0, 0), tp(0, 1), xc, yc)
    for point = 0 to 2
        scan
        for dis = 0 to .5 * dist step 2
            scan
            dGray = 255*dis/dist
            xx = tp(point, 0) : yy = tp(point, 1)
            call midpoint xx, yy, xc, yc, dis/dist, midx, midy
            for r = pRadius * (dist - dis) / dist to 0 step -1
                scan
                call midInk dGray, dGray, dGray, 255, 255, 255, (pRadius - r) / pRadius
                call fcirc midx, midy, r
            next
        next
        tp2(point, 0) = midx
        tp2(point, 1) = midy
    next
end sub

function rand(lo, hi)
    rand = int((hi - lo + 1) * rnd(0)) + lo
end function

sub Lightning x1,y1,x2,y2,d
    scan
    if d < 10 then
        call hue 180, 180, 225
        call aline x1,y1,x2,y2
    else
        mx = (x2+x1)/2
        my = (y2+y1)/2
        mx = mx + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        my = my + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        call Lightning x1, y1, mx, my, d/2
        call Lightning x2, y2, mx, my, d/2
    end if
end sub

function distance(x1, y1, x2, y2)
    distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
end function

sub midpoint x1, y1, x2, y2, fraction, byref midx, byref midy
  midx = (x2 - x1) * fraction + x1
  midy = (y2 - y1) * fraction + y1
end sub

sub aline x0, y0, x1, y1
    #gr "line ";x0;" ";y0;" ";x1+1;" ";y1+1  'add 1 to end point
end sub

sub fcirc x, y, radius
    #gr "place ";x;" ";y;"; circlefilled ";radius
end sub

sub hue r, g, b 'fore and back
    #gr "color ";r;" ";g;" ";b
    #gr "backcolor ";r;" ";g;" ";b
end sub

sub midInk r1, g1, b1, r2, g2, b2, frac
    dr = (r2 - r1) * frac : dg = (g2 - g1) * frac : db = (b2 - b1) * frac
    #gr "color ";r1 + dr;" ";g1 + dg;" ";b1 + db
    #gr "backcolor ";r1 + dr;" ";g1 + dg;" ";b1 + db
end sub

sub fbox x0, y0, x1, y1
    #gr "place ";x0;" ";y0
    #gr "boxfilled ";x1+1;" ";y1+1
end sub

sub lButtonUp H$, mx, my  'must have handle and mouse x,y
    call quit H$          '<=== H$ global window handle
end sub

sub charIn H$, c$ 
    call quit H$
end sub

sub quit H$
    close #H$ '<=== this needs Global H$ = "gr"
    end       'Thanks Facundo, close graphic wo error
end sub

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub

 
User IP Logged

B+
rtr
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 22
xx Re: Spark Discharge
« Reply #10 on: Aug 22nd, 2017, 2:27pm »

on Aug 22nd, 2017, 10:46am, Rod wrote:
Not enough light from the screen to trigger it but real lightning leaves your eyes swamped for a while.

I don't think it should be the job of the program to emulate that. Both the lightning and the viewer's eyes are too variable for any attempted emulation to be accurate. If you want it to look more realistic, wind up the brightness of your screen and watch it in low light conditions (causing the pupil to widen).

Richard.
User IP Logged

bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: Spark Discharge
« Reply #11 on: Aug 22nd, 2017, 4:05pm »

"Dancing Man" Pentacle Flux Capacitor...

Code:
'Pentacle Flux Capacitor.txt for JB (B+=MGA) 2017-08-22

global H$, XMAX, YMAX, PI, xc, yc, dist
H$ = "gr"
XMAX = 700
YMAX = 700
PI = acs(-1)
xc = XMAX/2
yc = YMAX/2 + 20
dim tp(4, 1), tp2(4, 1)

nomainwin

WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200 - XMAX) / 2
UpperLeftY = (700 - YMAX) / 2
ttl$ = "press or click any to quit.";space$(30);"Pentacle Flux Capacitor AKA Dancing Man..."
open ttl$ for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "when leftButtonUp lButtonUp"
#gr "when characterInput charIn"
#gr "down"
#gr "fill black"
#gr "size 2"  'or 2?

call drawTripoint 'sets global points too
#gr "getbmp TriP 0 0 ";XMAX;" ";YMAX
#gr "background TriP"

while 1
    scan
    #gr "drawsprites"
    call pause 45      '<< adjust time as needed for your system
    scan
    call hue 0, 0, 0
    call fbox 0, 0, XMAX, YMAX
    call pause 40
    for i = 0 to 4
        scan
        xe = tp2(i, 0)
        ye = tp2(i, 1)
        d = rand(.1 * dist, .7 * dist)
        call Lightning xc, yc, xe, ye, d
        if i = 0 then
            d = rand(.7 * dist, .9 * dist)
            call Lightning xc, yc, xe, ye, d
        end if
    next
    call pause 20
wend

sub drawTripoint
    '3 main points for array tp()
    pRadius = 40 : cRadius = 1.5 * pRadius
    a3 = 2 * PI / 5 : r = YMAX/2 - cRadius
    ao = -1*PI/2 : a = ao
    for rr = r to 0 step -10
        call midInk 255, 255, 255, 0, 0, 128, rr/r
        call fcirc xc, yc, rr
    next
    for i = 0 to 4
        tp(i,0) = xc + r * cos(a)
        tp(i,1) = yc + r * sin(a)
        for rr = cRadius to pRadius step -1
            call hue (rr-pRadius)/(cRadius-pRadius) * 255 * (cRadius-rr + pRadius)/cRadius, 0, 0
            xx = tp(i, 0) : yy = tp(i,1)
            call fcirc xx, yy, rr
        next
        a = a + a3
    next
    dist = distance(tp(0, 0), tp(0, 1), xc, yc)
    for point = 0 to 4
        scan
        for dis = 0 to .5 * dist step 2
            scan
            dGray = 255*dis/dist
            xx = tp(point, 0) : yy = tp(point, 1)
            call midpoint xx, yy, xc, yc, dis/dist, midx, midy
            for r = pRadius * (dist - dis) / dist to 0 step -1
                scan
                call midInk dGray, dGray, dGray, 255, 255, 255, (pRadius - r) / pRadius
                call fcirc midx, midy, r
            next
        next
        tp2(point, 0) = midx
        tp2(point, 1) = midy
    next
end sub

function rand(lo, hi)
    rand = int((hi - lo + 1) * rnd(0)) + lo
end function

sub Lightning x1,y1,x2,y2,d
    scan
    if d < 10 then
        call hue 180, 180, 225
        call aline x1,y1,x2,y2
    else
        mx = (x2+x1)/2
        my = (y2+y1)/2
        mx = mx + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        my = my + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        call Lightning x1, y1, mx, my, d/2
        call Lightning x2, y2, mx, my, d/2
    end if
end sub

function distance(x1, y1, x2, y2)
    distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
end function

sub midpoint x1, y1, x2, y2, fraction, byref midx, byref midy
  midx = (x2 - x1) * fraction + x1
  midy = (y2 - y1) * fraction + y1
end sub

sub aline x0, y0, x1, y1
    #gr "line ";x0;" ";y0;" ";x1+1;" ";y1+1  'add 1 to end point
end sub

sub fcirc x, y, radius
    #gr "place ";x;" ";y;"; circlefilled ";radius
end sub

sub hue r, g, b 'fore and back
    #gr "color ";r;" ";g;" ";b
    #gr "backcolor ";r;" ";g;" ";b
end sub

sub midInk r1, g1, b1, r2, g2, b2, frac
    dr = (r2 - r1) * frac : dg = (g2 - g1) * frac : db = (b2 - b1) * frac
    #gr "color ";r1 + dr;" ";g1 + dg;" ";b1 + db
    #gr "backcolor ";r1 + dr;" ";g1 + dg;" ";b1 + db
end sub

sub fbox x0, y0, x1, y1
    #gr "place ";x0;" ";y0
    #gr "boxfilled ";x1+1;" ";y1+1
end sub

sub lButtonUp H$, mx, my  'must have handle and mouse x,y
    call quit H$          '<=== H$ global window handle
end sub

sub charIn H$, c$ 
    call quit H$
end sub

sub quit H$
    close #H$ '<=== this needs Global H$ = "gr"
    end       'Thanks Facundo, close graphic wo error
end sub

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub

 
User IP Logged

B+
tanger32au
Full Member
ImageImageImageImage


member is offline

Avatar



YIM YIM
Homepage PM

Gender: Male
Posts: 130
xx Re: Spark Discharge
« Reply #12 on: Aug 22nd, 2017, 5:12pm »

All very cool little programs smiley
User IP Logged

http://launcestonanalyticalradioscanning.blogspot.com.au/

bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: Spark Discharge
« Reply #13 on: Aug 23rd, 2017, 02:45am »

Dancing man has been working on his moves...
Code:
'Pentacle Flux Capacitor 2.txt for JB (B+=MGA) 2017-08-22

global H$, XMAX, YMAX, PI, xc, yc, dist
H$ = "gr"
XMAX = 700
YMAX = 700
PI = acs(-1)
xc = XMAX/2
yc = YMAX/2 + 20
dim tp(4, 1), tp2(4, 1)

nomainwin

WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200 - XMAX) / 2
UpperLeftY = (700 - YMAX) / 2
ttl$ = "press or click any to quit.";space$(30);"Pentacle Flux Capacitor AKA Dancing Man..."
open ttl$ for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "when leftButtonUp lButtonUp"
#gr "when characterInput charIn"
#gr "down"
#gr "fill black"
#gr "size 2"  'or 2?

call drawTripoint 'sets global points too
#gr "getbmp TriP 0 0 ";XMAX;" ";YMAX
#gr "background TriP"

while 1
    scan
    #gr "drawsprites"
    call pause 45      '<< adjust time as needed for your system
    scan
    call hue 0, 0, 0
    call fbox 0, 0, XMAX, YMAX
    call pause 40
    call Lightning xc, yc-90, xc, yc + 10, 135
    for i = 0 to 4
        scan
        xe = tp2(i, 0)
        ye = tp2(i, 1)
        d = rand(.1 * dist, .7 * dist)
        select case i
        case 0
            call Lightning xc, yc-90, xe, ye, d
            call Lightning xc, yc-90, xe, ye, d
        case 1, 4
            call Lightning xc, yc-70, xe, ye, d
        case 2, 3
            call Lightning xc, yc+10, xe, ye, d
        end select
    next
    call pause 20
wend

sub drawTripoint
    '3 main points for array tp()
    pRadius = 40 : cRadius = 1.5 * pRadius
    a3 = 2 * PI / 5 : r = YMAX/2 - cRadius
    ao = -1*PI/2 : a = ao
    for rr = r to 0 step -10
        call midInk 255, 255, 255, 0, 0, 128, rr/r
        call fcirc xc, yc, rr
    next
    for i = 0 to 4
        tp(i,0) = xc + r * cos(a)
        tp(i,1) = yc + r * sin(a)
        for rr = cRadius to pRadius step -1
            call hue (rr-pRadius)/(cRadius-pRadius) * 255 * (cRadius-rr + pRadius)/cRadius, 0, 0
            xx = tp(i, 0) : yy = tp(i,1)
            call fcirc xx, yy, rr
        next
        a = a + a3
    next
    dist = distance(tp(0, 0), tp(0, 1), xc, yc)
    for point = 0 to 4
        scan
        for dis = 0 to .5 * dist step 10
            scan
            dGray = 255*dis/dist
            xx = tp(point, 0) : yy = tp(point, 1)
            call midpoint xx, yy, xc, yc, dis/dist, midx, midy
            for r = pRadius * (dist - dis) / dist to 0 step -1
                scan
                call midInk dGray, dGray, dGray, 255, 255, 255, (pRadius - r) / pRadius
                call fcirc midx, midy, r
            next
        next
        tp2(point, 0) = midx
        tp2(point, 1) = midy
    next
end sub

function rand(lo, hi)
    rand = int((hi - lo + 1) * rnd(0)) + lo
end function

sub Lightning x1,y1,x2,y2,d
    scan
    if d < 10 then
        call hue 180, 180, 225
        call aline x1,y1,x2,y2
    else
        mx = (x2+x1)/2
        my = (y2+y1)/2
        mx = mx + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        my = my + -.5 * rnd(0) * d * .4 * rand(-2, 2)
        call Lightning x1, y1, mx, my, d/2
        call Lightning x2, y2, mx, my, d/2
    end if
end sub

function distance(x1, y1, x2, y2)
    distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
end function

sub midpoint x1, y1, x2, y2, fraction, byref midx, byref midy
  midx = (x2 - x1) * fraction + x1
  midy = (y2 - y1) * fraction + y1
end sub

sub aline x0, y0, x1, y1
    #gr "line ";x0;" ";y0;" ";x1+1;" ";y1+1  'add 1 to end point
end sub

sub fcirc x, y, radius
    #gr "place ";x;" ";y;"; circlefilled ";radius
end sub

sub hue r, g, b 'fore and back
    #gr "color ";r;" ";g;" ";b
    #gr "backcolor ";r;" ";g;" ";b
end sub

sub midInk r1, g1, b1, r2, g2, b2, frac
    dr = (r2 - r1) * frac : dg = (g2 - g1) * frac : db = (b2 - b1) * frac
    #gr "color ";r1 + dr;" ";g1 + dg;" ";b1 + db
    #gr "backcolor ";r1 + dr;" ";g1 + dg;" ";b1 + db
end sub

sub fbox x0, y0, x1, y1
    #gr "place ";x0;" ";y0
    #gr "boxfilled ";x1+1;" ";y1+1
end sub

sub lButtonUp H$, mx, my  'must have handle and mouse x,y
    call quit H$          '<=== H$ global window handle
end sub

sub charIn H$, c$ 
    call quit H$
end sub

sub quit H$
    close #H$ '<=== this needs Global H$ = "gr"
    end       'Thanks Facundo, close graphic wo error
end sub

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub

 


Need some Music?
Anyone remember Electric Light Orchestra?

It's a Livin Thing...
https://www.youtube.com/watch?v=i2d45tOgBl0&index=1&list=RDi2d45tOgBl0
« Last Edit: Aug 23rd, 2017, 03:03am by bplus » User IP Logged

B+
rtr
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 22
xx Re: Spark Discharge
« Reply #14 on: Aug 23rd, 2017, 03:36am »

on Aug 23rd, 2017, 02:45am, bplus wrote:
Anyone remember Electric Light Orchestra?

Yes. Or was that rhetorical?

R.
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls