Post by tsh73 on Jun 27, 2023 22:05:26 GMT
This one
Started from well, a pattern found online
Then
"aha, if I divide that line into N parts..."
"but it consists of similar triangles. Let's make a sub of it"
"I see repeated pattern. Let's wrap it a sub and call a fish"
(I made one fish red, so you can see it too)
And with some twiggling - I got it to fill whole window.
Having fun.
Started from well, a pattern found online
Then
"aha, if I divide that line into N parts..."
"but it consists of similar triangles. Let's make a sub of it"
sub shadedTriangle pts$, n
"I see repeated pattern. Let's wrap it a sub and call a fish"
sub fish pt0$, r, n
(I made one fish red, so you can see it too)
And with some twiggling - I got it to fill whole window.
Having fun.
'kind of filled (shaded? rayed?) triangle
'used to recreate a pattern
'tsh73 Jun 2023
global gr$ 'for sub
gr$ = "#gr"
nomainwin
open "pattern" for graphics_nsb_nf as #gr
#gr "down; home; posxy cx cy"
#gr "trapclose [quit] "
'call shadedTriangle "10 10 10 100 100 10 ", 20
r=70
n=15
pt00$=cx;" ";cy
for i = -1 to 1
for j = -1 to 1
pt0$=offsetPt$(pt00$, i*2*r,j*2*r)
#gr "color black"
if i = 0 and j = 0 then #gr "color red"
call fish pt0$, r, n
next
next
#gr "flush"
wait
sub fish pt0$, r, n
pt1$=offsetPt$(pt0$, 0,0-r)
pt2$=offsetPt$(pt0$, r,0)
pt3$=offsetPt$(pt0$, 0,r)
pt4$=offsetPt$(pt0$, 0-r,0)
call shadedTriangle pt1$;" ";pt2$;" ";pt0$, n
call shadedTriangle pt2$;" ";pt3$;" ";pt0$, n
call shadedTriangle pt3$;" ";pt4$;" ";pt0$, n
call shadedTriangle pt4$;" ";pt1$;" ";pt0$, n
n2=int(n*sqr(2)+.5)
pta1$=offsetPt$(pt1$, 2*r,0)
pta3$=offsetPt$(pt3$, 2*r,0)
call shadedTriangle pt1$;" ";pta1$;" ";pt2$, n2
call shadedTriangle pt3$;" ";pta3$;" ";pt2$, n2
end sub
sub shadedTriangle pts$, n
'pts$ is 3 points x1 y1 x2 y2 x3 y3
'x1 y1 x2 y2 is divided into n segments
'x3 y3 connecte to each segment
x1=val(word$(pts$,1))
y1=val(word$(pts$,2))
x2=val(word$(pts$,3))
y2=val(word$(pts$,4))
endPt$=" ";word$(pts$,5);" ";word$(pts$,6)
#gr$ "line ";x1;" ";y1;" ";x2;" ";y2
for i = 0 to n
a=i/n: b=1-a
x=x1*a+x2*b
y=y1*a+y2*b
#gr$ "line ";x;" ";y;endPt$
next
end sub
function offsetPt$(pt1$, dx, dy)
x1=val(word$(pt1$,1))
y1=val(word$(pt1$,2))
offsetPt$=x1+dx;" ";y1+dy
end function
wait
[quit]
close #gr
end