Author 
Topic: Happy St Patrick's Day (Read 198 times) 

bplus
Senior Member
member is offline
Gender:
Posts: 1286


Happy St Patrick's Day
« Thread started on: Mar 7^{th}, 2018, 1:33pm » 

OK, on time even early with this one. Code:'from QB64
' _TITLE "Happy St Patrick's Day by bplus 20180307"
' from
' Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
H$ = "gr"
XMAX = 1200 '<======================================== actual drawing space needed
YMAX = 720 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200  XMAX) / 2 'or delete if XMAX is 1200 or above
UpperLeftY = (720  YMAX) / 2 'or delete if YMAX is 700 or above
open " Happy St Patrick's Day by bplus 20180307" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "size 2"
WHILE 1
scan
cc1 = RND(0) * 100 + 50
cc2 = RND(0) * 100 + 50
xp = RND(0) * XMAX
yp = RND(0) * YMAX
sz = INT(RND(0) * 40) + 10
ang = RND(0) * PI*2
#gr "size 2"
call fore 0, cc1, 0
FOR r = 1 TO sz
scan
call drawShamrock xp +1, yp, r, ang
'call drawShamrock xp  1, yp, r, ang
'call drawShamrock xp, yp + 1, r, ang
'call drawShamrock xp, yp  1, r, ang
'call drawShamrock xp + 1, yp + 1, r, ang
NEXT
#gr "size 1"
call fore 0, cc2, 0
FOR r = 1 TO sz
scan
call drawShamrock xp, yp, r, ang
NEXT
WEND
wait
sub fore r, g, b
#gr "color ";r;" ";g;" ";b
end sub
sub aline x0, y0, x1, y1
#gr "line ";x0;" ";y0;" ";x1;" ";y1 'add 1 to end point
end sub
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
for rAngle = rAngleStart to rAngleEnd step Stepper
if rAngle = rAngleStart then
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
else
nextX = xCenter + arcRadius * cos(rAngle)
if nextX <= lastX then useX = nextX 1 else useX = nextX + 1
nextY = yCenter + arcRadius * sin(rAngle)
if nextY <= lastY then useY = nextY 1 else useY = nextY + 1
#gr "line ";lastX;" ";lastY;" ";nextX;" ";nextY
lastX = nextX
lastY = nextY
end if
next
end sub
SUB drawHeart x, y, r, a
scan
'local x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6
'clockwise from due East, the V
x1 = x + r * COS(a)
y1 = y + r * SIN(a)
x2 = x + r * COS(a + PI / 2)
y2 = y + r * SIN(a + PI / 2)
x3 = x + r * COS(a + PI)
y3 = y + r * SIN(a + PI)
x4 = x + r * COS(a + 3 * PI / 2)
y4 = y + r * SIN(a + 3 * PI / 2)
x5 = (x3 + x4) / 2
y5 = (y3 + y4) / 2
x6 = (x4 + x1) / 2
y6 = (y4 + y1) / 2
#gr "line ";x1;" ";y1;" ";x2;" ";y2
#gr "line ";x2;" ";y2;" ";x3;" ";y3
'left hump
call arc x5, y5, .5 * r * 2 ^ .5, DEG*a + 135, 180
'right hump
call arc x6, y6, .5 * r * 2 ^ .5, DEG*a + 225, 180
END SUB
SUB drawShamrock x, y, r, a
'local x1, x2, x3, y1, y2, y3
scan
x1 = x + r * COS(a + 3 * PI / 2)
y1 = y + r * SIN(a + 3 * PI / 2)
x2 = x + r * COS(a + PI / 6)
y2 = y + r * SIN(a + PI / 6)
x3 = x + r * COS(a + 5 * PI / 6)
y3 = y + r * SIN(a + 5 * PI / 6)
call drawHeart x1, y1, r, a
call drawHeart x2, y2, r, a + 2 * PI / 3
call drawHeart x3, y3, r, a + 4 * PI / 3
END SUB
Might even have a screen full by St Patrick's Day :))


Logged

B+



tsh73
JBSupporter
member is offline
Gender:
Posts: 3662


Re: Happy St Patrick's Day
« Reply #1 on: Mar 8^{th}, 2018, 10:54am » 

Had to chase my kid off computer  he kept searching for "which shamrock grows" (instead of doing math that is). Ahh, I see you used "heart" code. So you can't make "lucky clover" (four pads) with it?


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
member is offline
Gender:
Posts: 1286


Re: Happy St Patrick's Day
« Reply #2 on: Mar 8^{th}, 2018, 10:58am » 

on Mar 8^{th}, 2018, 10:54am, tsh73 wrote:Had to chase my kid off computer  he kept searching for "which shamrock grows" (instead of doing math that is). Ahh, I see you used "heart" code. So you can't make "lucky clover" (four pads) with it? 

Why not?
If 4 is lucky, what is 5?


Logged

B+



tsh73
JBSupporter
member is offline
Gender:
Posts: 3662


Re: Happy St Patrick's Day
« Reply #3 on: Mar 8^{th}, 2018, 1:02pm » 

