示例#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());
        }
 public static GsColor Darken(this GsColor color, float amt = 0.5f)
 {
     return(GsMath.Lerp(color, GsColor.Black, amt));
 }
 public static GsColor Lighten(this GsColor color, float amt = 0.5f)
 {
     return(GsMath.Lerp(color, GsColor.White, amt));
 }