Пример #1
0
        public static List <ArtColor> ColorSplitter(ArtColor c1, ArtColor c2, int numDivisions)
        {
            var result = new List <ArtColor>();

            result.Add(c1);
            for (int y = 0; y < numDivisions - 1; y++)
            {
                var blendPercent = 100.FloorDivide(numDivisions) * (y + 1);
                result.Add(c1.Blend(c2, blendPercent));
            }
            return(result);
        }
Пример #2
0
        private void HilbertFill()
        {
            var curve = HilbertCurve.GenerateHilbertCurve(HilbertIterationsRequired());
            // inflate curve to gridSize (this could be a grid method eventually)
            var temp = new Grid <bool>(curve.gridSize.Times(gridSize));

            foreach (Cell <bool> C in curve.EachCell())
            {
                bool value = curve.GetCell(C.loc);
                foreach (var C2 in Methods.EachPoint(new Coord(gridSize)))
                {
                    temp.SetCell(C.loc.Times(gridSize).Plus(C2), value);
                }
            }
            curve = temp;

            curve = curve.Crop(new Coord(0, 0), size);

            foreach (var cell in curve.EachCell())
            {
                ArtColor color = BinaryColor(cell.value, ArtColor.White.Blend(ArtColor.White, 75), ArtColor.Green.Blend(ArtColor.Red, 25));//funColor2(cell.loc, cell.value);
                canvas.SetCell(cell.loc, color);
            }
        }
Пример #3
0
        public ArtLayer Generate(CommonInfo _Info)
        {
            Info = _Info;
            var result = new ArtLayer(Info.Size);
            var curve  = HilbertCurve.GenerateHilbertCurve(HilbertIterationsRequired());
            // inflate curve to gridSize (this could be a grid method eventually)
            var temp = new Grid <bool>(curve.gridSize.Times(Info.PatternScale));

            foreach (Cell <bool> C in curve.EachCell())
            {
                bool value = curve.GetCell(C.loc);
                foreach (var C2 in Methods.EachPoint(new Coord(Info.PatternScale)))
                {
                    temp.SetCell(C.loc.Times(Info.PatternScale).Plus(C2), value);
                }
            }
            curve = temp;

            curve = curve.Crop(new Coord(0, 0), Info.Size);

            foreach (var cell in curve.EachCell())
            {
                if (cell.value == true)
                {
                    Info.Phase = 0;
                }
                else
                {
                    Info.Phase = 1;
                }
                Info.Position = cell.loc;
                ArtColor color = Info.Fill.Fill(Info);
                result.grid.SetCell(cell.loc, color);
            }
            return(result);
        }
Пример #4
0
 private ArtColor BinaryColor(bool value, ArtColor on, ArtColor off)
 {
     return(value ? on : off);
 }