Page 1 of 1

Lazy Spiral

Posted: Mon Nov 24, 2008 5:43 am
by Allosentient
Lazy Spiral

How to solve (Windows)

1: Open image in paint, save as 24-bit BMP
2. Paintbucket all of the background pure black
3. Use red pencil to mark each of the dots once. You do not have to be exact, but the dots must follow the following rules:
a) all dots same color
b) original image doesn't contain any pixel with the dot color
c) dots do not touch each other (1 pixel wide)
d) dots do not touch background or different color circles
e) if there is a chain of X similar big orange/white dots, you may put X number of red dots anywhere in that group, provided that they follow the above rules. However, depending on your program, it may fail if the dots are too far apart or if they deviate too far from the original pattern

4. Use .NET System.Drawing to modify the image to contain only 4 colors

if (!File.Exists(@"..\..\..\spiral2-Comp.bmp"))
WriteCompFile(spiralImgBmp, @"..\..\..\spiral2-Comp.bmp");


private void WriteCompFile(Bitmap spiralImgBmp, string newCompFilePath)
{
List<Color> colors = new List<Color>();
for (int x = 0; x < spiralImgBmp.Width; x++)
{
for (int y = 0; y < spiralImgBmp.Height; y++)
{
Color color = spiralImgBmp.GetPixel(x, y);
color = SnapColorValue(color);
if (!colors.Contains(color))
colors.Add(color);
spiralImgBmp.SetPixel(x, y, TranslateColor(color));
}
}
spiralImgBmp.Save(newCompFilePath);
}

private Color SnapColorValue(Color color)
{
byte b = SnapColorByte(color.B);
byte r = SnapColorByte(color.R);
byte g = SnapColorByte(color.G);
color = Color.FromArgb(r, g, b);
return color;
}

private byte SnapColorByte(byte p)
{
if (p > 0)
p = (byte)(p - (p % 64));
return p;
}

private Color TranslateColor(Color color)
{
if (color.B == 0 && color.G == 0 && color.R == 0)
return Color.Black;
if (color.B == color.G && color.G == color.R)
return Color.White;
if (color.R > 190 && color.G == 0 && color.B == 0)
return Color.Red;
return Color.Orange;
}


5. In your program, make a list of all red dots, with their location. Pick a dot for your starting location, and set that as "Current Location". Remove "Current Location" from the list of red dots, then search for the closest red dot in the list, then record the color that is directly next to that dot, then set that dot to current location. Rinse and repeat until all colors are recorded, then just convert them to bytes as you did in Spiral Bits.

Posted: Tue Jan 31, 2012 11:01 am
by dangermouse
For me, this was easy to solve, as all techniques were already developed for 'Spiral Bits'. Additionally, circles were not overlapping, so it was overall easier than the previous Spiral challenge.

And the main discovery was: even if the decoding is not perfect, GIMP was able to show the image :-)

Posted: Wed Apr 23, 2014 9:10 pm
by Hippo
I have used base from the spiral bits, but I have to help with navigation in 3 places.
But definitely faster thanks to a lot of work already done.