This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class WheelPrimeEnumerator : IEnumerator<int> | |
| { | |
| private readonly IEnumerator<int> _candidates = | |
| new WheelSequence(11, | |
| new BrokenRecord<int>( | |
| new[] { 4, 2, 4, 2, 4, 6, 2, 6 } | |
| ) | |
| ).GetEnumerator(); | |
| private readonly IPriorityQueue<NumberEnumerator> _pq = | |
| new IntervalHeap<NumberEnumerator>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class WheelPrimeSequence : IEnumerable<int> | |
| { | |
| public IEnumerator<int> GetEnumerator() | |
| { | |
| yield return 2; | |
| yield return 3; | |
| yield return 5; | |
| var e = new WheelPrimeEnumerator(); | |
| while (e.MoveNext()) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "pixelsWide": 13, | |
| "pixelsHigh": 10, | |
| "pixelSize": 20, | |
| "payload": | |
| [ | |
| { | |
| "color" : '#000000', | |
| "pixels" : | |
| [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PixItData | |
| { | |
| private readonly Color? _bgColor; | |
| private readonly int _pixelsWide; | |
| private readonly int _pixelsHigh; | |
| private readonly int _pixelSize; | |
| private readonly Dictionary<Color, IEnumerable<Pixel>> _data; | |
| public PixItData(Color? bgColor, int pixelsWide, | |
| int pixelsHigh, int pixelSize, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static PixItData ToPixItData(string json) | |
| { | |
| JObject o = JObject.Parse(json); | |
| int size = o.SelectToken("pixelSize").Value<int>(); | |
| int wide = o.SelectToken("pixelsWide").Value<int>(); | |
| int high = o.SelectToken("pixelsHigh").Value<int>(); | |
| JToken bg = o.SelectToken("background"); | |
| Color? bgColor = null; | |
| if (bg != null) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Pixel | |
| { | |
| private readonly int _x; | |
| private readonly int _y; | |
| public Pixel(int x, int y) | |
| { | |
| _x = x; | |
| _y = y; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static Image CreateImage(PixItData data) | |
| { | |
| int width = data.PixelSize * data.PixelsWide; | |
| int height = data.PixelSize * data.PixelsHigh; | |
| var image = new Bitmap(width, height); | |
| using (Graphics g = Graphics.FromImage(image)) | |
| { | |
| if (data.Background.HasValue) | |
| { | |
| Color bgColor = data.Background.Value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PixItHandler : IHttpHandler | |
| { | |
| public bool IsReusable | |
| { | |
| get { return true; } | |
| } | |
| public void ProcessRequest(HttpContext context) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <configuration> | |
| <system.web> | |
| <httpHandlers> | |
| <add verb="POST" path="pix.it" | |
| type="ample.code.pixit.PixItHandler, PixItHandler" /> | |
| </httpHandlers> | |
| </system.web> | |
| </configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "background": "#54FCFC", | |
| "pixelsWide": 18, | |
| "pixelsHigh": 36, | |
| "pixelSize": 4, | |
| "payload": | |
| [ | |
| { | |
| "color" : "#000000", | |
| "pixels" : |