Quote: Because 4 pads connect? (and 5 will sure overlap  have to see if it's actually bad thing) Code:'from QB64
' _TITLE "Happy St Patrick's Day by bplus 20180307"
' from
' Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
H$ = "gr"
XMAX = 1200 '<======================================== actual drawing space needed
YMAX = 720 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200  XMAX) / 2 'or delete if XMAX is 1200 or above
UpperLeftY = (720  YMAX) / 2 'or delete if YMAX is 700 or above
open " Happy St Patrick's Day by bplus 20180307" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
'#gr "size 2"
WHILE 1
scan
cc1 = RND(0) * 100 + 50
cc2 = RND(0) * 100 + 50
xp = RND(0) * XMAX
yp = RND(0) * YMAX
sz = INT(RND(0) * 40) + 10
ang = RND(0) * PI*2
lucky = rnd(0)<.1
#gr "size 3" 'so no white dots show through
call fore 0, cc1, 0
FOR r = 1 TO sz
scan
if lucky then
call drawShamrock4 xp +1, yp, r, ang
else
call drawShamrock xp +1, yp, r, ang
end if
'call drawShamrock xp  1, yp, r, ang
'call drawShamrock xp, yp + 1, r, ang
'call drawShamrock xp, yp  1, r, ang
'call drawShamrock xp + 1, yp + 1, r, ang
NEXT
#gr "size 1"
call fore 0, cc2, 0
FOR r = 1 TO sz
scan
if lucky then
call drawShamrock4 xp, yp, r, ang
else
call drawShamrock xp, yp, r, ang
end if
NEXT
if lucky then
#gr "size 2"
#gr "color black"
call drawShamrock4 xp, yp, sz, ang
end if
WEND
wait
sub fore r, g, b
#gr "color ";r;" ";g;" ";b
end sub
sub aline x0, y0, x1, y1
#gr "line ";x0;" ";y0;" ";x1;" ";y1 'add 1 to end point
end sub
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
for rAngle = rAngleStart to rAngleEnd step Stepper
if rAngle = rAngleStart then
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
else
nextX = xCenter + arcRadius * cos(rAngle)
if nextX <= lastX then useX = nextX 1 else useX = nextX + 1
nextY = yCenter + arcRadius * sin(rAngle)
if nextY <= lastY then useY = nextY 1 else useY = nextY + 1
#gr "line ";int(lastX);" ";int(lastY);" ";int(nextX);" ";int(nextY)
lastX = nextX
lastY = nextY
end if
next
end sub
SUB drawHeart x, y, r, a
scan
'local x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6
'clockwise from due East, the V
#gr "place ";x;" ";y
x1 = x + r * COS(a)
y1 = y + r * SIN(a)
x2 = x + r * COS(a + PI / 2)
y2 = y + r * SIN(a + PI / 2)
x3 = x + r * COS(a + PI)
y3 = y + r * SIN(a + PI)
x4 = x + r * COS(a + 3 * PI / 2)
y4 = y + r * SIN(a + 3 * PI / 2)
x5 = (x3 + x4) / 2
y5 = (y3 + y4) / 2
x6 = (x4 + x1) / 2
y6 = (y4 + y1) / 2
#gr "line ";x1;" ";y1;" ";x2;" ";y2
#gr "line ";x2;" ";y2;" ";x3;" ";y3
'left hump
call arc x5, y5, .5 * r * 2 ^ .5, DEG*a + 135, 180
'right hump
call arc x6, y6, .5 * r * 2 ^ .5, DEG*a + 225, 180
END SUB
SUB drawShamrock x, y, r, a
'local x1, x2, x3, y1, y2, y3
scan
x1 = x + r * COS(a + 3 * PI / 2)
y1 = y + r * SIN(a + 3 * PI / 2)
x2 = x + r * COS(a + PI / 6)
y2 = y + r * SIN(a + PI / 6)
x3 = x + r * COS(a + 5 * PI / 6)
y3 = y + r * SIN(a + 5 * PI / 6)
call drawHeart x1, y1, r, a
call drawHeart x2, y2, r, a + 2 * PI / 3
call drawHeart x3, y3, r, a + 4 * PI / 3
END SUB
SUB drawShamrock4 x, y, r, a
'local x1, x2, x3, y1, y2, y3
scan
x1 = x + r * COS(a + PI / 2)
y1 = y + r * SIN(a + PI / 2)
x2 = x + r * COS(a + PI )
y2 = y + r * SIN(a + PI )
x3 = x + r * COS(a + 3 * PI / 2)
y3 = y + r * SIN(a + 3 * PI / 2)
x4 = x + r * COS(a )
y4 = y + r * SIN(a )
call drawHeart x1, y1, r, a  PI
call drawHeart x2, y2, r, a  PI/2
call drawHeart x3, y3, r, a
call drawHeart x4, y4, r, a + PI / 2
END SUB


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)



tsh73
JBSupporter
member is offline
Gender:
Posts: 3662


Re: Happy St Patrick's Day
« Reply #4 on: Mar 8^{th}, 2018, 1:20pm » 

