/// <summary>
        ///     Parallel Coordinates Style object.
        /// </summary>
        /// <param name="LineColor">Color of the selected Lines/Values.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of the Chart in pixels.</param>
        /// <param name="Height">Height of the Chart in pixels.</param>
        /// <returns name="Style">Parallel Coordinates Style.</returns>
        /// <search>parallel, coordinates, style</search>
        public static ParallelCoordinatesStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color LineColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width  = 1000,
            int Height = 500)
        {
            ParallelCoordinatesStyle style = new ParallelCoordinatesStyle();

            style.Width     = Width;
            style.Height    = Height;
            style.LineColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(LineColor.Alpha, LineColor.Red, LineColor.Green, LineColor.Blue));
            style.Margins   = Margins;
            style.SizeX     = (int)Math.Ceiling(Width / 100d);
            style.SizeY     = (int)Math.Ceiling(Height / 100d);

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Exemple #2
0
        public void SetupCustomUIElements(dynNodeView view)
        {
            var drawPlane = new Image
            {
                Stretch             = Stretch.Fill,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Width  = 100,
                Height = 200
            };

            var dm = this.Workspace.DynamoModel;

            view.inputGrid.Children.Add(drawPlane);

            RequestChangeColorRange += delegate
            {
                DispatchOnUIThread(delegate
                {
                    var colorStartNode = InPorts[0].Connectors[0].Start.Owner;
                    var startIndex     = InPorts[0].Connectors[0].Start.Index;
                    var colorEndNode   = InPorts[1].Connectors[0].Start.Owner;
                    var endIndex       = InPorts[1].Connectors[0].Start.Index;

                    var startId = colorStartNode.GetAstIdentifierForOutputIndex(startIndex).Name;
                    var endId   = colorEndNode.GetAstIdentifierForOutputIndex(endIndex).Name;

                    var startMirror = dm.EngineController.GetMirror(startId);
                    var endMirror   = dm.EngineController.GetMirror(endId);

                    object start = null;
                    object end   = null;

                    if (startMirror.GetData().IsCollection)
                    {
                        start = startMirror.GetData().GetElements().Select(x => x.Data).FirstOrDefault();
                    }
                    else
                    {
                        start = startMirror.GetData().Data;
                    }

                    if (endMirror.GetData().IsCollection)
                    {
                        end = endMirror.GetData().GetElements().Select(x => x.Data).FirstOrDefault();
                    }
                    else
                    {
                        end = endMirror.GetData().Data;
                    }

                    Color startColor = start as Color;
                    Color endColor   = end as Color;
                    if (null != startColor && null != endColor)
                    {
                        WriteableBitmap bmp = CompleteColorScale(startColor, endColor);
                        drawPlane.Source    = bmp;
                    }
                });
            };
        }
Exemple #3
0
        /// <summary>
        ///     Scatter Plot Style.
        /// </summary>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width in pixels.</param>
        /// <param name="Height">Height in pixels.</param>
        /// <param name="YAxisLabel">Label displayed for Y Axis.</param>
        /// <param name="XAxisLabel">Label displayed for X Axis.</param>
        /// <param name="DotColor">Color of Scatter Plot dot.</param>
        /// <returns name="Style">Scatter Plot Style.</returns>
        /// <search>style, scatter plot</search>
        public static ScatterPlotStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,100,100,100)")] DSCore.Color DotColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width = 1000,
            int Height = 500,
            string YAxisLabel = "Label",
            string XAxisLabel = "Label")
        {
            ScatterPlotStyle style = new ScatterPlotStyle();
            style.Width = Width;
            style.Height = Height;
            style.YAxisLabel = YAxisLabel;
            style.XAxisLabel = XAxisLabel;
            style.DotColor = sColor.FromArgb(DotColor.Alpha, DotColor.Red, DotColor.Green, DotColor.Blue);
            style.Margins = Margins;

            if (Address != null)
            {
                style.GridRow = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow = 1;
                style.GridColumn = 1;
            }

            return style;
        }
 /// <summary>
 /// Create a new Font
 /// </summary>
 /// <param name="color"></param>
 /// <param name="fontfamily"></param>
 /// <param name="size"></param>
 /// <param name="style"></param>
 public Font(DSCore.Color color, string fontfamily = "HELVETICA", double size = 1.2, string style = "")
 {
     FontSize   = size;
     Style      = style;
     FontFamily = fontfamily;
     Color      = color;
 }
