Beispiel #1
0
        private IEnumerable <Poly> BackgroundPolys()
        {
            var fullCirlce      = (float)Math.PI * 2f;
            var fullRadius0     = 0f;
            var fullRadius1     = _worldDimensions.HsvColorPickerHueSaturationCircleRadius;
            var fullRadiusRange = fullRadius1 - fullRadius0;

            const int cirRes = 36;
            const int radRes = 20;

            var alphaDelta  = fullCirlce / cirRes;
            var radiusDelta = fullRadiusRange / radRes;

            var ci = new CircularIterator(cirRes, true);

            while (ci.Next() && ci.Alpha1Ratio <= 1.00000001f)
            {
                var rad0 = fullRadius0;

                for (int rIx = 1; rIx <= radRes; ++rIx)
                {
                    var rad1 = fullRadius0 + rIx * radiusDelta;

                    var p0 = new SKPoint(ci.Cos0 * rad0, ci.Sin0 * rad0) + _worldDimensions.Center;
                    var p1 = new SKPoint(ci.Cos1 * rad0, ci.Sin1 * rad0) + _worldDimensions.Center;
                    var p2 = new SKPoint(ci.Cos1 * rad1, ci.Sin1 * rad1) + _worldDimensions.Center;
                    var p3 = new SKPoint(ci.Cos0 * rad1, ci.Sin0 * rad1) + _worldDimensions.Center;

                    _hsvRgb.Hsv2Rgb(ci.Alpha0 / fullCirlce, (rad0 - fullRadius0) / fullRadiusRange, 1f, out SKColor c0);
                    _hsvRgb.Hsv2Rgb(ci.Alpha1 / fullCirlce, (rad0 - fullRadius0) / fullRadiusRange, 1f, out SKColor c1);
                    _hsvRgb.Hsv2Rgb(ci.Alpha1 / fullCirlce, (rad1 - fullRadius0) / fullRadiusRange, 1f, out SKColor c2);
                    _hsvRgb.Hsv2Rgb(ci.Alpha0 / fullCirlce, (rad1 - fullRadius0) / fullRadiusRange, 1f, out SKColor c3);

                    var poly = new Poly();

                    poly.Points.Add(p0);
                    poly.Points.Add(p1);
                    poly.Points.Add(p2);
                    poly.Points.Add(p3);

                    poly.Colors.Add(c0);
                    poly.Colors.Add(c1);
                    poly.Colors.Add(c2);
                    poly.Colors.Add(c3);

                    yield return(poly);

                    rad0 = rad1;
                }
            }
        }
Beispiel #2
0
        public void Draw(SKCanvas canvas, float scale)
        {
            var vs = Vertices().Select(v => new SKPoint(v.X * scale, v.Y * scale));

            var cpl = new ColorPositionLine(_colorPositions.AsArray());
            var ci  = new CircularIterator(_circularResolution, false);
            var cs  = new List <SKColor>();

            while (ci.Next())
            {
                var c0 = cpl.ColorAt(ci.Alpha0Ratio);
                cs.Add(c0);
                cs.Add(c0);
            }

            canvas.DrawVertices(SKVertexMode.TriangleStrip, vs.ToArray(), cs.ToArray(), new SKPaint());
        }
Beispiel #3
0
        private SKPoint[] Vertices()
        {
            if (_vertices == null)
            {
                var ci = new CircularIterator(_circularResolution, true);
                var vs = new List <SKPoint>();
                var r0 = _radius - _thickness / 2f;
                var r1 = _radius + _thickness / 2f;
                while (ci.Next())
                {
                    var v0 = _center + new SKPoint(ci.Cos0 * r0, ci.Sin0 * r0);
                    var v1 = _center + new SKPoint(ci.Cos0 * r1, ci.Sin0 * r1);

                    vs.Add(v0);
                    vs.Add(v1);
                }
                _vertices = vs.ToArray();
            }
            return(_vertices);
        }