Just to say, circle are SO MUCH faster :( though not so pretty, but it really jumps at you. (have a look in color section too) Code:'from QB64
' _TITLE "Happy St Patrick's Day by bplus 20180307"
' from
' Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
H$ = "gr"
XMAX = 1200 '<======================================== actual drawing space needed
YMAX = 720 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200  XMAX) / 2 'or delete if XMAX is 1200 or above
UpperLeftY = (720  YMAX) / 2 'or delete if YMAX is 700 or above
open " Happy St Patrick's Day by bplus 20180307" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
'#gr "size 2"
WHILE 1
scan
cc1 = RND(0) * 100 + 50
cc2 =cc1
while abs(cc2cc1)<50
cc2 = RND(0) * 100 + 50
wend
xp = RND(0) * XMAX
yp = RND(0) * YMAX
sz = INT(RND(0) * 40) + 10
ang = RND(0) * PI*2
lucky = rnd(0)<.1
#gr "size 3" 'so no white dots show through
call fore 0, cc1, 0
FOR r = 1 TO sz
scan
if lucky then
call drawShamrock4 xp +1, yp, r, ang
else
call drawShamrock xp +1, yp, r, ang
end if
'call drawShamrock xp  1, yp, r, ang
'call drawShamrock xp, yp + 1, r, ang
'call drawShamrock xp, yp  1, r, ang
'call drawShamrock xp + 1, yp + 1, r, ang
NEXT
#gr "size 1"
call fore 0, cc2, 0
FOR r = 1 TO sz
scan
if lucky then
call drawShamrock4 xp, yp, r, ang
else
call drawShamrock xp, yp, r, ang
end if
NEXT
'if lucky then
' #gr "size 1"
' #gr "color black"
' call drawShamrock4 xp, yp, sz, ang
'end if
WEND
wait
sub fore r, g, b
#gr "color ";r;" ";g;" ";b
end sub
sub aline x0, y0, x1, y1
#gr "line ";x0;" ";y0;" ";x1;" ";y1 'add 1 to end point
end sub
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
for rAngle = rAngleStart to rAngleEnd step Stepper
if rAngle = rAngleStart then
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
else
nextX = xCenter + arcRadius * cos(rAngle)
if nextX <= lastX then useX = nextX 1 else useX = nextX + 1
nextY = yCenter + arcRadius * sin(rAngle)
if nextY <= lastY then useY = nextY 1 else useY = nextY + 1
#gr "line ";int(lastX);" ";int(lastY);" ";int(nextX);" ";int(nextY)
lastX = nextX
lastY = nextY
end if
next
end sub
SUB drawHeart x, y, r, a
scan
'local x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6
'clockwise from due East, the V
#gr "place ";x;" ";y
x1 = x + r * COS(a)
y1 = y + r * SIN(a)
x2 = x + r * COS(a + PI / 2)
y2 = y + r * SIN(a + PI / 2)
x3 = x + r * COS(a + PI)
y3 = y + r * SIN(a + PI)
x4 = x + r * COS(a + 3 * PI / 2)
y4 = y + r * SIN(a + 3 * PI / 2)
x5 = (x3 + x4) / 2
y5 = (y3 + y4) / 2
x6 = (x4 + x1) / 2
y6 = (y4 + y1) / 2
#gr "line ";x1;" ";y1;" ";x2;" ";y2
#gr "line ";x2;" ";y2;" ";x3;" ";y3
'left hump
'call arc x5, y5, .5 * r * 2 ^ .5, DEG*a + 135, 180
#gr "place ";x5;" ";y5
#gr "circle ";.5 * r * 2 ^ .5
'right hump
'call arc x6, y6, .5 * r * 2 ^ .5, DEG*a + 225, 180
#gr "place ";x6;" ";y6
#gr "circle ";.5 * r * 2 ^ .5
END SUB
SUB drawShamrock x, y, r, a
'local x1, x2, x3, y1, y2, y3
scan
x1 = x + r * COS(a + 3 * PI / 2)
y1 = y + r * SIN(a + 3 * PI / 2)
x2 = x + r * COS(a + PI / 6)
y2 = y + r * SIN(a + PI / 6)
x3 = x + r * COS(a + 5 * PI / 6)
y3 = y + r * SIN(a + 5 * PI / 6)
call drawHeart x1, y1, r, a
call drawHeart x2, y2, r, a + 2 * PI / 3
call drawHeart x3, y3, r, a + 4 * PI / 3
END SUB
SUB drawShamrock4 x, y, r, a
'local x1, x2, x3, y1, y2, y3
scan
x1 = x + r * COS(a + PI / 2)
y1 = y + r * SIN(a + PI / 2)
x2 = x + r * COS(a + PI )
y2 = y + r * SIN(a + PI )
x3 = x + r * COS(a + 3 * PI / 2)
y3 = y + r * SIN(a + 3 * PI / 2)
x4 = x + r * COS(a )
y4 = y + r * SIN(a )
call drawHeart x1, y1, r, a  PI
call drawHeart x2, y2, r, a  PI/2
call drawHeart x3, y3, r, a
call drawHeart x4, y4, r, a + PI / 2
END SUB


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
member is offline
Gender:
Posts: 1286