Exemple #5
0
        /// <summary>
        /// Override the element's color in the active view.
        /// </summary>
        /// <param name="color">The color to apply to a solid fill on the element.</param>
        public Element OverrideColorInView(Color color)
        {
            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
            var view = DocumentManager.Instance.CurrentUIDocument.ActiveView;
            var ogs  = new Autodesk.Revit.DB.OverrideGraphicSettings();

            var patternCollector = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);

            patternCollector.OfClass(typeof(Autodesk.Revit.DB.FillPatternElement));
            Autodesk.Revit.DB.FillPatternElement solidFill = patternCollector.ToElements().Cast <Autodesk.Revit.DB.FillPatternElement>().First(x => x.GetFillPattern().IsSolidFill);

            var overrideColor = new Autodesk.Revit.DB.Color(color.Red, color.Green, color.Blue);

            // the old functions SetProjectionFillColor and SetProjectionFillPatternId,
            // are obsoleted and suggested by the documentation that will be removed and
            // replaced by SetSurfaceForegroundPatternColor and SetSurfaceForegroundPatternId.

            ogs.SetSurfaceForegroundPatternColor(overrideColor);
            ogs.SetSurfaceForegroundPatternId(solidFill.Id);
            ogs.SetProjectionLineColor(overrideColor);
            view.SetElementOverrides(InternalElementId, ogs);
            TransactionManager.Instance.TransactionTaskDone();

            return(this);
        }
Exemple #6
0
        /// <summary>
        /// 移除与图像边缘联通的区域
        /// </summary>
        /// <param name="inMat">输入图片:Mat</param>
        /// <param name="color">填充颜色</param>
        /// <returns></returns>
        public static Mat ClearBorder(Mat inMat, Color color)
        {
            Image <Gray, byte> src = new Image <Gray, byte>(inMat.Size);

            src = inMat.ToImage <Gray, byte>();
            Image <Gray, byte> cannyOut = new Image <Gray, byte>(src.Size);

            CvInvoke.Canny(src, cannyOut, 5, 5 * 3);
            //边缘延拓
            Image <Gray, byte> mask = new Image <Gray, byte>(new Size(src.Width + 2, src.Height + 2));

            CvInvoke.cvSetImageROI(mask, new Rectangle(1, 1, src.Width, src.Height));
            cannyOut.CopyTo(mask);
            CvInvoke.cvResetImageROI(mask);

            Rectangle rect = new Rectangle();

            CvInvoke.FloodFill(
                src,                                               //1 原图像
                mask,                                              //2 掩码
                new Point(1, 1),                                   //3 种子点
                new MCvScalar(color.Blue, color.Green, color.Red), //4 填充颜色值
                out rect,                                          //5
                new MCvScalar(25, 25, 25),                         //6
                new MCvScalar(0, 0, 0),                            //7
                Connectivity.EightConnected,                       //8 连通性设置
                FloodFillType.FixedRange                           //9
                );

            src = src - cannyOut;
            return(src.Mat);
        }
