-
Can you draw this pattern:
[ This attachment cannot be displayed inline in 'Print Page' view ]
-
Sure I can, and in the easiest way imaginable!
-
;-)) Pretty hefty .bas file there Steve! But that's smart thinking. :)
Maybe someone can do it in a couple less MB's.
[ This attachment cannot be displayed inline in 'Print Page' view ]
-
Honestly, since it’s a black and white pattern, one can turn those data statements into a simple set of on/off counters. 3 white, 13 black, 33 white...
Instead of saving data as pixel by pixel, save that data as number of white, number of black, number of white... (3, 13, 33...)
It’d compress down to a fraction of the size. (Maybe even as small as your screenshot. ;-D)
-
Hi. I tried doing this in approx. 2KB, but I can not get closer than this. ;)
[ This attachment cannot be displayed inline in 'Print Page' view ]
_TITLE "Pattern Challenge Program by Ashish" rad = 50
a = 1
k = 0
k = 1
pattern x, y, rad, 0
k = 0
pattern x, y, rad, 0.85
a = 0
k = 0
k = 1
pattern x, y, rad, 0
k = 0
pattern x, y, rad, 0.85
SUB pattern
(x
, y
, r
, off_ang
) circ
(x
+ (COS(i
) * r
+ x
)) / 2, (y
+ (SIN(i
) * r
+ y
)) / 2, r
/ 2, r
/ 2, _RGB(254, 254, 254), i
, _PI + i
n = 1
SUB circ
(x
, y
, rx
, ry
, c~&
, theta1
, theta2
) LINE (COS(i
) * rx
+ x
, SIN(i
) * ry
+ y
)-(COS(i
+ 0.01) * rx
+ x
, SIN(i
+ 0.01) * ry
+ y
), c~&
-
Hi BPlus. Mine is not so good as your.
Second radius is ellipse?
sx2
= 50 + COS(pi
+ .3) * 25 sy2
= 50 + SIN(pi
+ .3) * 25 sx3
= 50 + COS(pi
+ _PI(2) / 6 + .2) * 20 sy3
= 50 + SIN(pi
+ _PI(2) / 6 + .2) * 20
PSET (sx
+ COS(c
+ pi
) * 25, sy
+ SIN(c
+ pi
) * 25) PSET (sx2
+ COS(c
+ pi
) * 25, sy2
+ SIN(c
+ pi
) * 25)
f = 0
g = 0
g = g + 1
f = f + 1
-
@Petr
That has nearly damaged my eyesight. :D
-
Hi Ashish. Am sorry :-D Bplus destroyed my brain :-D
-
@Petr and @Ashish,
You guys are definitely going places.
-
r = 70
swirl xx
*2*r
+ r
*(yy
and 1), 0 + yy
*2*r
*cos(pi
/6), r
xx
= x
+ 0.5*r
*cos(i
*pi
/3) yy
= y
+ 0.5*r
*sin(i
*pi
/3)
a = i*pi/3
-
@Petr and @Ashish,
You guys are definitely going places.
Yeppers!
Ashish, your trailing edge is a radius of a circle as the leading edge, a result I failed to achieve, nice!
Petr, your code has 2 lines more than mine and yours moves! also nice!
Oh Vince just posted! Dang! wow, nice concise code!!!
My trailing edge is not a radius of a circle, I'm not even sure it is ellipse.
If leading edge y = SQR(radius^2 - x^2) then trailing edge is a fraction of y, so I can make the crescent as thick or thin as I want. EDIT minus not plus
Yeah Petr, now I've got to get the cresents twirling too! ;-)) Plus.... :)
PS sorry for my poor spelling of crescent (the spell checker worked!)
-
@Vince
Perfect one!
-
Hi guys
for now I'm debugging my idea
to get the slices putting a circle up to another circle.. :-)
I must stop my idea for now. Job is calling!
here bugged code (only forn now)
x = (i * d) + k
y = i2 * d
r = d / 2
MakeSlice x, y, r, c~&
CIRCLE (ax
+ xp
, ay
+ yp
), ar
, col
Here partial result:
[ This attachment cannot be displayed inline in 'Print Page' view ]
I'll change circle with fillcircle of library of QB64 and I'll search the right number of circle to draw
-
Very nice, _vince!
-
Yes, Vince code is really nice compared to mine used to create the screen shot in original post:
CONST xmax
= 800, ymax
= 600 _TITLE "Cresent" 'mod B+ makeover started 2019-06-27
DIM polyR
, stepX
, stepY
, y
, x
, xoff
COLOR &HFF000000, &HFFFFFFFF polyR = 32
stepX = polyR * 4
stepY
= polyR
* 2 * SQR(3) cresentX6 x - xoff * 1.5 * stepX, y
DIM r
, x
, y
, py
, x1
, y1
, x2
, y2
, a
, dist1
, a1
, x3
, y3
, dist2
, a2
, x4
, y4
r = 32
py = .53 * y
x1 = x + x0 + r
y1 = y + y0
x2 = x1
y2 = py + y0
dist1
= SQR((x1
- x0
) ^ 2 + (y1
- y0
) ^ 2) x3
= x0
+ dist1
* COS(a1
+ a
) y3
= y0
+ dist1
* SIN(a1
+ a
)
dist2
= SQR((x2
- x0
) ^ 2 + (y2
- y0
) ^ 2) x4
= x0
+ dist2
* COS(a2
+ a
) y4
= y0
+ dist2
* SIN(a2
+ a
)
I was working up something to post at JB forum but JB does not have PAINT (nor POINT).
I have reworked Vince code without PAINT so I can show it off at JB! ;-))
swirl xx
* 2 * r
+ r
* (yy
AND 1), 0 + yy
* 2 * r
* COS(pi
/ 6) xx
= x
+ 0.5 * r
* COS(i
* pi
/ 3) - r
'Edit: this and next, removed variables not used yy
= y
+ 0.5 * r
* SIN(i
* pi
/ 3) + r
a = i * pi / 3
c = b - a
LINE (xx
+ 0.5 * r
* COS(b
), yy
+ 0.5 * r
* SIN(b
))-(xx
+ 0.5 * r
* COS(c
) * COS(a
) - 0.28 * r
* SIN(c
) * SIN(a
), yy
+ 0.5 * r
* COS(c
) * SIN(a
) + 0.28 * r
* SIN(c
) * COS(a
)), K
I reversed the B&W to save a line, to get lines to 20:
[ This attachment cannot be displayed inline in 'Print Page' view ]
-
Good news for all you math guys
my graphic idea has an overlapping logic bug ...
but it does the same something.
[ This attachment cannot be displayed inline in 'Print Page' view ]
x = (i * d) + k
y = i2 * d
r = d / 2
MakeSlice x, y, r, c~&
col2 = col
'CIRCLE (ax + xp, ay + yp), ar, col2
'PAINT STEP(0, 0), col2, col2
CALL CircleFill
(ax
+ xp
, ay
+ yp
, ar
, col2
) ' CIRCLE (ax + xp, ay + yp), ar, _RGB32(255, 255, 255)
' PAINT STEP(0, 0), _RGB32(255, 255, 255), _RGB32(255, 255, 255)
CALL CircleFill
(ax
+ xp
, ay
+ yp
, ar
, _RGB32(255, 255, 255))
' CX = center x coordinate
' CY = center y coordinate
' R = radius
' C = fill color
RadiusError = -Radius
X = Radius
Y = 0
LINE (CX
- X
, CY
)-(CX
+ X
, CY
), C
, BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), C
, BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), C
, BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), C
, BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), C
, BF
to complete the image a workaround may be to join two specular images of that showed on the screen... but it is so complex near your fantastic linear math code!
-
Hi TempodiBasic,
It's difficult trying to fit coding in with job and sleep, I remember burning the candle from both ends in 1993 or so...
Anyway for your overlap problem try drawing 1/2 circles, arcs!, instead of full circles. Get one going right, then worry about wallpapering the screen with them.
And thanks for using your precious time for this crazy thing. :-)
-
@Bplus
Thanks
about
Anyway for your overlap problem try drawing 1/2 circles, arcs!, instead of full circles.
I cannot face again with PAINT and CIRCLE lacking color.... not now!
And I have no knownledge that CircleFill and its brothers can draw arches!
... or is there no lacking color for halfcircle?
Instead to have an urticaria attack I left my keyboard and go walking with my dog before to go sleep!
See the next time. GoodNight
-
I found bplus's thread:
http://justbasiccom.proboards.com/thread/304/pattern-challenge?page=1&scrollTo=1804 (http://justbasiccom.proboards.com/thread/304/pattern-challenge?page=1&scrollTo=1804)
The original image is slightly different than bplus's and is easier to draw, technotitlick is on the right track, just needs some fine tuning. I like bplus's better though, looks like calligraphy.
Since some of you are playing with rotating the swirls, one neat effect is to have each rotating at different speeds, cleverly chosen, for a nice hypnotic effect.
-
reminds me of geometry problems from school where you have to find unknown distances and angles in a partially labelled diagrams, fun exercise
-
I found bplus's thread:
http://justbasiccom.proboards.com/thread/304/pattern-challenge?page=1&scrollTo=1804 (http://justbasiccom.proboards.com/thread/304/pattern-challenge?page=1&scrollTo=1804)
The original image is slightly different than bplus's and is easier to draw, technotitlick is on the right track, just needs some fine tuning. I like bplus's better though, looks like calligraphy.
Since some of you are playing with rotating the swirls, one neat effect is to have each rotating at different speeds, cleverly chosen, for a nice hypnotic effect.
Hi _vince,
The original image is easier to draw? The original image is a Hexagonal shape of twirls and at slight angle, which I imagine would be harder to replicate.
-
Hi TempodiBasic,
This must be what you are trying to say:
_TITLE "Crescent Pattern by Half Circle Arcs" CONST xmax
= 800, ymax
= 600, pi
= 3.14159265
crescent xmax / 2, ymax / 2, 50
SUB crescent
(x0
, y0
, r6
) 'r6 is radius of 6 crescent pattern DIM a12
, a
, r1
, x12
, y12
, stopa
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
'we need origin of the 12 arcs
'arc start angle = a end angle = a + pi = 1/2 circle
stopa = 2 * pi - (a + pi)
CIRCLE (x12
, y12
), r1
, , a
, 2 * pi
'<<< as I've said before CIRCLE sub sucks! CIRCLE (x12
, y12
), r1
, , 0, stopa
CIRCLE (x12
, y12
), r1
, , a
, a
+ pi
The operator of the CIRCLE command is probably partly to blame. :P
-
Never fear, B+ is here:
_TITLE "Crescent Pattern by Half Circle Arcs" CONST xmax
= 800, ymax
= 600, pi
= 3.14159265
crescent xmax / 2, ymax / 2, 50
SUB crescent
(x0
, y0
, r6
) 'r6 is radius of 6 crescent pattern r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
'we need origin of the 12 arcs
'arc start angle = a end angle = a + pi = 1/2 circle
arc x12, y12, r1, a, a + pi, &HFF0000FF
'x, y origin, r = radius, c = color
'raStart is first angle clockwise from due East = 0 degrees
' arc will start drawing there and clockwise until raStop angle reached
arc x
, y
, r
, raStart
, _PI(2), c
arc x, y, r, 0, raStop, c
' modified to easier way suggested by Steve
'Why was the line method not good? I forgot.
al
= _PI * r
* r
* (raStop
- raStart
) / _PI(2)
hmm... looks like we need arcs a little longer than half circles. :o
-
Outline looks OK, the start angle is the outer point, I was thinking wrongly it was the end angle.
_TITLE "Crescent Pattern by Half Circle Arcs" CONST xmax
= 800, ymax
= 600, pi
= 3.14159265
crescent xmax / 2, ymax / 2, 50
SUB crescent
(x0
, y0
, r6
) 'r6 is radius of 6 crescent pattern r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
'we need origin of the 12 arcs
'arc start angle = a end angle = a + pi = 1/2 circle
arc x12, y12, r1, a - pi / 6, a + pi, &HFF0000FF '<<<<<<<<<<<<<<<<<<<<<<<<<<<< start angle earlier
'x, y origin, r = radius, c = color
'raStart is first angle clockwise from due East = 0 degrees
' arc will start drawing there and clockwise until raStop angle reached
arc x
, y
, r
, raStart
, _PI(2), c
arc x, y, r, 0, raStop, c
' modified to easier way suggested by Steve
'Why was the line method not good? I forgot.
al
= _PI * r
* r
* (raStop
- raStart
) / _PI(2)
-
im on freebasic so ill just post the algorithm, but this one needed some manual fiddling, close enough for me
mine isnt pixel perfect for a few precision reasons, i challenge someone to perfectly reproduce the JB forum image, bonus points for antialiased edges
sw = 1920
sh = 1080
'fill in
xx = sw/2
yy = sh/2
a = pi/2 - pi/4 - pi/15 + 0.05 - 0.15
b = pi/6
c = 0.2
r = 100
for i = 0 to 5
x = xx + 2*r*cos(i*pi/3 + c)
y = yy + 2*r*sin(i*pi/3 + c)
for j = 0 to 5
p = x + 2*r*cos(j*pi/3 + c)
q = y + 2*r*sin(j*pi/3 + c)
rr = 1.03*r
for k = 0 to 5
u = k*pi/3 + a
circle (p + 0.5*rr*cos(u), q - 0.5*rr*sin(u)), 0.5*rr,, u+b, u+pi
circle (p + 0.5*rr*cos(u+ b), q - 0.5*rr*sin(u+ b)), 0.5*rr,, u, u+pi+b
'paint (p + 0.5*rr*cos(u+0.2), q - 0.5*rr*sin(u+0.2))
next
next
next
-
Looks good _vince!
I'm up to twirling:
_TITLE "Crescent Pattern by Half Circle Arcs" CONST xmax
= 800, ymax
= 600, pi
= 3.14159265 COLOR &HFF000000, &HFFFFFFFF aof = aof + 4 * pi / 36
crescent xmax / 2, ymax / 2, 50, aof
SUB crescent
(x0
, y0
, r6
, aoff
) 'r6 is radius of 6 crescent pattern DIM a12
, a
, r1
, x12
, y12
, i
, px
, py
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
FOR i
= 0 TO 11 'draw 12 arcs 'we need origin of the 12 arcs
x12
= x0
+ r1
* COS(i
* a12
+ aoff
) y12
= y0
+ r1
* SIN(i
* a12
+ aoff
) 'arc start angle = a end angle = a + pi = 1/2 circle
arc x12, y12, r1, i * a12 + aoff - pi / 6, i * a12 + aoff + pi, &HFFFFFFFE '<<<<<<<<<<<<<<<<<<<<<<<<<<<< start angle earlier
px
= x0
+ r1
* COS(i
* a12
+ aoff
+ pi
/ 12) py
= y0
+ r1
* SIN(i
* a12
+ aoff
+ pi
/ 12) 'CIRCLE (px, py), 2 'test for paint
PAINT (px
, py
), &HFF000000, &HFFFFFFFE 'leaks try line arc
'x, y origin, r = radius, c = color
'raStart is first angle clockwise from due East = 0 degrees
' arc will start drawing there and clockwise until raStop angle reached
arc x
, y
, r
, raStart
, _PI(2), c
arc x, y, r, 0, raStop, c
' modified to easier way suggested by Steve
'Why was the line method not good? I forgot.
al
= _PI * r
* r
* (raStop
- raStart
) / _PI(2)
-
@Bplus
thanks to translate my poor discussion
I cannot face again with PAINT and CIRCLE lacking color.... not now!
And I have no knownledge that CircleFill and its brothers can draw arches!
... or is there no lacking color for halfcircle?
in code experience that others can have
Hi TempodiBasic,
This must be what you are trying to say:
OPTION _EXPLICIT
_TITLE "Crescent Pattern by Half Circle Arcs"
CONST xmax = 800, ymax = 600, pi = 3.14159265
SCREEN _NEWIMAGE(xmax, ymax, 32)
crescent xmax / 2, ymax / 2, 50
SUB crescent (x0, y0, r6) 'r6 is radius of 6 crescent pattern
DIM a12, a, r1, x12, y12, stopa
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
FOR a = 0 TO 2 * pi STEP a12 'draw 12 arcs
'we need origin of the 12 arcs
x12 = x0 + r1 * COS(a)
y12 = y0 + r1 * SIN(a)
'arc start angle = a end angle = a + pi = 1/2 circle
IF a + pi > 2 * pi THEN
stopa = 2 * pi - (a + pi)
CIRCLE (x12, y12), r1, , a, 2 * pi '<<< as I've said before CIRCLE sub sucks!
CIRCLE (x12, y12), r1, , 0, stopa
ELSE
CIRCLE (x12, y12), r1, , a, a + pi
END IF
NEXT
END SUB
However great I see that now we have a new function for toolbox section! :-)
'x, y origin, r = radius, c = color
'raStart is first angle clockwise from due East = 0 degrees
' arc will start drawing there and clockwise until raStop angle reached
arc x
, y
, r
, raStart
, _PI(2), c
arc x, y, r, 0, raStop, c
' modified to easier way suggested by Steve
'Why was the line method not good? I forgot.
al
= _PI * r
* r
* (raStop
- raStart
) / _PI(2)
Very cool boys and girls of QB64! Very very cool!
-
TempodiBasic, you are not the only one confused by Drawing Arcs with CIRCLE. I learned Basic trig functions before using CIRCLE for Arcs and I find it hard to think backwards for CIRCLE command.
Why the CIRCLE command works Counter-Clockwise with the start and end angles is beyond me but it is inconsistent with all the Basic trig functions that go Clockwise around origin. It doesn't even make sense with the Y-axis increasing from due East 0 degrees or radians.
So yeah, if you need a Arc command that works consistently with the other Basic commands or functions put this Arc sub in your toolbox. It's even been reviewed by Steve. :-))
I think it always gets enough points to avoid leaks if you use the line as a border for PAINTing. Originally I used a line to connect the dots to assure no leaks (and you can do with less dots) but Steve did not like that one so I changed to just dots.
@Steve if you remember the reason, I wouldn't mind being reminded. :-)
Update: with twirling the patterns, they draw too slow to do a screen full of twirlers, so I will use Petr's method of snap shot images. I also like the shape of crescent pattern drawn originally, trailing edge is ellipse or ellipse like but not a circle arc or at least not a painted circular arc that leaves holes in middle and won't look right close to surrounding crescent patterns. Maybe I will try a line method to fill between leading and trailing edge of circular arcs first.
-
A different approach to this (I think; I haven't tried all the other demos fully, yet):
DEFLNG A-Z
SCREEN _NEWIMAGE(640, 480, 32)
DIM Colors(-1 TO 0)
Colors(-1) = &HFFFF0000 'Red
Colors(0) = &HFF0000FF 'Blue
FOR i = 0 TO 8
k = NOT k
x = 25 * SIN(_D2R(30 * i)) + 50
y = 25 * COS(_D2R(30 * i)) + 50
CIRCLE (x, y), 25, Colors(k)
PAINT (x, y), Colors(k)
NEXT
halfimage = _NEWIMAGE(50, 100, 32)
_PUTIMAGE , 0, halfimage, (50, 0)-(100, 100)
fullimage = _NEWIMAGE(100, 100, 32)
_DEST fullimage
DisplayImage halfimage, 50, 0, 0, 1
DisplayImage halfimage, 0, 0, 180, 4
_DEST 0
CLS , Colors(-1)
DO
angle = (angle + 1) MOD 360
FOR y = -50 TO _HEIGHT + 50 STEP 82
Insert = NOT Insert
FOR x = -50 TO _WIDTH + 50 STEP 100
DisplayImage fullimage, x + Insert * 50, y, angle, 0
NEXT
NEXT
_LIMIT 120
_DISPLAY
LOOP UNTIL _KEYHIT
SUB PlacePattern (Xwhere, Ywhere, WhichPattern)
DisplayImage WhichPattern, Xwhere, Ywhere, 0, 1
DisplayImage tempimage, Xwhere - 50, Ywhere, 180, 4
END SUB
SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
'Image is the image handle which we use to reference our image.
'x,y is the X/Y coordinates where we want the image to be at on the screen.
'angle is the angle which we wish to rotate the image.
'mode determines HOW we place the image at point X,Y.
'Mode 0 we center the image at point X,Y
'Mode 1 we place the Top Left corner of oour image at point X,Y
'Mode 2 is Bottom Left
'Mode 3 is Top Right
'Mode 4 is Bottom Right
DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
w = _WIDTH(Image): h = _HEIGHT(Image)
SELECT CASE mode
CASE 0 'center
px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
CASE 1 'top left
px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
px(1) = 0: py(1) = h: px(2) = w: py(2) = h
CASE 2 'bottom left
px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
CASE 3 'top right
px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
CASE 4 'bottom right
px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
END SELECT
sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
FOR i = 0 TO 3
x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
px(i) = x2: py(i) = y2
NEXT
_MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
END SUB
-
And a slight mod to the above, to give the "cogs" directionality, so that they appear as if they'd actually be turning as we'd expect to see in a machine.
DEFLNG A-Z
SCREEN _NEWIMAGE(640, 480, 32)
DIM Colors(-1 TO 0)
Colors(-1) = &HFFFF0000 'Red
Colors(0) = &HFF0000FF 'Blue
FOR i = 0 TO 8
k = NOT k
x = 25 * SIN(_D2R(30 * i)) + 50
y = 25 * COS(_D2R(30 * i)) + 50
CIRCLE (x, y), 25, Colors(k)
PAINT (x, y), Colors(k)
NEXT
halfimage = _NEWIMAGE(50, 100, 32)
_PUTIMAGE , 0, halfimage, (50, 0)-(100, 100)
fullimage = _NEWIMAGE(100, 100, 32)
_DEST fullimage
DisplayImage halfimage, 50, 0, 0, 1
DisplayImage halfimage, 0, 0, 180, 4
_DEST 0
CLS ', Colors(-1)
DO
angle = (angle + 1) MOD 360
FOR y = -50 TO _HEIGHT + 50 STEP 82
Insert = NOT Insert
IF Insert THEN direction = -1 ELSE direction = 1
FOR x = -50 TO _WIDTH + 50 STEP 100
DisplayImage fullimage, x + Insert * 50, y, direction * angle, 0
NEXT
NEXT
_DISPLAY
LOOP UNTIL _KEYHIT
SUB PlacePattern (Xwhere, Ywhere, WhichPattern)
DisplayImage WhichPattern, Xwhere, Ywhere, 0, 1
DisplayImage tempimage, Xwhere - 50, Ywhere, 180, 4
END SUB
SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
'Image is the image handle which we use to reference our image.
'x,y is the X/Y coordinates where we want the image to be at on the screen.
'angle is the angle which we wish to rotate the image.
'mode determines HOW we place the image at point X,Y.
'Mode 0 we center the image at point X,Y
'Mode 1 we place the Top Left corner of oour image at point X,Y
'Mode 2 is Bottom Left
'Mode 3 is Top Right
'Mode 4 is Bottom Right
DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
w = _WIDTH(Image): h = _HEIGHT(Image)
SELECT CASE mode
CASE 0 'center
px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
CASE 1 'top left
px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
px(1) = 0: py(1) = h: px(2) = w: py(2) = h
CASE 2 'bottom left
px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
CASE 3 'top right
px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
CASE 4 'bottom right
px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
END SELECT
sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
FOR i = 0 TO 3
x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
px(i) = x2: py(i) = y2
NEXT
_MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
END SUB
-
Hi Steve,
That is about the simplest, most direct, easy to understand (and math lazy) way to assemble a twirler yet, though I haven't studied Petr's or quite follow _vince method (even though I modified it to line fill method from PAINT).
I always thought a horizontal row of cogs would alternate in spinning, the way you have them packed I think they would not be able to spin at all (assuming they are all touching). ???
To all,
I did work out a line filled circular arc crescent pattern and it looks much better than the one filled with PAINT method, it might be judged too complex compared to Steve's method of rendering. Can he do tri-color twirlers?
_TITLE "Crescent Line Filled Circle Arcs" 'b+ 2019-06-29 CONST xmax
= 800, ymax
= 600, pi
= 3.14159265 COLOR &HFF000000, &HFFFFFFFF 'aof = 0 'ALL Stop to view fill: hey that's a darn good fill!!!!
aof = aof + pi / 18
crescentLFCA xmax / 2, ymax / 2, 50, aof
'cresecent Line Filled Circular Arcs combines arc drawing sub with crescentPattern sub
SUB crescentLFCA
(x0
, y0
, r6
, aoff
) 'r6 is radius of 6 crescent pattern DIM a12
, r1
, a6
, x6
, y6
, x6m12
, y6m12
, i
, al
, a
, x1
, y1
, x2
, y2
, c~&
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
a6 = 2 * pi / 6
FOR i
= 1 TO 6 'draw 6 crescents find x, y of leading and trailing edges x6
= x0
+ r1
* COS(i
* a6
+ aoff
): y6
= y0
+ r1
* SIN(i
* a6
+ aoff
) 'origins of leading edges x6m12
= x0
+ r1
* COS(i
* a6
- a12
+ aoff
): y6m12
= y0
+ r1
* SIN(i
* a6
- a12
+ aoff
) 'origins of trailing edges al
= _PI * r1
* r1
* (pi
+ pi
/ 6) / _PI(2) FOR a
= (i
* a6
+ aoff
- pi
/ 6) TO (i
* a6
+ aoff
+ pi
) STEP 1 / al
'draw arc chords for dist a x1
= x6
+ r1
* COS(a
): y1
= y6
+ r1
* SIN(a
) ' point on leading edge x2
= x6m12
+ r1
* COS(a
): y2
= y6m12
+ r1
* SIN(a
) 'eqivalent point on trailing edge c~& = &HFF990000
c~& = &HFF008800
c~& = &HFF000099
LINE (x1
, y1
)-(x2
, y2
), c~&
[ This attachment cannot be displayed inline in 'Print Page' view ]
Here is wallpaper version for tiny wall:
_TITLE "Crescent Line Filled Circular Arcs Wallpaper" CONST xmax
= 200, ymax
= 240, pi
= 3.14159265 DIM aof
, polyr
, stepX
, stepY
, y
, xoff
, x
polyr = 20
stepX = polyr * 2 + 1
stepY
= polyr
* 1 * SQR(3) + 1 xoff = 0
FOR y
= polyr
/ 2 TO ymax
- polyr
/ 2 STEP stepY
crescentLFCA x - xoff * 1.5 * stepX, y, polyr, aof
aof = aof + pi / 36
'cresecent Line Filled Circular Arcs combines arc drawing sub with crescentPattern sub
SUB crescentLFCA
(x0
, y0
, r6
, aoff
) 'r6 is radius of 6 crescent pattern DIM a12
, r1
, a6
, x6
, y6
, x6m12
, y6m12
, i
, al
, a
, x1
, y1
, x2
, y2
, c~&
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
a6 = 2 * pi / 6
FOR i
= 1 TO 6 'draw 6 crescents find x, y of leading and trailing edges x6
= x0
+ r1
* COS(i
* a6
+ aoff
): y6
= y0
+ r1
* SIN(i
* a6
+ aoff
) 'origins of leading edges x6m12
= x0
+ r1
* COS(i
* a6
- a12
+ aoff
): y6m12
= y0
+ r1
* SIN(i
* a6
- a12
+ aoff
) 'origins of trailing edges al
= _PI * r1
* r1
* (pi
+ pi
/ 6) / _PI(2) FOR a
= (i
* a6
+ aoff
- pi
/ 6) TO (i
* a6
+ aoff
+ pi
) STEP 1 / al
'draw arc chords for dist a x1
= x6
+ r1
* COS(a
): y1
= y6
+ r1
* SIN(a
) ' point on leading edge x2
= x6m12
+ r1
* COS(a
): y2
= y6m12
+ r1
* SIN(a
) 'eqivalent point on trailing edge c~& = &HFF990000
c~& = &HFF008800
c~& = &HFF000099
LINE (x1
, y1
)-(x2
, y2
), c~&
-
Hi Steve,
That is about the simplest, most direct, easy to understand (and math lazy) way to assemble a twirler yet, though I haven't studied Petr's or quite follow _vince method (even though I modified it to line fill method from PAINT).
I always thought a horizontal row of cogs would alternate in spinning, the way you have them packed I think they would not be able to spin at all (assuming they are all touching). ???
To all,
I did work out a line filled circular arc crescent pattern and it looks much better than the one filled with PAINT method, it might be judged too complex compared to Steve's method of rendering. Can he do tri-color twirlers?
Looking at these, they appear to me to be more like designs on the edge of a wheel, than they do to be actual gears. As such, the idea that each row would rotate in an opposite direction is rather quite natural (at least to my way of thinking). The first row of "wheels" all rotate to the right, and the row under them would rotate to the left, with the next row rotating back to the right -- which is why I coded it the way I have.
As for using multiple colors, that's an easy modification as well:
DEFLNG A-Z
SCREEN _NEWIMAGE(640, 480, 32)
DIM Colors(3)
Colors(0) = &HFFFF0000 'Red
Colors(1) = &HFF0000FF 'Blue
Colors(2) = &HFF00FF00 'Green
Colors(3) = &HFFF0F00F 'Something... I just made up a value!
FOR i = 0 TO 8
k = i MOD 4
x = 25 * SIN(_D2R(30 * i)) + 50
y = 25 * COS(_D2R(30 * i)) + 50
CIRCLE (x, y), 25, Colors(k)
PAINT (x, y), Colors(k)
NEXT
halfimage = _NEWIMAGE(50, 100, 32)
_PUTIMAGE , 0, halfimage, (50, 0)-(100, 100)
fullimage = _NEWIMAGE(100, 100, 32)
_DEST fullimage
DisplayImage halfimage, 50, 0, 0, 1
DisplayImage halfimage, 0, 0, 180, 4
_DEST 0
CLS ', Colors(-1)
DO
angle = (angle + 1) MOD 360
FOR y = -50 TO _HEIGHT + 50 STEP 82
Insert = NOT Insert
IF Insert THEN direction = -1 ELSE direction = 1
FOR x = -50 TO _WIDTH + 50 STEP 100
DisplayImage fullimage, x + Insert * 50, y, direction * angle, 0
NEXT
NEXT
_DISPLAY
LOOP UNTIL _KEYHIT
SUB PlacePattern (Xwhere, Ywhere, WhichPattern)
DisplayImage WhichPattern, Xwhere, Ywhere, 0, 1
DisplayImage tempimage, Xwhere - 50, Ywhere, 180, 4
END SUB
SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
'Image is the image handle which we use to reference our image.
'x,y is the X/Y coordinates where we want the image to be at on the screen.
'angle is the angle which we wish to rotate the image.
'mode determines HOW we place the image at point X,Y.
'Mode 0 we center the image at point X,Y
'Mode 1 we place the Top Left corner of oour image at point X,Y
'Mode 2 is Bottom Left
'Mode 3 is Top Right
'Mode 4 is Bottom Right
DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
w = _WIDTH(Image): h = _HEIGHT(Image)
SELECT CASE mode
CASE 0 'center
px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
CASE 1 'top left
px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
px(1) = 0: py(1) = h: px(2) = w: py(2) = h
CASE 2 'bottom left
px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
CASE 3 'top right
px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
CASE 4 'bottom right
px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
END SELECT
sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
FOR i = 0 TO 3
x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
px(i) = x2: py(i) = y2
NEXT
_MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
END SUB
The above has a real pretty little FOUR color pattern, which (I think, at least) helps to showcase the directional spin on our wheels. ;)
-
I apologize in advance for the fact that this is only partially related to the topic. How to rotate the image - My frame method is memory -intensive as I have shown them. Turning with Steve's method in turn consumes a small amount of power. The worst method is direct rotation and direct rendering of everything at once. It depends on the particular program, when it fits best.
With both rotation method and with SaveImage can every from us easy sprite image files to do. If you set rotation center to correct place, you can rotate just piece of image for example, just the character's hand, but not the whole character....
Bplus here hidden draw galaxy...
OPTION _EXPLICIT
_TITLE "Crescent Line Filled Circle Arcs" 'b+ 2019-06-29
CONST xmax = 800, ymax = 600, pi = 3.14159265
DIM aof
DIM Frames(35) AS LONG, CreateFrames AS INTEGER, X AS SINGLE, Z AS SINGLE, angle AS SINGLE, height AS SINGLE, f AS _BYTE
FOR CreateFrames = 0 TO 35
Frames(CreateFrames) = _NEWIMAGE(101, 101, 32)
_DEST Frames(CreateFrames)
CLS
'aof = 0 'ALL Stop to view fill: hey that's a darn good fill!!!!
aof = aof + pi / 18
crescentLFCA 50, 50, 50, aof
_CLEARCOLOR &HFF000000
NEXT
_DEST 0
transform Frames()
_DISPLAYORDER _SOFTWARE , _HARDWARE
DO
Circled X, Z, angle, 1.3
angle = angle + .01
FOR height = 1.2 - Z TO 1.2 - Z + .1 STEP .01 'this is BAD METHOD, because i am too lasy. For best power muss be next segment defined and draw between segment A and segment B with MAPTRIANGLE.
view3D 0 + X, height, -4 + Z, Frames(), f
NEXT
LOCATE 1, 1: PRINT "BPlus created color galaxy!"
_DISPLAY
f = f - 1: IF f < LBOUND(frames) THEN f = UBOUND(frames)
_LIMIT 20
LOOP
'cresecent Line Filled Circular Arcs combines arc drawing sub with crescentPattern sub
SUB crescentLFCA (x0, y0, r6, aoff) 'r6 is radius of 6 crescent pattern
DIM a12, r1, a6, x6, y6, x6m12, y6m12, i, al, a, x1, y1, x2, y2, c~&
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
a6 = 2 * pi / 6
FOR i = 1 TO 6 'draw 6 crescents find x, y of leading and trailing edges
x6 = x0 + r1 * COS(i * a6 + aoff): y6 = y0 + r1 * SIN(i * a6 + aoff) 'origins of leading edges
x6m12 = x0 + r1 * COS(i * a6 - a12 + aoff): y6m12 = y0 + r1 * SIN(i * a6 - a12 + aoff) 'origins of trailing edges
al = _PI * r1 * r1 * (pi + pi / 6) / _PI(2)
FOR a = (i * a6 + aoff - pi / 6) TO (i * a6 + aoff + pi) STEP 1 / al 'draw arc chords for dist a
x1 = x6 + r1 * COS(a): y1 = y6 + r1 * SIN(a) ' point on leading edge
x2 = x6m12 + r1 * COS(a): y2 = y6m12 + r1 * SIN(a) 'eqivalent point on trailing edge
IF i MOD 3 = 0 THEN
c~& = &HFF990000
ELSEIF i MOD 3 = 1 THEN
c~& = &HFF008800
ELSEIF i MOD 3 = 2 THEN
c~& = &HFF000099
END IF
LINE (x1, y1)-(x2, y2), c~&
NEXT
NEXT
END SUB
SUB transform (arr() AS LONG)
DIM t AS INTEGER, img32 AS LONG
FOR t = LBOUND(arr) TO UBOUND(arr)
img32 = _COPYIMAGE(arr(t))
arr(t) = _COPYIMAGE(img32, 33)
_FREEIMAGE img32
NEXT
END SUB
SUB view3D (x AS SINGLE, y AS SINGLE, z AS SINGLE, arr() AS LONG, frameNR AS INTEGER)
DIM w AS INTEGER, h AS INTEGER, width3d AS _BYTE, height3d AS _BYTE, depth3d AS _BYTE
w = _WIDTH(arr(frameNR))
h = _HEIGHT(arr(frameNR))
width3d = 1
height3d = 1
depth3d = 1
_MAPTRIANGLE (0, 0)-(w, 0)-(0, h), arr(frameNR) TO(x - width3d, y - height3d, z - 3 * depth3d)-(x + width3d, y - height3d, z - 3 * depth3d)-(x - width3d, y - height3d, z + 3 * depth3d)
_MAPTRIANGLE (w, 0)-(0, h)-(w, h), arr(frameNR) TO(x + width3d, y - height3d, z - 3 * depth3d)-(x - width3d, y - height3d, z + 3 * depth3d)-(x + width3d, y - height3d, z + 3 * depth3d)
END SUB
SUB Circled (GetX, GetZ, angle, radius)
GetX = SIN(angle) * radius
GetZ = COS(angle) * radius
END SUB
-
Thanks Petr for taking code to a higher place :D
Eye Champagne:
_TITLE "Cresent Pattern in Cog Layout" 'b+ 2019-06-29 using part of Petr's mod and Steve's cog idea, I mod again CONST xmax
= 800, ymax
= 600, pi
= 3.14159265
FOR CreateFrames
= 0 TO 35 Frames
(CreateFrames
) = _NEWIMAGE(101, 101, 32) _DEST Frames
(CreateFrames
) 'aof = 0 'ALL Stop to view fill: hey that's a darn good fill!!!!
aof = aof + pi / 18
crescentLFCA 50, 50, 50, aof
chColor
xAlt = yAlt
_PUTIMAGE (x
+ 100, y
)-STEP(100, 100), Frames
(f
), 0, (100, 0)-(0, 100) _PUTIMAGE (x
+ 100, y
)-STEP(100, 100), Frames
(f
), 0, (0, 0)-(100, 100)
'cresecent Line Filled Circular Arcs combines arc drawing sub with crescentPattern sub
SUB crescentLFCA
(x0
, y0
, r6
, aoff
) 'r6 is radius of 6 crescent pattern DIM a12
, r1
, a6
, x6
, y6
, x6m12
, y6m12
, i
, al
, a
, x1
, y1
, x2
, y2
, c~&
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
a6 = 2 * pi / 6
al
= _PI * r1
* r1
* (pi
+ pi
/ 6) / _PI(2) '<<<<<<<<<<<<<<<< this needs to be calc only once FOR i
= 1 TO 6 'draw 6 crescents find x, y of leading and trailing edges x6
= x0
+ r1
* COS(i
* a6
+ aoff
): y6
= y0
+ r1
* SIN(i
* a6
+ aoff
) 'origins of leading edges x6m12
= x0
+ r1
* COS(i
* a6
- a12
+ aoff
): y6m12
= y0
+ r1
* SIN(i
* a6
- a12
+ aoff
) 'origins of trailing edges FOR a
= (i
* a6
+ aoff
- pi
/ 6) TO (i
* a6
+ aoff
+ pi
) STEP 1 / al
'draw arc chords for dist a x1
= x6
+ r1
* COS(a
): y1
= y6
+ r1
* SIN(a
) ' point on leading edge x2
= x6m12
+ r1
* COS(a
): y2
= y6m12
+ r1
* SIN(a
) 'eqivalent point on trailing edge c~& = &HFF990000
c~& = &HFF008800
c~& = &HFF000099
LINE (x1
, y1
)-(x2
, y2
), c~&
clr = clr + .3
-
Hi _vince,
I got as far as I could translating your algo to QB64. First I had to cut down screen size and scale radius.
Then replace CIRCLE commands with my Arc code because kept getting illegal calls with CIRCLE.
Then to get a decent draw I had to change sign on y coordinate as noted below.
OK got a hexagonal shape of twirls but! they are misaligned a bit, the crescents are at wrong angles for nice draw.
Then go to PAINT and the PAINT points all fit in crescents but the first is drawn outside the crescent drawn causing paint to paint entire the screen.
I think there is just one angle that needs fixing so everything lines up correctly.
_TITLE "Cresent Pattern in Hexagon Layout" 'b+ translated algo 2019-06-29
CONST sw
= 1068, sh
= 600, pi
= 3.14159265
'sw = 1920 ' 1.78 ratio 600 X 1.78 = 1068
'sh = 1080
'fill in
DIM xx
, yy
, a
, b
, c
, r
, i
AS INTEGER, x
, y
, j
AS INTEGER, p
, q
, rr
, k
AS INTEGER, u
xx = sw / 2
yy = sh / 2
a = pi / 2 - pi / 4 - pi / 15 + 0.05 - 0.15
b = pi / 6
c = 0.2
r = 100 / 1.78
x
= xx
+ 2 * r
* COS(i
* pi
/ 3 + c
) y
= yy
+ 2 * r
* SIN(i
* pi
/ 3 + c
) p
= x
+ 2 * r
* COS(j
* pi
/ 3 + c
) q
= y
+ 2 * r
* SIN(j
* pi
/ 3 + c
)
rr = 1.03 * r
u = k * pi / 3 + a
' In next lines I change y coordinate q - ... to q + ... or get crap!
arc p
+ 0.5 * rr
* COS(u
), q
+ 0.5 * rr
* SIN(u
), 0.5 * rr
, u
+ b
, u
+ pi
, &HFF0000FF arc p
+ 0.5 * rr
* COS(u
+ b
), q
+ 0.5 * rr
* SIN(u
+ b
), 0.5 * rr
, u
, u
+ pi
+ b
, &HFF0000FF
'test paint points oops they are all outside the last drawn crescent!
CIRCLE (p
+ 0.5 * rr
* COS(u
+ 0.2), q
+ 0.5 * rr
* SIN(u
+ 0.2)), 2 'test point 'PAINT (p + 0.5 * rr * COS(u + 0.2), q + 0.5 * rr * SIN(u + 0.2)), &HFFFFFFFF, &HFF0000FF
'x, y origin, r = radius, c = color
'raStart is first angle clockwise from due East = 0 degrees
' arc will start drawing there and clockwise until raStop angle reached
arc x
, y
, r
, raStart
, _PI(2), c
arc x, y, r, 0, raStop, c
' modified to easier way suggested by Steve
'Why was the line method not good? I forgot.
al
= _PI * r
* r
* (raStop
- raStart
) / _PI(2)
I think you can find the angle faster than I.
This gave me idea how to layout a Hexagon pattern though! :-)
-
OK Tricolor Crescent Pattern on slightly tilted Hexagonal Layout:
_TITLE "Crescent LFCA Hexagonal Layout" 'b+ 2019-06-29 LFCA = Lined Filled Circular Arcs CONST xmax
= 800, ymax
= 600, pi
= 3.14159265
DIM h
(45) AS xy
, tilt
, hex
, x0
, y0
, a
, i
, r
, j
, k
, cnt
r = 50
tilt = -pi / 8 'looks to match original challenge
hex = 2 * pi / 6
x0 = xmax / 2
y0 = ymax / 2
h
(i
).x
= x0
+ 2 * r
* COS(a
) h
(i
).y
= y0
+ 2 * r
* SIN(a
) i = i + 1
'PRINT k, h(k).x, h(k).y
h
(i
).x
= h
(j
).x
+ 2 * r
* COS(a
) h
(i
).y
= h
(j
).y
+ 2 * r
* SIN(a
) 'PRINT i, h(i).x, h(i).y
i = i + 1
i = i - 1
IF h
(j
).x
= h
(k
).x
AND h
(j
).y
= h
(k
).y
THEN h
(k
).x
= 0 IF h
(j
).x
<> 0 THEN cnt
= cnt
+ 1:
PRINT h
(j
).x
, h
(j
).y: crescentLFCA h
(j
).x
, h
(j
).y
, r
, -3 * tilt
'cresecent Line Filled Circular Arcs combines arc drawing sub with crescentPattern sub
SUB crescentLFCA
(x0
, y0
, r6
, aoff
) 'r6 is radius of 6 crescent pattern DIM a12
, r1
, a6
, x6
, y6
, x6m12
, y6m12
, i
, al
, a
, x1
, y1
, x2
, y2
, c~&
r1 = r6 / 2 ' the radius of each crescent
a12 = 2 * pi / 12 ' 30 degrees to draw 12 arcs about x0, y0
a6 = 2 * pi / 6
al
= 10 * _PI * r1
* r1
* (pi
+ pi
/ 6) / _PI(2) FOR i
= 1 TO 6 'draw 6 crescents find x, y of leading and trailing edges x6
= x0
+ r1
* COS(i
* a6
+ aoff
): y6
= y0
+ r1
* SIN(i
* a6
+ aoff
) 'origins of leading edges x6m12
= x0
+ r1
* COS(i
* a6
- a12
+ aoff
): y6m12
= y0
+ r1
* SIN(i
* a6
- a12
+ aoff
) 'origins of trailing edges FOR a
= (i
* a6
+ aoff
- pi
/ 6) TO (i
* a6
+ aoff
+ pi
) STEP 1 / al
'draw arc chords for dist a x1
= x6
+ r1
* COS(a
): y1
= y6
+ r1
* SIN(a
) ' point on leading edge x2
= x6m12
+ r1
* COS(a
): y2
= y6m12
+ r1
* SIN(a
) 'eqivalent point on trailing edge c~& = &HFF990000
c~& = &HFF008800
c~& = &HFF000099
LINE (x1
, y1
)-(x2
, y2
), c~&
The angles of tilt were eyeballed but turns out it was about -pi/8 then I had to turn the crescent patterns until they matched up at the nice round number of -3*tilt.
-
Nice work bplus, that's pretty much it. I think the way the original image has them interconnected is by giving the arcs a radius slightly larger than half the radius of the invisible circle within which they're embedded, which explains the rr = 1.01*r line in my code but in yours it looks like you connected them with a thin rectangle. Anyways, I think we've beaten this pattern to death, lets find more!