Re: Happy St Patrick's Day
« Reply #5 on: Mar 8^{th}, 2018, 4:16pm » 

OK N leafed Shamrocks though more than 7 is a bit much.
OK find the 7 leafer when this stops drawing: Code:'ShamrockN.bas for JB 2.0 b2 by bplus 20180308
'mod N leafed Shamrocks from Happy St Patrick's Day 20190307
'from QB64
' _TITLE "Happy St Patrick's Day by bplus 20180307"
' from
' Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
H$ = "gr"
XMAX = 800 '<======================================== actual drawing space needed
YMAX = 600 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200  XMAX) / 2 'or delete if XMAX is 1200 or above
UpperLeftY = (720  YMAX) / 2 'or delete if YMAX is 700 or above
open " N Leafed Shamrocks, How Lucky Are You? (Stops when 7 leafer is made.) by bplus 20180308" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "size 2"
WHILE nLeafs < 7
scan
if rnd(0) < .2 then
if rnd(0) < .2 then
if rnd(0) < .2 then
if rnd(0) < .2 then
nLeafs = 7
else
nLeafs = 6
end if
else
nLeafs = 5
end if
else
nLeafs = 4
end if
else
nLeafs = 3
end if
cc1 = RND(0) * 100 + 50
cc2 = RND(0) * 100 + 50
xp = RND(0) * XMAX
yp = RND(0) * YMAX
sz = INT(RND(0) * 7) + 10
ang = RND(0) * PI*2
#gr "size 1"
call fore 0, cc1, 0
FOR r = 1 TO sz step .2
scan
call drawShamrockN xp, yp, r, ang, nLeafs
NEXT
#gr "size 1"
call fore 0, cc2, 0
FOR r = 1 TO sz
scan
call drawShamrockN xp, yp, r, ang, nLeafs
NEXT
WEND
wait
sub fore r, g, b
#gr "color ";r;" ";g;" ";b
end sub
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
for rAngle = rAngleStart to rAngleEnd step Stepper
if rAngle = rAngleStart then
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
else
nextX = xCenter + arcRadius * cos(rAngle)
if nextX <= lastX then useX = nextX 1 else useX = nextX + 1
nextY = yCenter + arcRadius * sin(rAngle)
if nextY <= lastY then useY = nextY 1 else useY = nextY + 1
#gr "line ";lastX;" ";lastY;" ";nextX;" ";nextY
lastX = nextX
lastY = nextY
end if
next
end sub
sub drawSqueezedHeart x, y, r, rl, a
scan
'local x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6
'clockwise from due East, the V
x1 = x + r * cos(a)
y1 = y + r * sin(a)
x2 = x + rl * cos(a + PI/2)
y2 = y + rl * sin(a + PI/2)
x3 = x + r * cos(a + PI)
y3 = y + r * sin(a + PI)
x4 = x + r * cos(a + 3*PI/2)
y4 = y + r * sin(a + 3*PI/2)
x5 = (x3 + x4)/2
y5 = (y3 + y4)/2
x6 = (x4 + x1)/2
y6 = (y4 + y1)/2
#gr "line ";x1;" ";y1;" ";x2;" ";y2
#gr "line ";x2;" ";y2;" ";x3;" ";y3
'left hump
call arc x5, y5, .5 * r * 2 ^ .5, DEG*a + 135, 180
'right hump
call arc x6, y6, .5 * r * 2 ^ .5, DEG*a + 225, 180
end sub
sub drawShamrockN x, y, r, a, nLeafed
'local bigR, x1, x2, x3, y1, y2, y3
scan
np1 = nLeafed + 1
noLeaf = int(np1 / 2)
bigR = 2.2*r*np1 / (2*PI)
if nLeafed mod 2 = 0 then aoff = PI / np1
for leaf = 0 to nLeafed
if leaf <> noLeaf then
x1 = x + bigR * cos(a + leaf * 2*PI/np1 + 3*PI/2 + aoff)
y1 = y + bigR * sin(a + leaf * 2*PI/np1 + 3*PI/2 + aoff)
call drawSqueezedHeart x1, y1, r, bigR, a + leaf*2*PI/np1 + aoff
end if
next
end sub
PS need size 1 to preserve the space between the leaves.

« Last Edit: Mar 8^{th}, 2018, 4:28pm by bplus » 
Logged

B+



tsh73
JBSupporter
member is offline
Gender:
Posts: 3662


Re: Happy St Patrick's Day
« Reply #6 on: Mar 8^{th}, 2018, 11:01pm » 

Hey Bplus! Where are you hiding that time machine? Quote:'mod N leafed Shamrocks from Happy St Patrick's Day 20190307 

LOL
EDIT It seems that useX, useY in sub arc are not used

« Last Edit: Mar 8^{th}, 2018, 11:16pm by tsh73 » 
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)



tsh73
JBSupporter
member is offline
Gender:
Posts: 3662


Re: Happy St Patrick's Day
« Reply #7 on: Mar 8^{th}, 2018, 11:47pm » 