Exemple #7
0
        /// <summary>
        ///     Bar Chart Style object.
        /// </summary>
        /// <param name="BarColor">Fill color for bars.</param>
        /// <param name="BarHoverColor">Fill color when hovered over.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of the entire chart in pixels.</param>
        /// <param name="Height">Height of the entire chart in pixels.</param>
        /// <param name="YAxisLabel">Text displayed in top-left corner of chart.</param>
        /// <param name="TickMarksX">Approximate number of tick mark values for X Axis.</param>
        /// <param name="xTextRotation">Indicates if labels along x-axis are rotated.</param>
        /// <returns name="Style">Bar Chart Style.</returns>
        /// <search>bar, chart, style</search>
        public static BarStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color BarColor,
            [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins,
            int Width          = 1000,
            int Height         = 500,
            string YAxisLabel  = "Label",
            int TickMarksX     = 10,
            bool xTextRotation = false)
        {
            BarStyle style = new BarStyle();

            style.BarColor      = sColor.FromArgb(BarColor.Alpha, BarColor.Red, BarColor.Green, BarColor.Blue);
            style.BarHoverColor = sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue);
            style.Width         = Width;
            style.Height        = Height;
            style.YAxisLabel    = YAxisLabel;
            style.TickMarksX    = TickMarksX;
            style.xTextRotation = xTextRotation;
            style.Margins       = Margins;

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Exemple #8
0
        /// <summary>
        ///     Line Chart Style object.
        /// </summary>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of the entire chart in pixels.</param>
        /// <param name="Height">Height of the entire chart in pixels.</param>
        /// <param name="YAxisLabel">Text used to label Y Axis.</param>
        /// <param name="LineColor">Color for Line Chart Line.</param>
        /// <param name="TickMarksX">Approximate number of tick mark values for X Axis.</param>
        /// <returns name="Style">Line Chart Style.</returns>
        /// <search>line, style</search>
        public static LineChartStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color LineColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string YAxisLabel = "Label",
            int TickMarksX    = 10)
        {
            LineChartStyle style = new LineChartStyle();

            style.Width      = Width;
            style.Height     = Height;
            style.YAxisLabel = YAxisLabel;
            style.LineColor  = sColor.FromArgb(LineColor.Alpha, LineColor.Red, LineColor.Green, LineColor.Blue);
            style.TickMarksX = TickMarksX;
            style.Margins    = Margins;

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Exemple #9
0
        public void ColorPalette_CreatesCorrectUndoStackForComplexState()
        {
            var homespace = Model.CurrentWorkspace as HomeWorkspaceModel;

            Assert.NotNull(homespace, "The current workspace is not a HomeWorkspaceModel");
            var colorPalette = new ColorPalette();

            Model.AddNodeToCurrentWorkspace(colorPalette, true);
            homespace.Run();
            Assert.DoesNotThrow(DispatcherUtil.DoEvents);
            Assert.AreEqual(DSColor.ByARGB(255, 0, 0, 0), colorPalette.DsColor);
            homespace.UpdateModelValue(new List <System.Guid>()
            {
                colorPalette.GUID
            }, "DsColor", DSColor.ByARGB(255, 255, 0, 0).ToString());
            homespace.UpdateModelValue(new List <System.Guid>()
            {
                colorPalette.GUID
            }, "DsColor", DSColor.ByARGB(255, 0, 0, 255).ToString());
            homespace.UpdateModelValue(new List <System.Guid>()
            {
                colorPalette.GUID
            }, "DsColor", DSColor.ByARGB(255, 255, 0, 0).ToString());

            //now undo a few times and assert the color is red.
            homespace.Undo();
            Assert.AreEqual(DSColor.ByARGB(255, 0, 0, 255), colorPalette.DsColor);
            homespace.Undo();
            Assert.AreEqual(DSColor.ByARGB(255, 255, 0, 0), colorPalette.DsColor);
            Assert.IsTrue(homespace.UndoRecorder.CanUndo);
            homespace.Undo();
            Assert.AreEqual(DSColor.ByARGB(255, 0, 0, 0), colorPalette.DsColor);
        }
Exemple #10
0
 public static TextBinder TextBinder(
     Point position,
     string text,
     [DefaultArgument("null")] Color color)
 {
     return(new TextBinder(position.ToTriple(), text, color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultLineColor));
 }
Exemple #11
0
        /// <summary>
        ///     Area Chart Style object.
        /// </summary>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Marings in pixels.</param>
        /// <param name="Width">Width of the entire chart in pixels.</param>
        /// <param name="Height">Height of the entire chart in pixels.</param>
        /// <param name="YAxisLabel">Text used to label Y Axis.</param>
        /// <param name="AreaColor">Color for Area Chart fill.</param>
        /// <param name="TickMarksX">Approximate number of tick marks on X Axis.</param>
        /// <returns name="Style">Area Chart Style.</returns>
        /// <search>area, chart, style</search>
        public static AreaChartStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color AreaColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string YAxisLabel = "Label",
            int TickMarksX    = 10)
        {
            AreaChartStyle style = new AreaChartStyle();

            style.Width      = Width;
            style.Height     = Height;
            style.YAxisLabel = YAxisLabel;
            style.AreaColor  = ChartsUtilities.ColorToHexString(sColor.FromArgb(AreaColor.Alpha, AreaColor.Red, AreaColor.Green, AreaColor.Blue));
            style.TickMarksX = TickMarksX;
            style.Margins    = Margins;
            style.SizeX      = (int)Math.Ceiling(Width / 100d);
            style.SizeY      = (int)Math.Ceiling(Height / 100d);

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
        /// <summary>
        ///     Horizontal Bar Chart Style
        /// </summary>
        /// <param name="BarColor">Fill color for bars.</param>
        /// <param name="BarHoverColor">Fill color when hovered over.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of the entire chart in pixels.</param>
        /// <param name="Height">Height of the entire chart in pixels.</param>
        /// <param name="XAxisLabel">Text displayed in bottom-right corner of chart.</param>
        /// <returns name="Style">Style</returns>
        public static HorizontalBarChartStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color BarColor,
            [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string XAxisLabel = "Label")
        {
            HorizontalBarChartStyle style = new HorizontalBarChartStyle();

            style.BarColor      = sColor.FromArgb(BarColor.Alpha, BarColor.Red, BarColor.Green, BarColor.Blue);
            style.BarHoverColor = sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue);
            style.Width         = Width;
            style.Height        = Height;
            style.YAxisLabel    = XAxisLabel;
            style.Margins       = Margins;

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Exemple #13
0
 public static Color Multiply(DSCore.Color c1, double div)
 {
     return(Color.ByARGB(
                (int)(c1.Alpha * div),
                (int)(c1.Red * div),
                (int)(c1.Green * div),
                (int)(c1.Blue * div)));
 }
Exemple #14
0
 public static Color Add(DSCore.Color c1, DSCore.Color c2)
 {
     return(Color.ByARGB(
                c1.Alpha + c2.Alpha,
                c1.Red + c2.Red,
                c1.Green + c2.Green,
                c1.Blue + c2.Blue));
 }
Exemple #15
0
 internal static void AddColouredVertex(
     IRenderPackage package,
     GTGeom.Vertex vertex,
     DSCore.Color color)
 {
     package.AddPointVertex(vertex.X, vertex.Y, vertex.Z);
     package.AddPointVertexColor(color.Red, color.Green, color.Blue, color.Alpha);
 }
Exemple #16
0
 public static Color Divide(DSCore.Color c1, double div)
 {
     return(Color.ByARGB(
                (int)(c1.Alpha / div),
                (int)(c1.Red / div),
                (int)(c1.Green / div),
                (int)(c1.Blue / div)));
 }
Exemple #17
0
 public static MeshBinder MeshBinder(
     Autodesk.Dynamo.MeshToolkit.Mesh toolkitMesh,
     [DefaultArgument("null")] Color color)
 {
     return(new MeshBinder(
                toolkitMesh,
                color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultMeshFaceColor));
 }
Exemple #18
0
 public static MeshBinder MeshBinder(
     Mesh mesh,
     [DefaultArgument("null")] Color color)
 {
     return(new MeshBinder(
                mesh,
                color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultMeshFaceColor));
 }
Exemple #19
0
 public static LineBinder LineBinder(
     Line line,
     [DefaultArgument("null")] Color color)
 {
     return(new LineBinder(
                line.StartPoint.ToTriple(),
                line.EndPoint.ToTriple(),
                color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultLineColor));
 }
Exemple #20
0
 /// <summary>
 /// Annotation Object
 /// </summary>
 /// <param name="created"></param>
 /// <param name="updated"></param>
 /// <param name="contents"></param>
 /// <param name="author"></param>
 /// <param name="geometry"></param>
 public Annotation(string contents, string author, string subject, Geometry geometry, DSCore.Color color)
 {
     this.Created  = DateTime.Now;
     this.Updated  = DateTime.Now;
     this.Contents = contents;
     this.Author   = author;
     this.Geometry = geometry;
     this.Color    = color;
     this.Subject  = subject;
 }
 public static LineBinder LineBinder(
     Point startPoint,
     Point endPoint,
     [DefaultArgument("null")] Color color)
 {
     return(new LineBinder(
                startPoint.ToTriple(),
                endPoint.ToTriple(),
                color?.ToColor4() ?? DynaShapeDisplay.DefaultLineColor));
 }
Exemple #22
0
 public static PolylineBinder PolylineBinder(
     List <Point> vertices,
     [DefaultArgument("null")] Color color,
     [DefaultArgument("false")] bool loop)
 {
     return(new PolylineBinder(
                vertices.ToTriples(),
                color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultLineColor,
                loop));
 }
Exemple #23
0
        public static Dictionary <string, object> PageBySize(string pagesize, DSCore.Color color)
        {
            Page p = new Page(pagesize, color);

            return(new Dictionary <string, object>()
            {
                { "Page", p },
                { "Rectangle", p.Rectangle.ToDSRectangle() }
            });
        }
Exemple #24
0
        internal static void AddColouredEdge(IRenderPackage package, gEdge edge, DSCore.Color color)
        {
            package.AddLineStripVertex(edge.StartVertex.X, edge.StartVertex.Y, edge.StartVertex.Z);
            package.AddLineStripVertex(edge.EndVertex.X, edge.EndVertex.Y, edge.EndVertex.Z);

            package.AddLineStripVertexColor(color.Red, color.Green, color.Blue, color.Alpha);
            package.AddLineStripVertexColor(color.Red, color.Green, color.Blue, color.Alpha);

            package.AddLineStripVertexCount(2);
        }
Exemple #25
0
        /// <summary>
        ///     Restore stored value and set "dscolor" to it.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="context"></param>
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            base.DeserializeCore(element, context);

            var colorNode = element.ChildNodes.Cast <XmlNode>().FirstOrDefault(x => x.Name == "dsColor");

            if (colorNode != null)
            {
                dsColor = DeserializeValue(colorNode.InnerText);
            }
        }
