コード例 #1
0
        public static IEnumerable <GsVector> CreateArc(float cx, float cy, float width, float height, int startAngle, int sweepAngle)
        {
            int endAngle = startAngle + sweepAngle;
            int sign     = Math.Sign(endAngle - startAngle);
            int negsign  = -sign;
            int d        = sign * AngleIncrement;

            for (int angle = startAngle; angle.CompareTo(endAngle).Equals(negsign); angle += d)
            {
                yield return(new GsVector
                {
                    X = cx + width * GsMath.Cos(angle),
                    Y = cy + height * GsMath.Sin(angle),
                });
            }
        }
コード例 #2
0
        public static GsVector[] CreateEllipse(float h, float k, float width, float height, int slices = DefaultSlices)
        {
            // create a list of points of the circle
            float           max     = GsMath.TwoPi;
            float           step    = max / (float)slices;
            List <GsVector> vectors = new List <GsVector>();

            for (float t = 0.0f; t < max; t += step)
            {
                float x = (float)(h + width * GsMath.Cos(t));
                float y = (float)(k + height * GsMath.Sin(t));
                vectors.Add(new GsVector(x, y));
            }
            vectors.Add(vectors[0]);

            // return the points
            return(vectors.ToArray());
        }
コード例 #3
0
 public static GsColor Darken(this GsColor color, float amt = 0.5f)
 {
     return(GsMath.Lerp(color, GsColor.Black, amt));
 }
コード例 #4
0
 public static GsColor Lighten(this GsColor color, float amt = 0.5f)
 {
     return(GsMath.Lerp(color, GsColor.White, amt));
 }