sped it up quite a bit, added counter on top (so you see how inlucky you actually are ;) ) (I got 01:05:07:51:246) Code:'mod N leafed Shamrocks from Happy St Patrick's Day 20190307
'from QB64
' _TITLE "Happy St Patrick's Day by bplus 20180307"
' from
' Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
global USECIRCLE
H$ = "gr"
XMAX = 800 '<======================================== actual drawing space needed
YMAX = 600 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200  XMAX) / 2 'or delete if XMAX is 1200 or above
UpperLeftY = (720  YMAX) / 2 'or delete if YMAX is 700 or above
open " N Leafed Shamrocks, How Lucky Are You? (Stops when 7 leafer is made.) by bplus 20180308" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "size 2"
dim count(7)
WHILE nLeafs < 7
scan
#gr "discard" 'to prevent memory buildup
if rnd(0) < .2 then
if rnd(0) < .2 then
if rnd(0) < .2 then
if rnd(0) < .2 then
nLeafs = 7
else
nLeafs = 6
end if
else
nLeafs = 5
end if
else
nLeafs = 4
end if
else
nLeafs = 3
end if
count(nLeafs)=count(nLeafs)+1
#gr "place 0 0"
#gr "backcolor white"
#gr "\\";right$("";100+count(7),2);":" _
;right$("";100+count(6),2);":" _
;right$("";100+count(5),2);":" _
;right$("";100+count(4),2);":" _
;right$("";1000+count(3),3)
cc1 = RND(0) * 100 + 50
'cc2 = RND(0) * 100 + 50
cc2 =cc1 'make them substantially different
while abs(cc2cc1)<20
cc2 = RND(0) * 100 + 50
wend
xp = RND(0) * XMAX
yp = RND(0) * YMAX
sz = INT(RND(0) * 7) + 10
ang = RND(0) * PI*2
#gr "size 1"
call fore 0, cc1, 0
USECIRCLE=1
#gr "backcolor ";0;" ";cc1;" ";0
FOR r = 1 TO sz+1 step .2
scan
call drawShamrockN xp, yp, r, ang, nLeafs
NEXT
#gr "size 1"
call fore 0, cc2, 0
USECIRCLE=0
FOR r = 1 TO sz
scan
call drawShamrockN xp, yp, r, ang, nLeafs
NEXT
WEND
wait
sub fore r, g, b
#gr "color ";r;" ";g;" ";b
end sub
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
#gr "set ";int(lastX);" ";int(lastY)
for rAngle = rAngleStart+Stepper to rAngleEnd step Stepper
nextX = xCenter + arcRadius * cos(rAngle)
nextY = yCenter + arcRadius * sin(rAngle)
#gr "goto ";int(nextX);" ";int(nextY) 'int speeds things up
next
end sub
sub drawSqueezedHeart x, y, r, rl, a
scan
'local x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6
'clockwise from due East, the V
x1 = x + r * cos(a)
y1 = y + r * sin(a)
x2 = x + rl * cos(a + PI/2)
y2 = y + rl * sin(a + PI/2)
x3 = x + r * cos(a + PI)
y3 = y + r * sin(a + PI)
x4 = x + r * cos(a + 3*PI/2)
y4 = y + r * sin(a + 3*PI/2)
x5 = (x3 + x4)/2
y5 = (y3 + y4)/2
x6 = (x4 + x1)/2
y6 = (y4 + y1)/2
#gr "line ";x1;" ";y1;" ";x2;" ";y2
#gr "line ";x2;" ";y2;" ";x3;" ";y3
if USECIRCLE then 'much faster, OK for solid heart
#gr "place ";x5;" ";y5
#gr "circlefilled ";.5 * r * 2 ^ .5
#gr "place ";x6;" ";y6
#gr "circlefilled ";.5 * r * 2 ^ .5
else
'left hump
call arc x5, y5, .5 * r * 2 ^ .5, DEG*a + 135, 180
'right hump
call arc x6, y6, .5 * r * 2 ^ .5, DEG*a + 225, 180
END IF
end sub
sub drawShamrockN x, y, r, a, nLeafed
'local bigR, x1, x2, x3, y1, y2, y3
scan
np1 = nLeafed + 1
noLeaf = int(np1 / 2)
bigR = 2.2*r*np1 / (2*PI)
if nLeafed mod 2 = 0 then aoff = PI / np1
for leaf = 0 to nLeafed
if leaf <> noLeaf then
x1 = x + bigR * cos(a + leaf * 2*PI/np1 + 3*PI/2 + aoff)
y1 = y + bigR * sin(a + leaf * 2*PI/np1 + 3*PI/2 + aoff)
call drawSqueezedHeart x1, y1, r, bigR, a + leaf*2*PI/np1 + aoff
end if
next
end sub

« Last Edit: Mar 8^{th}, 2018, 11:58pm by tsh73 » 
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
member is offline
Gender:
Posts: 1286


Re: Happy St Patrick's Day
« Reply #8 on: Mar 9^{th}, 2018, 10:54am » 