Exemple #26
0
 public static CircleBinder CircleBinder(
     Point center,
     float radius,
     [DefaultArgument("Vector.ZAxis()")] Vector planeNormal,
     [DefaultArgument("null")] Color color)
 {
     return(new CircleBinder(
                center.ToTriple(),
                radius,
                planeNormal.ToTriple(),
                color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultLineColor));
 }
Exemple #27
0
 public static TexturedMeshBinder TexturedMeshBinder(
     Autodesk.Dynamo.MeshToolkit.Mesh toolkitMesh,
     [DefaultArgument("null")] Color color,
     string textureFileName,
     TextureCoordinateSet textureCoordinates)
 {
     return(new TexturedMeshBinder(
                toolkitMesh,
                color?.ToSharpDXColor() ?? DynaShapeDisplay.DefaultMeshFaceColor,
                textureFileName,
                textureCoordinates.Content));
 }
Exemple #28
0
 private DSColor DeserializeValue(string val)
 {
     try
     {
         //Splits the xml string and returns each of the ARGB values as a string array.
         string[] argb = Regex.Split(val, @"\D+").Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
         return(DSColor.ByARGB(int.Parse(argb[3]), int.Parse(argb[0]), int.Parse(argb[1]), int.Parse(argb[2])));
     }
     catch
     {
         return(DSColor.ByARGB(255, 0, 0, 0));
     }
 }
