Beispiel #1
0
        public static void DrawCube(SKCanvas thisCanvas, SKRect thisRect)
        {
            CreatePaints();
            SKPath thisPath  = new SKPath();
            var    pt_Center = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + (thisRect.Height / 2));

            SKPoint[] pts_Side = new SKPoint[4];
            SKPoint[] pts      = new SKPoint[6];
            pts[0] = new SKPoint(thisRect.Location.X, thisRect.Location.Y + (thisRect.Height / 4));
            pts[1] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y);
            pts[2] = new SKPoint(thisRect.Location.X + thisRect.Width, thisRect.Location.Y + (thisRect.Height / 4));
            pts[3] = new SKPoint(thisRect.Location.X + thisRect.Width, thisRect.Location.Y + ((thisRect.Height * 3) / 4));
            pts[4] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + thisRect.Height);
            pts[5] = new SKPoint(thisRect.Location.X, thisRect.Location.Y + ((thisRect.Height * 3) / 4));
            thisPath.MoveTo(pts[0]);
            var loopTo = pts.Count() - 1;

            for (int i = 1; i <= loopTo; i++)
            {
                thisPath.LineTo(pts[i]);
            }
            thisPath.Close();
            thisCanvas.DrawPath(thisPath, _bluePaint);
            thisCanvas.DrawPath(thisPath, _penUsed);
            thisPath    = new SKPath(); // shades
            pts_Side[0] = new SKPoint(thisRect.Location.X, thisRect.Location.Y + (thisRect.Height / 4));
            pts_Side[1] = pt_Center;
            pts_Side[2] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + thisRect.Height);
            pts_Side[3] = new SKPoint(thisRect.Location.X, thisRect.Location.Y + ((thisRect.Height * 3) / 4));
            thisPath.MoveTo(pts_Side[0]);
            var loopTo1 = pts_Side.Count() - 1;

            for (int i = 1; i <= loopTo1; i++)
            {
                thisPath.LineTo(pts_Side[i]);
            }
            thisCanvas.DrawPath(thisPath, _firstCube);
            thisCanvas.DrawPath(thisPath, _penUsed);
            thisPath    = new SKPath();
            pts_Side[0] = new SKPoint(thisRect.Location.X, thisRect.Location.Y + (thisRect.Height / 4));
            pts_Side[1] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y);
            pts_Side[2] = new SKPoint(thisRect.Location.X + thisRect.Width, thisRect.Location.Y + (thisRect.Height / 4));
            pts_Side[3] = pt_Center;
            thisPath.MoveTo(pts_Side[0]);
            var loopTo2 = pts_Side.Count() - 1;

            for (int i = 1; i <= loopTo2; i++)
            {
                thisPath.LineTo(pts_Side[i]);
            }
            thisPath.Close();
            thisCanvas.DrawPath(thisPath, _secondCube);
            thisCanvas.DrawPath(thisPath, _penUsed);
            thisPath    = new SKPath();
            pts_Side[0] = new SKPoint(thisRect.Location.X + thisRect.Width, thisRect.Location.Y + (thisRect.Height / 4));
            pts_Side[1] = new SKPoint(thisRect.Location.X + thisRect.Width, thisRect.Location.Y + ((thisRect.Height * 3) / 4));
            pts_Side[2] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + thisRect.Height);
            pts_Side[3] = pt_Center;

            thisPath.MoveTo(pts_Side[0]);
            var loopTo3 = pts_Side.Count() - 1;

            for (int i = 1; i <= loopTo3; i++)
            {
                thisPath.LineTo(pts_Side[i]);
            }
            thisPath.Close();
            thisCanvas.DrawPath(thisPath, _thirdCube);
            thisCanvas.DrawPath(thisPath, _penUsed);
        }