I am lucky having tsh73 tips!
OK solid triangles to go with solid circles, saved so much time that we can do bigger shamrocks on bigger screen! (Just outlining shamrocks, also to save time.)
Code:'Shamrock 20180309.bas for JB v2b2 by bplus and tsh73
' removed need for USECIRCLE, added Andy Amaya's fill triangle for solid fill shamrocks
' mod tsh73 20180309 mod with USECIRCLE, arc fix but not quite there
' mod N leafed Shamrocks from Happy St Patrick's Day 20180308 <  edit date ;)
' from QB64: _TITLE "Happy St Patrick's Day by bplus 20180307"
' from: Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
H$ = "gr"
XMAX = 1280 '<======================================== actual drawing space needed
YMAX = 740 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 30
open " N Leafed Shamrocks, How Lucky Are You? (Stops when 7 leafer is made.) by bplus and tsh73 20180309" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "size 2"
dim count(7)
WHILE nLeafs < 7
scan
#gr "discard" 'to prevent memory buildup
luck = rnd(0)
select case
case luck <= 1/625 : nLeafs = 7
case luck <= 1/125 : nLeafs = 6
case luck <= 1/25 : nLeafs = 5
case luck <= 1/5 : nLeafs = 4
case else : nLeafs = 3
end select
count(nLeafs) = count(nLeafs) + 1
#gr "place 0 0"
#gr "backcolor white"
#gr "\\";right$("";100 + count(7), 2);":" _
;right$("";100 + count(6), 2);":" _
;right$("";100 + count(5), 2);":" _
;right$("";100 + count(4), 2);":" _
;right$("";10000 + count(3), 4)
cc1 = RND(0) * 100 + 50
cc2 = RND(0) * 100 + 50
while abs(cc2  cc1) < 20 'make them substantially different
cc2 = RND(0) * 100 + 50
wend
xp = RND(0) * (XMAX  100) + 50
yp = RND(0) * (YMAX  100) + 50
sz = INT(RND(0) * 30) + 10
ang = RND(0) * PI * 2
#gr "color ";0;" ";cc1;" ";0
#gr "backcolor ";0;" ";cc1;" ";0
call drawShamrockN xp, yp, sz, ang, nLeafs, 1
#gr "color ";0;" ";cc2;" ";0
call drawShamrockN xp, yp, sz, ang, nLeafs, 0
WEND
wait
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'20180309 two useless useX, useY lines removed!
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
for rAngle = rAngleStart to rAngleEnd step Stepper
if rAngle = rAngleStart then
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
else
nextX = xCenter + arcRadius * cos(rAngle)
nextY = yCenter + arcRadius * sin(rAngle)
#gr "line ";lastX;" ";lastY;" ";nextX;" ";nextY
lastX = nextX
lastY = nextY
end if
next
end sub
'Fast Filled Triangle Sub by AndyAmaya
Sub ftriangle x1, y1, x2, y2, x3, y3
scan
'triangle coordinates must be ordered: where x1 < x2 < x3
If x2 < x1 Then x = x2 : y = y2 : x2 = x1 : y2 = y1 : x1 = x : y1 = y
'swap x1, y1, with x3, y3
If x3 < x1 Then x = x3 : y = y3 : x3 = x1 : y3 = y1 : x1 = x : y1 = y
'swap x2, y2 with x3, y3
If x3 < x2 Then x = x3 : y = y3 : x3 = x2 : y3 = y2 : x2 = x : y2 = y
If x1 <> x3 Then slope1 = (y3  y1) / (x3  x1)
'draw the first half of the triangle
length = x2  x1
If length <> 0 Then
slope2 = (y2  y1) / (x2  x1)
For x = 0 To length
#gr "Line ";int(x + x1);" ";int(x * slope1 + y1);" ";int(x + x1);" ";int(x * slope2 + y1)
Next
End If
'draw the second half of the triangle
y = length * slope1 + y1 : length = x3  x2
If length <> 0 Then
slope3 = (y3  y2) / (x3  x2)
For x = 0 To length
#gr "Line ";int(x + x2);" ";int(x * slope1 + y);" ";int(x + x2);" ";int(x * slope3 + y2)
Next
End If
End Sub
sub drawShamrockN x, y, r, a, nLeafed, solid
scan
np1 = nLeafed + 1
noLeaf = int(np1 / 2)
bigR = 2.2 * r * np1 / (2 * PI)
if nLeafed mod 2 = 0 then aoff = PI / np1
for leaf = 0 to nLeafed
if leaf <> noLeaf then
x1 = x + bigR * cos(a + leaf * 2 * PI / np1 + 3 * PI / 2 + aoff)
y1 = y + bigR * sin(a + leaf * 2 * PI / np1 + 3 * PI / 2 + aoff)
call drawHeart x1, y1, r, bigR, a + leaf * 2 * PI / np1 + aoff, solid
end if
next
end sub
sub drawHeart x, y, r, rl, a, solid
scan
'clockwise from due East, the V
x1 = x + r * cos(a)
y1 = y + r * sin(a)
x2 = x + rl * cos(a + PI / 2)
y2 = y + rl * sin(a + PI / 2)
x3 = x + r * cos(a + PI)
y3 = y + r * sin(a + PI)
x4 = x + r * cos(a + 3 * PI / 2)
y4 = y + r * sin(a + 3 * PI / 2)
x5 = (x3 + x4) / 2
y5 = (y3 + y4) / 2
x6 = (x4 + x1) / 2
y6 = (y4 + y1) / 2
if solid then
call ftriangle x1, y1, x2, y2, x3, y3
call ftriangle x3, y3, x4, y4, x1, y1
#gr "place ";x5;" ";y5
#gr "circlefilled ";.5 * r * 2 ^ .5
#gr "place ";x6;" ";y6
#gr "circlefilled ";.5 * r * 2 ^ .5
else
#gr "line ";x1;" ";y1;" ";x2;" ";y2
#gr "line ";x2;" ";y2;" ";x3;" ";y3
'tsh73 I tried your version of arc (tarc) here for single outline of shamrock and not good
'left hump
call arc x5, y5, .5 * r * 2 ^ .5, DEG * a + 135, 180
'right hump
call arc x6, y6, .5 * r * 2 ^ .5, DEG * a + 225, 180
end if
end sub
'20180309 tsh73 this mod of arc does not draw the shamrock outline correctly
sub tarc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
lastX = xCenter + arcRadius * cos(rAngle)
lastY = yCenter + arcRadius * sin(rAngle)
#gr "set ";int(lastX);" ";int(lastY)
for rAngle = rAngleStart+Stepper to rAngleEnd step Stepper
nextX = xCenter + arcRadius * cos(rAngle)
nextY = yCenter + arcRadius * sin(rAngle)
#gr "goto ";int(nextX);" ";int(nextY) 'int speeds things up
next
end sub
Edit: Not lucky! had 3 leaves go past 1000.

