Ok. I fixed the color. It is not missing the pattern. The shapes are just overlapping each other..... and I think it must be within the rule of this
challenge.
Only thing I really noticed that seemed off is just a little math. Your polygons are from the outer ring of your circle and not the inner ring. ;)
Now, for some honesty on my part: The screenshot produced
wasn't the actual results which I was looking for -- it's a glitched pattern which I thought was kinda cute and decided to share.
The glitchy code to produce our perfectly imperfect pattern is this one:
CONST Gold
= &HFFFFD700~&
' _RGB32(255,215,0) CONST Silver
= &HFFC0C0C0~&
' _RGB32(192,192,192)
CircleScreen
= _NEWIMAGE(400, 400, 32) '200 radius outer circle
CreateBlendedScreen
k(3) = Gold
k(4) = Silver
k(5) = &HFFFF0000 'Red
k(6) = &HFFFFFFFF 'White
k(7) = &HFF0000FF 'Blue
length = 200
DrawPattern x
, y
, length
, width, i
, k
(i
)
CreateCircleScreen Xcenter
, Ycenter
, Radius
, Width DisplayImage ViewScreen, Xcenter, Ycenter, 0, 0
CreatePolygon Xcenter
, Ycenter
, Radius
- Width, Width, N
, Kolor
x = 0
x
= Xcenter
+ SIN(p
) * Radius
y
= YCenter
+ COS(p
) * Radius
x2
= Xcenter
+ SIN(p
) * Radius
y2
= YCenter
+ COS(p
) * Radius
LINE (x
, y
)-(x2
, y2
), Kolor
x
= Xcenter
+ SIN(p
) * (Radius
+ width / 2) y
= YCenter
+ COS(p
) * (Radius
+ width / 2)
'CreateCircleScreen = _NEWIMAGE(radius * 2, radius * 2, 32)
'_DEST CreateCircleScreen
ai = 360 / p
x
= Xcenter
+ SIN(a
) * (radius
- w
) y
= YCenter
+ COS(a
) * (radius
- w
) ' _DEST ViewScreen
'step from red to green
kolor = kolor + 1
kolor = kolor - 1
kolor = kolor + 1
kolor = kolor - 1
kolor = kolor + 1
kolor = kolor - 1
'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
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
px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
px(1) = 0: py(1) = h: px(2) = w: py(2) = h
px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
sinr
= SIN(angle
/ 57.2957795131): cosr
= COS(angle
/ 57.2957795131) x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
px(i) = x2: py(i) = y2
_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))
The actual pattern I was looking for is this one (which requires only a single line remarked out):
_DEFINE A-Z AS _FLOAT
DIM SHARED ViewScreen, BlendedScreen
CONST Gold = &HFFFFD700~& ' _RGB32(255,215,0)
CONST Silver = &HFFC0C0C0~& ' _RGB32(192,192,192)
ViewScreen = _NEWIMAGE(800, 800, 32): SCREEN ViewScreen
BlendedScreen = _NEWIMAGE(1536, 100, 32)
CircleScreen = _NEWIMAGE(400, 400, 32) '200 radius outer circle
CreateBlendedScreen
width = 6
DIM k(3 TO 7) AS _UNSIGNED LONG
k(3) = Gold
k(4) = Silver
k(5) = &HFFFF0000 'Red
k(6) = &HFFFFFFFF 'White
k(7) = &HFF0000FF 'Blue
FOR x = 200 TO 600 STEP 400
FOR y = 200 TO 600 STEP 400
length = 200
FOR i = 3 TO 7
DrawPattern x, y, length, width, i, k(i)
length = (length - 2 * width) * COS(_PI / i) - 1
NEXT
NEXT
NEXT
SLEEP
END
SUB DrawPattern (Xcenter, Ycenter, Radius, Width, N, Kolor AS _UNSIGNED LONG)
CreateCircleScreen Xcenter, Ycenter, Radius, Width
'DisplayImage ViewScreen, Xcenter, Ycenter, 0, 0
CreatePolygon Xcenter, Ycenter, Radius - Width, Width, N, Kolor
END SUB
SUB CreatePolygon (Xcenter, YCenter, Radius AS LONG, width AS LONG, N AS LONG, Kolor AS _UNSIGNED LONG)
a = _PI(2) / N
FOR i = 0 TO 1
x = 0
IF i THEN Radius = Radius - width
FOR p = 0 TO _PI(2) STEP a
IF x THEN oldx = x: oldy = y
x = Xcenter + SIN(p) * Radius
y = YCenter + COS(p) * Radius
IF oldx THEN LINE (oldx, oldy)-(x, y), Kolor
NEXT
x2 = Xcenter + SIN(p) * Radius
y2 = YCenter + COS(p) * Radius
LINE (x, y)-(x2, y2), Kolor
NEXT
x = Xcenter + SIN(p) * (Radius + width / 2)
y = YCenter + COS(p) * (Radius + width / 2)
PAINT (x, y), Kolor
END SUB
SUB CreateCircleScreen (Xcenter, YCenter, radius AS LONG, width AS LONG)
'CreateCircleScreen = _NEWIMAGE(radius * 2, radius * 2, 32)
'_DEST CreateCircleScreen
p = _PI(2) * radius
tempimage = _NEWIMAGE(p, width, 32)
_PUTIMAGE , BlendedScreen, tempimage
_SOURCE tempimage
FOR i = 0 TO p - 1 STEP .25
FOR w = 0 TO width - 1
ai = 360 / p
a = _D2R(ai * i)
x = Xcenter + SIN(a) * (radius - w)
y = YCenter + COS(a) * (radius - w)
PSET (x, y), POINT(i, w)
NEXT
NEXT
_SOURCE ViewScreen
' _DEST ViewScreen
_FREEIMAGE tempimage
END SUB
SUB CreateBlendedScreen
'step from red to green
DIM kolor AS _FLOAT, i AS _FLOAT
_DEST BlendedScreen
FOR i = 0 TO 255
kolor = kolor + 1
LINE (i, 0)-STEP(0, 99), _RGB32(255, kolor, 0)
NEXT
FOR i = 256 TO 511
kolor = kolor - 1
LINE (i, 0)-STEP(0, 99), _RGB32(kolor, 255, 0)
NEXT
FOR i = 512 TO 767
kolor = kolor + 1
LINE (i, 0)-STEP(0, 99), _RGB32(0, 255, kolor)
NEXT
FOR i = 768 TO 1023
kolor = kolor - 1
LINE (i, 0)-STEP(0, 99), _RGB32(0, kolor, 255)
NEXT
FOR i = 1024 TO 1279
kolor = kolor + 1
LINE (i, 0)-STEP(0, 99), _RGB32(kolor, 0, 255)
NEXT
FOR i = 1280 TO 1535
kolor = kolor - 1
LINE (i, 0)-STEP(0, 99), _RGB32(255, 0, kolor)
NEXT
_DEST ViewScreen
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
Line 36 is remarked out, as I changed my methodology in the midst of my coding. At first, I was going to take blended lines as well, rotate them and place them at their midpoints so they'd fit in the proper slots, but then I decided not to worry with it. I would've had to map segments of the overall blended colors to each side, to run the blended pattern across the whole polygon, and I just didn't think it was worth the hassle. All I needed was a nice little pattern set so I could print out some colorful CD/DVD labels, and to be honest, I was just too lazy to go through the effort to blend the lines as well. :P
In the steps of removing the polygon line blending (and use of DisplayImage for rotational ease at the center point), I tested what I *thought* should produce my desired pattern -- only to blink stupidly and say, "What the Taco Bell????????"...
... And thus, I shared the glitch, just 'cause I found it rather amusing. ;D