Exemple #29
0
        public ColorPalette(JObject InputValue, IEnumerable <PortModel> inPorts, IEnumerable <PortModel> outPorts) : base(inPorts, outPorts)
        {
            // RGBA to ARGB
            try
            {
                this.DsColor = DSColor.ByARGB((int)InputValue["A"], (int)InputValue["R"], (int)InputValue["G"], (int)InputValue["B"]);
            }

            catch
            {
                this.DsColor = DSColor.ByARGB(255, 0, 0, 0);
            }
        }
Exemple #30
0
        public ColorPalette(JObject DsColor, IEnumerable <PortModel> inPorts, IEnumerable <PortModel> outPorts) : base(inPorts, outPorts)
        {
            // RGBA to ARGB
            try
            {
                this.DsColor = DSColor.ByARGB((int)DsColor["Alpha"], (int)DsColor["Red"], (int)DsColor["Green"], (int)DsColor["Blue"]);
            }

            catch
            {
                this.DsColor = DSColor.ByARGB(255, 0, 0, 0);
            }
        }
Exemple #31
0
        //http://gaggerostechnicalnotes.blogspot.com/2012/01/wpf-colors-scale.html
        private WriteableBitmap CompleteColorScale(Color start, Color end)
        {
            const int size = 64;

            const int width = 1;
            const int height = size;

            var bitmap = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgra32, null);
            var pixels = new uint[width * height];

            for (int i = 0; i < size; i++)
            {
                var newRed = start.Red + ((end.Red - start.Red) / size) * i;
                var newGreen = start.Green + ((end.Green - start.Green) / size) * i;
                var newBlue = start.Blue + ((end.Blue - start.Blue) / size) * i;

                pixels[i] = (uint)((255 << 24) + (newRed << 16) + (newGreen << 8) + newBlue);

            }
            bitmap.WritePixels(new Int32Rect(0, 0, width, height), pixels, width * 4, 0);

            return bitmap;
        }