« Last Edit: Mar 9^{th}, 2018, 11:17am by bplus » 
Logged

B+



tsh73
JBSupporter
member is offline
Gender:
Posts: 3662


Re: Happy St Patrick's Day
« Reply #9 on: Mar 9^{th}, 2018, 1:35pm » 

I miss contour shading (with arcs ) As for Quote:this mod of arc does not draw the shamrock outline correctly 

it needs rAngleStart for first point, not rAngle


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
member is offline
Gender:
Posts: 1286


Re: Happy St Patrick's Day
« Reply #10 on: Mar 9^{th}, 2018, 4:17pm » 

on Mar 9^{th}, 2018, 1:35pm, tsh73 wrote:I miss contour shading (with arcs ) :) As for
it needs rAngleStart for first point, not rAngle 

I miss it too and with the arc fix and reducing size some, it works fast enough, I think?
I WAS going to add stems to fill in missing leaf. Nope, won't look right so I spread leaves more evenly... Code:'Shamrock 20180309.bas for JB v2b2 by bplus and tsh73
' fix arc, return arc lines, space leaves evenly, dirt background
' removed need for USECIRCLE, added Andy Amaya's fill triangle for solid fill shamrocks
' mod tsh73 20180309 mod with USECIRCLE, arc fix but not quite there
' mod N leafed Shamrocks from Happy St Patrick's Day 20180308 <  edit date ;)
' from QB64: _TITLE "Happy St Patrick's Day by bplus 20180307"
' from: Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 20180307
global H$, XMAX, YMAX, PI, DEG, RAD
H$ = "gr"
XMAX = 1280 '<======================================== actual drawing space needed
YMAX = 740 '<======================================== actual drawing space needed
PI = acs(1)
DEG = 180 / PI
RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 30
open " N Leafed Shamrocks, How Lucky Are You? (Stops when 7 leafer is made.) by bplus and tsh73 20180309" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "fill 60 30 10"
#gr "size 1"
dim count(7)
WHILE nLeafs < 7
scan
#gr "discard" 'to prevent memory buildup
luck = rnd(0)
select case
case luck <= 1/625 : nLeafs = 7
case luck <= 1/125 : nLeafs = 6
case luck <= 1/25 : nLeafs = 5
case luck <= 1/5 : nLeafs = 4
case else : nLeafs = 3
end select
count(nLeafs) = count(nLeafs) + 1
#gr "place 0 0"
#gr "backcolor blue"
#gr "color black"
#gr "\\";right$("";100 + count(7), 2);":" _
;right$("";100 + count(6), 2);":" _
;right$("";100 + count(5), 2);":" _
;right$("";1000 + count(4), 3);":" _
;right$("";10000 + count(3), 4)
cc1 = RND(0) * 100 + 50
cc2 = RND(0) * 100 + 50
while abs(cc2  cc1) < 30 'make them substantially different
cc2 = RND(0) * 100 + 50
wend
xp = RND(0) * (XMAX  100) + 50
yp = RND(0) * (YMAX  100) + 50
sz = INT(RND(0) * 20) + 10
ang = RND(0) * PI * 2
#gr "color ";0;" ";cc1;" ";0
#gr "backcolor ";0;" ";int(cc1);" ";0
#gr "size 2" 'to fill holes
call drawShamrockN xp, yp, sz, ang, nLeafs, 1
#gr "size 1"
#gr "color ";0;" ";int(cc2);" ";0
for r = 2 to sz1 step 1
call drawShamrockN xp, yp, r, ang, nLeafs, 0
next
WEND
wait
'Need line: #gr "trapclose quit"
sub quit H$
close #H$ '<=== this needs Global H$ = "gr"
end 'Thanks Facundo, close graphic wo error
end sub
'Fast Filled Triangle Sub by AndyAmaya
Sub ftriangle x1, y1, x2, y2, x3, y3
scan
'triangle coordinates must be ordered: where x1 < x2 < x3
If x2 < x1 Then x = x2 : y = y2 : x2 = x1 : y2 = y1 : x1 = x : y1 = y
'swap x1, y1, with x3, y3
If x3 < x1 Then x = x3 : y = y3 : x3 = x1 : y3 = y1 : x1 = x : y1 = y
'swap x2, y2 with x3, y3
If x3 < x2 Then x = x3 : y = y3 : x3 = x2 : y3 = y2 : x2 = x : y2 = y
If x1 <> x3 Then slope1 = (y3  y1) / (x3  x1)
'draw the first half of the triangle
length = x2  x1
If length <> 0 Then
slope2 = (y2  y1) / (x2  x1)
For x = 0 To length
#gr "Line ";int(x + x1);" ";int(x * slope1 + y1);" ";int(x + x1);" ";int(x * slope2 + y1)
Next
End If
'draw the second half of the triangle
y = length * slope1 + y1 : length = x3  x2
If length <> 0 Then
slope3 = (y3  y2) / (x3  x2)
For x = 0 To length
#gr "Line ";int(x + x2);" ";int(x * slope1 + y);" ";int(x + x2);" ";int(x * slope3 + y2)
Next
End If
End Sub
sub drawShamrockN x, y, r, a, nLeafed, solid
scan
bigR = 2.05 * r * nLeafed / (2 * PI) '<< EDIT for fuller leaves
for leaf = 0 to nLeafed1
x1 = x + bigR * cos(a + leaf * 2 * PI / nLeafed + 3 * PI / 2 )
y1 = y + bigR * sin(a + leaf * 2 * PI / nLeafed + 3 * PI / 2 )
call drawHeart x1, y1, r, bigR, a + leaf * 2 * PI / nLeafed , solid
next
end sub
sub drawHeart x, y, r, rl, a, solid
scan
'clockwise from due East, the V
x1 = x + r * cos(a)
y1 = y + r * sin(a)
x2 = x + rl * cos(a + PI / 2)
y2 = y + rl * sin(a + PI / 2)
x3 = x + r * cos(a + PI)
y3 = y + r * sin(a + PI)
x4 = x + r * cos(a + 3 * PI / 2)
y4 = y + r * sin(a + 3 * PI / 2)
x5 = (x3 + x4) / 2
y5 = (y3 + y4) / 2
x6 = (x4 + x1) / 2
y6 = (y4 + y1) / 2
if solid then
call ftriangle x1, y1, x2, y2, x3, y3
call ftriangle x3, y3, x4, y4, x1, y1
#gr "place ";int(x5);" ";int(y5)
#gr "circlefilled ";int(.5 * r * 2 ^ .5)
#gr "place ";int(x6);" ";int(y6)
#gr "circlefilled ";int(.5 * r * 2 ^ .5)
else
#gr "line ";int(x1);" ";int(y1);" ";int(x2);" ";int(y2)
#gr "line ";int(x2);" ";int(y2);" ";int(x3);" ";int(y3)
'left hump
call arc x5, y5, .5 * r * 2 ^ .5, DEG * a + 135, 180
'right hump
call arc x6, y6, .5 * r * 2 ^ .5, DEG * a + 225, 180
end if
end sub
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure
'notes:
'you may want to adjust size and color for line drawing
'using angle measures in degrees to match Just Basic ways with pie and piefilled
'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart
rAngleEnd = RAD * dAMeasure + rAngleStart
Stepper = RAD / (.1 * arcRadius) 'fixed
lastX = xCenter + arcRadius * cos(rAngleStart)
lastY = yCenter + arcRadius * sin(rAngleStart)
#gr "set ";int(lastX);" ";int(lastY)
for rAngle = rAngleStart+Stepper to rAngleEnd step Stepper
nextX = xCenter + arcRadius * cos(rAngle)
nextY = yCenter + arcRadius * sin(rAngle)
#gr "goto ";int(nextX);" ";int(nextY) 'int speeds things up
next
end sub
So better?
A couple of edits: last was to fix 4 leaves going over 100 EDIT: 20180310 another edit for fuller leaves

« Last Edit: Mar 10^{th}, 2018, 06:54am by bplus » 
Logged

B+



bplus
Senior Member
member is offline
Gender:
Posts: 1286


Re: Happy St Patrick's Day
« Reply #11 on: Mar 10^{th}, 2018, 3:20pm » 

They were selling Shamrock plants at the grocery store today.
Ha! their plant leaves were all wrong, like someone cut off the round parts!


Logged

B+



