Laser Cut Effect

You can talk about anything related to LB Booster here, not covered in another category
alincon2001
Posts: 4
Joined: Mon Apr 16, 2018 1:51 am

Laser Cut Effect

Post by alincon2001 »

This is taken from 'that other LB forum'.
(I don't know how to format code anymore)
r.m.

'Laser engraving (look-alike)
'tsh73
'Jan 2019. Feb 2019 - with GetPixelAPI for LB

nomainwin
WindowWidth = 650
open "Laser engraving" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
handleg =hwnd( #gr)
calldll #user32, "GetDC", handleg as ulong, hDC as ulong

#gr "down"
#gr "fill black; flush"

#gr "backcolor black"
#gr "color 1 1 1" 'almost black, but not exactly
'#gr "color white"
#gr "place 30 200"
#gr "font times_new_roman 60 bold"
#gr "font times_new_roman 0 90 bold"
var$ = "Hello World!"
#gr "|";var$
#gr "StringWidth? var$ widthInPixels"

#gr "color blue" 'gives red on black after XOR. Don't ask.

n = 5
r = 20

x0=(300 + widthInPixels)
y0=150
x1=35
y1=y0

t0=time$("ms")
#gr "rule xor"

for x1 = 30 to (widthInPixels + 30)
for y = 145 to 250
scan
#gr "color ";Int((rnd(1)*255)+0.5);" ";Int((rnd(1)*255)+0.5);" ";Int((rnd(1)*255)+0.5)
calldll #gdi32, "GetPixel", hDC as ulong, x1 as long, y as long, pixcol as ulong
'print x1, y, pixcol

hasDot = (pixcol<>0)
if not(hasDot) then goto [skip]
y0=y:y1=y0
'since last point on a line not drawn, we draw line from LAST point
'#gr "line ";x0;" ";y0;" ";x1;" ";y1
#gr "line ";x1;" ";y1;" ";x0;" ";y0
'random sparkles
for i = 1 to n
a(i)=int(rnd(0)*360)
r(i)=int(rnd(0)*r)
next
for i = 1 to n
#gr "place ";x1;" ";y1
#gr "north; turn ";a(i)
#gr "go ";r(i)
next
'call pause 20'0'00
'#gr "line ";x0;" ";y0;" ";x1+1;" ";y1 '+1 !!
#gr "line ";x1+1;" ";y1;" ";x0;" ";y0
for i = 1 to n
#gr "place ";x1;" ";y1
#gr "north; turn ";a(i)
#gr "go ";r(i)
next
[skip]
next
#gr "discard"
next
#gr "flush"
t1=time$("ms")

notice "That's all, folks ";t1-t0
wait

[quit]
close #gr
end

sub pause mil
t0=time$("ms")
while time$("ms")<t0+mil
scan
wend
exit sub
[quit]
close #gr
end
end sub
tsh73
Posts: 44
Joined: Fri Apr 06, 2018 7:58 pm

Re: Laser Cut Effect

Post by tsh73 »

(I don't know how to format code anymore)
5th button on a toolbar, after
B I U [ Quote ]

Or you can use [ code ] [ /code ] tags (I just put unbreakable spaces so it didn't run)
alincon2001
Posts: 4
Joined: Mon Apr 16, 2018 1:51 am

Re: Laser Cut Effect

Post by alincon2001 »

I didn't really forget, I just didn't recognize the <>------<> as a code formatter icon.
Sorry if I posted your code w/o asking, but it's a great demo.

r.m.
tsh73
Posts: 44
Joined: Fri Apr 06, 2018 7:58 pm

Re: Laser Cut Effect

Post by tsh73 »

I'm flattered ;)