Ejemplo n.º 1
0
        public static string ToSVG(this Wg.GradientRadial input)
        {
            string output = "<radialGradient id=\"" + input.ID + "\" ";

            output += "cx=\"" + input.Center.X * 100 + "%\" cy=\"" + input.Center.Y * 100 + "%\" r=\"" + input.RadiusX * 100 + "%\" ";
            output += "fx =\"" + input.Focus.X * 100 + "%\" fy=\"" + input.Focus.Y * 100 + "%\" ";
            output += "gradientUnits=\"objectBoundingBox\" >" + Environment.NewLine;
            for (int i = 0; i < input.Colors.Count; i++)
            {
                output += "<stop offset=\"" + (input.Stops[i] * 100.0) + "%\" style=\"stop-color:" + input.Colors[i].ToSVG() + "; stop-opacity:" + (input.Colors[i].A / 255.0) + "\" />" + Environment.NewLine;
            }
            output += "</radialGradient>";

            return(output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Wg.Graphic graphic = Wg.Graphics.FillBlack;
            if (!DA.GetData(0, ref graphic))
            {
                graphic = new Wg.Graphic(graphic);
            }

            List <Color> colors = new List <Color>();

            DA.GetDataList(1, colors);

            List <double> stops = new List <double>();

            DA.GetDataList(2, stops);

            Point3d center = new Point3d(0.5, 0.5, 0);

            DA.GetData(3, ref center);

            Point3d focus = new Point3d(0.5, 0.5, 0);

            DA.GetData(4, ref focus);

            double radius = 1.0;

            DA.GetData(5, ref radius);

            List <Wg.Color> windColors = new List <Wg.Color>();

            foreach (Color color in colors)
            {
                windColors.Add(color.ToWindColor());
            }

            Wg.GradientRadial gradient = new Wg.GradientRadial(windColors, stops);
            gradient.Center  = new Wind.Geometry.Point(center.X, center.Y, 0);
            gradient.Focus   = new Wind.Geometry.Point(focus.X, focus.Y, 0);
            gradient.RadiusX = radius;
            gradient.RadiusY = radius;

            graphic.Fill = gradient;

            DA.SetData(0, graphic);
        }
Ejemplo n.º 3
0
        public static Sm.RadialGradientBrush ToMediaBrush(this Wg.GradientRadial input)
        {
            Sm.RadialGradientBrush brush = new Sm.RadialGradientBrush();
            int i = 0;

            foreach (Wg.Color color in input.Colors)
            {
                brush.GradientStops.Add(new Sm.GradientStop(color.ToMediaColor(), input.Stops[i]));
                i++;
            }

            brush.SpreadMethod = Sm.GradientSpreadMethod.Pad;
            brush.MappingMode  = Sm.BrushMappingMode.RelativeToBoundingBox;

            brush.Center         = new Point(input.Center.X, input.Center.Y);
            brush.GradientOrigin = new Point(input.Focus.X, input.Focus.Y);
            brush.RadiusX        = input.RadiusX;
            brush.RadiusY        = input.RadiusY;

            return(brush);
        }
Ejemplo n.º 4
0
 public GradientRadial(GradientRadial gradient) : base(gradient)
 {
 }