private Paragraph GetHeader(string header)
        {
            var paragraph = new Paragraph();
            var run       = paragraph.AppendChild(new Run());

            run.RunProperties          = new RunProperties();
            run.RunProperties.FontSize = (FontSize)textSize.Clone();
            run.RunProperties.Color    = (Color)darkColor.Clone();
            run.AppendChild(new Text(header));

            return(paragraph);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new Attribute that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Attribute that is a copy of this instance.</returns>
        public object Clone()
        {
            Attribute entity = new Attribute
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = isVisible,
                //Attribute properties
                Definition   = (AttributeDefinition)definition?.Clone(),
                Tag          = tag,
                Height       = height,
                WidthFactor  = widthFactor,
                ObliqueAngle = obliqueAngle,
                Value        = attValue,
                Style        = style,
                Position     = position,
                Flags        = flags,
                Rotation     = rotation,
                Alignment    = alignment
            };

            return(entity);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new AttributeDefinition that is a copy of the current instance.
        /// </summary>
        /// <returns>A new AttributeDefinition that is a copy of this instance.</returns>
        public object Clone()
        {
            AttributeDefinition entity = new AttributeDefinition(tag)
            {
                //Attribute definition properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                Prompt        = prompt,
                Value         = attValue,
                Height        = height,
                WidthFactor   = widthFactor,
                ObliqueAngle  = obliqueAngle,
                Style         = style,
                Position      = position,
                Flags         = flags,
                Rotation      = rotation,
                Alignment     = alignment
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 4
0
        /// <summary>
        /// Converts the arc in a Polyline.
        /// </summary>
        /// <param name="precision">Number of divisions.</param>
        /// <returns>A new instance of <see cref="LwPolyline">LightWeightPolyline</see> that represents the arc.</returns>
        public LwPolyline ToPolyline(int precision)
        {
            IEnumerable <Vector2> vertexes = PolygonalVertexes(precision);
            Vector3 ocsCenter = MathHelper.Transform(center, Normal, CoordinateSystem.World, CoordinateSystem.Object);

            LwPolyline poly = new LwPolyline
            {
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                Elevation     = ocsCenter.Z,
                Thickness     = Thickness,
                IsClosed      = false
            };

            foreach (Vector2 v in vertexes)
            {
                poly.Vertexes.Add(new LwPolylineVertex(v.X + ocsCenter.X, v.Y + ocsCenter.Y));
            }
            return(poly);
        }
 protected internal override ExcelDxfFontBase Clone()
 {
     return(new ExcelDxfFontBase(_styles)
     {
         Bold = Bold, Color = Color.Clone(), Italic = Italic, Strike = Strike, Underline = Underline
     });
 }
Esempio n. 6
0
        /// <summary>
        /// Creates a new LwPolyline that is a copy of the current instance.
        /// </summary>
        /// <returns>A new LwPolyline that is a copy of this instance.</returns>
        public override Object Clone()
        {
            LwPolyline entity = new LwPolyline
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //LwPolyline properties
                Elevation = elevation,
                Thickness = thickness,
                Flags     = flags
            };

            foreach (LwPolylineVertex vertex in vertexes)
            {
                entity.Vertexes.Add((LwPolylineVertex)vertex.Clone());
            }

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 7
0
        public Material Clone(string name = null)
        {
            var clone = new Material {
                Name              = string.IsNullOrEmpty(name) ? Name : name,
                WrapLighting      = WrapLighting,
                Roughness         = Roughness,
                GlossyImageLerp   = GlossyImageLerp,
                Thickness         = Thickness,
                Edge              = Edge,
                EdgeAlpha         = EdgeAlpha,
                Opacity           = Opacity,
                BaseColor         = BaseColor.Clone(),
                Glossiness        = Glossiness.Clone(),
                ClearCoat         = ClearCoat.Clone(),
                IsMetal           = IsMetal,
                IsOpacityActive   = IsOpacityActive,
                Elasticity        = Elasticity,
                ElasticityFalloff = ElasticityFalloff,
                Friction          = Friction,
                ScatterAngle      = ScatterAngle,
            };

            clone.UpdateData();
            return(clone);
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a new MText that is a copy of the current instance.
        /// </summary>
        /// <returns>A new MText that is a copy of this instance.</returns>
        public override object Clone()
        {
            MText entity = new MText
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //MText properties
                Position          = position,
                Rotation          = rotation,
                Height            = height,
                LineSpacingFactor = lineSpacing,
                LineSpacingStyle  = lineSpacingStyle,
                RectangleWidth    = rectangleWidth,
                AttachmentPoint   = attachmentPoint,
                Style             = (TextStyle)style.Clone(),
                Value             = text
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a new Arc that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Arc that is a copy of this instance.</returns>
        public override object Clone()
        {
            Arc entity = new Arc
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Arc properties
                Center     = center,
                Radius     = radius,
                StartAngle = startAngle,
                EndAngle   = endAngle,
                Thickness  = thickness
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 10
0
        /// <summary>
        /// Allows the creation of a shallow copy of this Bytescout.PDF.SolidPen.
        /// </summary>
        /// <returns cref="object" href="http://msdn.microsoft.com/en-us/library/system.object.aspx">Returns a shallow copy of this Bytescout.PDF.SolidPen.</returns>
        public override object Clone()
        {
            SolidPen p = this.MemberwiseClone() as SolidPen;

            p._color = _color.Clone() as Color;
            return(p);
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a new MLine that is a copy of the current instance.
        /// </summary>
        /// <returns>A new MLine that is a copy of this instance.</returns>
        public override object Clone()
        {
            MLine entity = new MLine
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //MLine properties
                Elevation     = elevation,
                Scale         = scale,
                Justification = justification,
                Style         = (MLineStyle)style.Clone(),
                Flags         = flags
            };

            foreach (MLineVertex vertex in vertexes)
            {
                entity.vertexes.Add((MLineVertex)vertex.Clone());
            }

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 12
0
        public override object Clone()
        {
            Symbol obj = new Symbol();

            if (Type != null)
            {
                obj.Type = Type.Clone();
            }
            if (Color != null)
            {
                obj.Color = Color.Clone();
            }
            if (Size != null)
            {
                obj.Size = Size.Clone();
            }
            if (GroupingBy != null)
            {
                obj.GroupingBy = GroupingBy.Clone();
            }
            obj.Visible = this.Visible;
            foreach (DataViewPosition pos in DataViewPositionLst)
            {
                obj.DataViewPositionLst.Add((DataViewPosition)pos.Clone());
            }
            return(obj);
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a new Line that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Line that is a copy of this instance.</returns>
        public override object Clone()
        {
            Line entity = new Line
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Line properties
                StartPoint = start,
                EndPoint   = end,
                Thickness  = thickness
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 14
0
        public override EffectBase Clone()
        {
            var result = (PixelOutlineEffect)base.Clone();

            result.Color = Color.Clone();
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// Creates a new Trace that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Trace that is a copy of this instance.</returns>
        public override object Clone()
        {
            Trace entity = new Trace
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Solid properties
                FirstVertex  = firstVertex,
                SecondVertex = secondVertex,
                ThirdVertex  = thirdVertex,
                FourthVertex = fourthVertex,
                Thickness    = thickness
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 16
0
        /// <summary>
        /// Creates a new Point that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Point that is a copy of this instance.</returns>
        public override object Clone()
        {
            Point entity = new Point
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Point properties
                Position  = position,
                Rotation  = rotation,
                Thickness = thickness
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 17
0
        //public override void TransformBy2(Matrix3 transformation, Vector3 translation)
        //{
        //    Vector3 newCenter;
        //    Vector3 newNormal;
        //    double newMajorAxis;
        //    double newMinorAxis;
        //    double newRotation;

        //    newCenter = transformation * this.Center + translation;
        //    newNormal = transformation * this.Normal;

        //    Matrix3 transOW = MathHelper.ArbitraryAxis(this.Normal);
        //    transOW *= Matrix3.RotationZ(this.Rotation * MathHelper.DegToRad);

        //    Matrix3 transWO = MathHelper.ArbitraryAxis(newNormal);
        //    transWO = transWO.Transpose();

        //    Vector3 v = transOW * Vector3.UnitX;
        //    v = transformation * v;
        //    v = transWO * v;
        //    double angle = Vector2.Angle(new Vector2(v.X, v.Y));

        //    newRotation = angle * MathHelper.RadToDeg;

        //    transWO = Matrix3.RotationZ(newRotation * MathHelper.DegToRad).Transpose() * transWO;

        //    Vector3 s = transOW * new Vector3(this.MajorAxis, this.MinorAxis, 0.0);
        //    s = transformation * s;
        //    s = transWO * s;

        //    newMajorAxis = s.X <= 0 ? MathHelper.Epsilon : s.X;
        //    newMinorAxis = s.Y <= 0 ? MathHelper.Epsilon : s.Y;

        //    this.Center = newCenter;
        //    this.Normal = newNormal;
        //    this.Rotation = newRotation;
        //    if (newMinorAxis > newMajorAxis)
        //    {
        //        this.MajorAxis = newMinorAxis;
        //        this.MinorAxis = newMajorAxis;
        //    }
        //    else
        //    {
        //        this.MajorAxis = newMajorAxis;
        //        this.MinorAxis = newMinorAxis;
        //    }
        //}

        /// <summary>
        /// Creates a new Ellipse that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Ellipse that is a copy of this instance.</returns>
        public override object Clone()
        {
            Ellipse entity = new Ellipse
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Ellipse properties
                Center     = center,
                MajorAxis  = majorAxis,
                MinorAxis  = minorAxis,
                Rotation   = rotation,
                StartAngle = startAngle,
                EndAngle   = endAngle,
                Thickness  = thickness
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 18
0
        /// <summary>
        /// Creates a new Text that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Text that is a copy of this instance.</returns>
        public override object Clone()
        {
            Text entity = new Text
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Text properties
                Position     = position,
                Rotation     = rotation,
                Height       = height,
                WidthFactor  = widthFactor,
                ObliqueAngle = obliqueAngle,
                Alignment    = alignment,
                Style        = (TextStyle)style.Clone(),
                Value        = text
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 19
0
        /// <summary>
        /// Creates a new Hatch that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Hatch that is a copy of this instance.</returns>
        /// <remarks>If the hatch is associative the referenced boundary entities will not be automatically cloned. Use CreateBoundary if required.</remarks>
        public override object Clone()
        {
            Hatch entity = new Hatch((HatchPattern)pattern.Clone(), associative)
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Hatch properties
                Elevation = elevation
            };

            foreach (HatchBoundaryPath path in boundaryPaths)
            {
                entity.boundaryPaths.Add((HatchBoundaryPath)path.Clone());
            }

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 20
0
        public override EffectBase Clone()
        {
            var result = (ShadowEffect)base.Clone();

            result.Color = Color.Clone();
            return(result);
        }
Esempio n. 21
0
        public override object Clone()
        {
            Shape entity = new Shape(name, (ShapeStyle)style.Clone())
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Shape properties
                Position     = position,
                Size         = size,
                Rotation     = rotation,
                ObliqueAngle = obliqueAngle,
                Thickness    = thickness
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 22
0
        public override object Clone()
        {
            Tolerance entity = new Tolerance
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Tolerance properties
                Entry1 = (ToleranceEntry)entry1.Clone(),
                Entry2 = (ToleranceEntry)entry2.Clone(),
                Height = height,
                ShowProjectedToleranceZoneSymbol = showProjectedToleranceZoneSymbol,
                DatumIdentifier = datumIdentifier,
                Style           = (DimensionStyle)style.Clone(),
                Position        = position,
                Rotation        = rotation
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 23
0
        /// <summary>
        /// Creates a new Ray that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Ray that is a copy of this instance.</returns>
        public override object Clone()
        {
            Ray entity = new Ray
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Ray properties
                Origin    = origin,
                Direction = direction,
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 24
0
        /// <summary>
        /// Creates a new Underlay that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Underlay that is a copy of this instance.</returns>
        public override object Clone()
        {
            Underlay entity = new Underlay
            {
                //EntityObject properties
                Layer         = (Layer)Layer.Clone(),
                Linetype      = (Linetype)Linetype.Clone(),
                Color         = (AciColor)Color.Clone(),
                Lineweight    = Lineweight,
                Transparency  = (Transparency)Transparency.Clone(),
                LinetypeScale = LinetypeScale,
                Normal        = Normal,
                IsVisible     = IsVisible,
                //Underlay properties
                Definition       = (UnderlayDefinition)definition.Clone(),
                Position         = position,
                Scale            = scale,
                Rotation         = rotation,
                Contrast         = contrast,
                Fade             = fade,
                DisplayOptions   = displayOptions,
                ClippingBoundary = clippingBoundary != null ? (ClippingBoundary)clippingBoundary.Clone() : null
            };

            foreach (XData data in XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
Esempio n. 25
0
    private void HandleDataChanged()
    {
        var    points = new PointCollection();
        double x      = 0;


        points.Add(new Point(0, canvas.ActualHeight));


        var xScale = canvas.ActualWidth / (Data.Count() - 1);
        var yScale = canvas.ActualHeight / Maximum;

        foreach (var dataPoint in Data)
        {
            var y = canvas.ActualHeight - dataPoint * yScale;

            points.Add(new Point(x, y));
            x += xScale;
        }

        points.Add(new Point(canvas.ActualWidth, canvas.ActualHeight));

        var fill = Color.Clone();

        fill.Opacity   = 0.2;
        polygon.Stroke = Color;
        polygon.Fill   = fill;

        polygon.Points = points;
    }
Esempio n. 26
0
        /// <summary>
        /// Creates a duplicate of the current value.
        /// </summary>
        /// <returns>The cloned value.</returns>
        /// <remarks>This method is a deep copy clone.</remarks>
        public object Clone()
        {
            var clone = (OpenExcelFont)MemberwiseClone();

            clone.Color = (HexBinaryValue)Color?.Clone();

            return(clone);
        }
Esempio n. 27
0
 /// <summary>
 /// Creates a MLineStyleElement that is a copy of the current instance.
 /// </summary>
 /// <returns>A new MLineStyleElement is a copy of this instance.</returns>
 public object Clone()
 {
     return(new MLineStyleElement(offset)
     {
         Color = (AciColor)Color.Clone(),
         Linetype = (Linetype)linetype.Clone()
     });
 }
Esempio n. 28
0
        public IPrototype Clone()
        {
            Color color = (Color)Color.Clone();

            return(new Shape()
            {
                Color = color, Name = this.Name
            });
        }
        internal SLGradientStop Clone()
        {
            var gs = new SLGradientStop(Color.listThemeColors);

            gs.Color       = Color.Clone();
            gs.decPosition = decPosition;

            return(gs);
        }
Esempio n. 30
0
        public void Clone(double red, double green, double blue, double alpha)
        {
            var color = new Color(red, green, blue, alpha);

            var cloneColor = color.Clone() as Color;

            Assert.Equal(color.Red, cloneColor.Red);
            Assert.Equal(color.Green, cloneColor.Green);
            Assert.Equal(color.Blue, cloneColor.Blue);
            Assert.Equal(color.Alpha, cloneColor.Alpha);
        }
Esempio n. 31
0
        private static void SetKeysAround(uint rowStart, uint colStart)
        {
            var colors = new Color[6][];
            var colorsColumns = new Color[22];
            for (var i = 0; i < colorsColumns.Length; i++)
            {
                colorsColumns[i] = Color.Black;
            }
            for (var i = 0; i < colors.Length; i++)
            {
                colors[i] = (Color[]) colorsColumns.Clone();
            }

            var indexList = new List<Tuple<int, int>>
            {
                Tuple.Create(-1, -1),
                Tuple.Create(-1, 0),
                Tuple.Create(-1, +1),
                Tuple.Create(0, -1),
                Tuple.Create(0, 0),
                Tuple.Create(0, +1),
                Tuple.Create(+1, -1),
                Tuple.Create(+1, 0),
                Tuple.Create(+1, +1)
            };

            foreach (var tuple in indexList)
            {
                if (((2 + tuple.Item1) > 0 && (2 + tuple.Item1) < maxRows)
                    && ((keyIndex + tuple.Item2) > 0 && (keyIndex + tuple.Item2) < maxCols))
                {
                    float brightnessModifier = (tuple.Item1 == 0 && tuple.Item2 == 0) ? 0f : 0.85f;
                    colors[2 + tuple.Item1][keyIndex + tuple.Item2] = new Color((1f - brightnessModifier), 0f, 0f);
                }
            }

            Keyboard.Instance.Set(new CustomGrid(colors));
            if (keyIndex >= maxCols)
            {
                keyIndex = 0;
            }
            else
            {
                keyIndex++;
            }
        }
Esempio n. 32
0
 public void Stroke(GraphicsPath path, Graphics g, int time, float opacity)
 {
     int num1 = 0;
     int num2 = 0;
     GraphicsContainer container1 = g.BeginContainer();
     AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
     g.SmoothingMode = base.OwnerDocument.SmoothingMode;
     SpreadMethods methods1 = this.SpreadMethod;
     bool flag1 = this.Units == Units.UserSpaceOnUse;
     float single1 = this.X1;
     float single2 = this.Y1;
     float single3 = this.X2;
     float single4 = this.Y2;
     if ((single1 == single3) && (single2 == single4))
     {
         single1 -= 1E-05f;
         single3 += 1E-05f;
     }
     float single5 = single1;
     float single6 = single2;
     float single7 = single3;
     float single8 = single4;
     RectangleF ef1 = RectangleF.Empty;
     RectangleF ef2 = RectangleF.Empty;
     Matrix matrix1 = this.Transform.Matrix.Clone();
     PointF[] tfArray4 = new PointF[2] { new PointF(single1, single2), new PointF(single3, single4) } ;
     PointF[] tfArray1 = tfArray4;
     matrix1.TransformPoints(tfArray1);
     single1 = tfArray1[0].X;
     single3 = tfArray1[1].X;
     single2 = tfArray1[0].Y;
     single4 = tfArray1[1].Y;
     bool flag2 = single2 == single4;
     bool flag3 = single1 == single3;
     float single9 = 1f;
     this.coord = new Matrix();
     this.ratiomatrix = new Matrix();
     RectangleF ef3 = PathFunc.GetBounds(path);
     if (flag1)
     {
         ef1 = ((SVG) base.OwnerDocument.DocumentElement).ViewPort;
     }
     else
     {
         ef3 = new RectangleF(0f, 0f, 1f, 1f);
         ef1 = ef3;
         ef2 = PathFunc.GetBounds(path);
         this.coord.Translate(ef2.X, ef2.Y);
         this.coord.Scale(ef2.Width, ef2.Width);
         this.ratiomatrix.Scale(1f, ef2.Height / ef2.Width);
     }
     PointF tf1 = new PointF(single1, single2);
     PointF tf2 = new PointF(single3, single4);
     PointF tf3 = tf1;
     PointF tf4 = tf2;
     ColorBlend blend1 = new ColorBlend(this.Stops.Count);
     Color[] colorArray1 = new Color[this.Stops.Count];
     float[] singleArray1 = new float[this.Stops.Count];
     SvgElementCollection collection1 = this.Stops;
     for (int num3 = 0; num3 < collection1.Count; num3++)
     {
         GradientStop stop1 = (GradientStop) collection1[num3];
         AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
         int num4 = 0xff;
         if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
         {
             if (stop1.Opacity <= 1f)
             {
                 num4 = (int) (stop1.Opacity * 255f);
             }
             else
             {
                 num4 = (int) stop1.Opacity;
             }
         }
         num4 = (int) Math.Min((float) (opacity * 255f), (float) num4);
         Color color1 = stop1.Color;
         float single10 = Math.Min((float) 1f, Math.Max((float) 0f, stop1.ColorOffset));
         colorArray1[num3] = Color.FromArgb(num4, color1.R, color1.G, color1.B);
         singleArray1[num3] = single10;
     }
     float[] singleArray2 = (float[]) singleArray1.Clone();
     Color[] colorArray2 = (Color[]) colorArray1.Clone();
     Array.Sort(singleArray2, colorArray2);
     Color color2 = colorArray2[0];
     Color color3 = colorArray2[colorArray2.Length - 1];
     float single11 = singleArray2[0];
     float single12 = singleArray2[singleArray2.Length - 1];
     if (singleArray2[0] != 0f)
     {
         float[] singleArray3 = (float[]) singleArray2.Clone();
         Color[] colorArray3 = (Color[]) colorArray2.Clone();
         singleArray2 = new float[singleArray2.Length + 1];
         colorArray2 = new Color[colorArray2.Length + 1];
         colorArray3.CopyTo(colorArray2, 1);
         singleArray3.CopyTo(singleArray2, 1);
         singleArray2[0] = 0f;
         colorArray2[0] = color2;
     }
     if (singleArray2[singleArray2.Length - 1] != 1f)
     {
         float[] singleArray4 = (float[]) singleArray2.Clone();
         Color[] colorArray4 = (Color[]) colorArray2.Clone();
         singleArray2 = new float[singleArray2.Length + 1];
         singleArray4.CopyTo(singleArray2, 0);
         singleArray2[singleArray2.Length - 1] = 1f;
         colorArray2 = new Color[colorArray2.Length + 1];
         colorArray4.CopyTo(colorArray2, 0);
         colorArray2[colorArray2.Length - 1] = color3;
     }
     PointF[] tfArray2 = new PointF[1];
     PointF[] tfArray3 = new PointF[4];
     if (methods1 == SpreadMethods.Pad)
     {
         if (flag2)
         {
             tf1 = new PointF(Math.Min(single1, ef3.X), tf1.Y);
             tf2 = new PointF(Math.Max(single3, ef3.Right), tf2.Y);
             float single13 = single1;
             float single14 = single3 - single1;
             for (int num5 = 0; num5 < singleArray2.Length; num5++)
             {
                 singleArray2[num5] = ((single13 + (single14 * singleArray2[num5])) - tf1.X) / (tf2.X - tf1.X);
             }
         }
         else if (flag3)
         {
             tf1 = new PointF(tf1.X, Math.Min(single2, ef3.Y));
             tf2 = new PointF(tf2.X, Math.Max(single4, ef3.Bottom));
             float single15 = single2;
             float single16 = single4 - single2;
             for (int num6 = 0; num6 < singleArray2.Length; num6++)
             {
                 singleArray2[num6] = ((single15 + (single16 * singleArray2[num6])) - tf1.Y) / (tf2.Y - tf1.Y);
             }
         }
         else
         {
             single9 = (single4 - single2) / (single3 - single1);
             float single17 = (single2 - (single9 * single1)) / (1f + (single9 * single9));
             PointF tf5 = ef3.Location;
             PointF tf6 = new PointF(ef3.Right, ef3.Y);
             PointF tf7 = new PointF(ef3.Right, ef3.Bottom);
             PointF tf8 = new PointF(ef3.X, ef3.Bottom);
             PointF[] tfArray5 = new PointF[4] { tf5, tf6, tf7, tf8 } ;
             tfArray2 = tfArray5;
             for (int num7 = 0; num7 < tfArray2.Length; num7++)
             {
                 PointF tf9 = tfArray2[num7];
                 float single18 = ((((single9 * single9) * tf9.Y) + (single9 * tf9.X)) / (1f + (single9 * single9))) + single17;
                 float single19 = (single9 * (tf9.Y - single18)) + tf9.X;
                 tfArray3[num7] = new PointF(single19, single18);
                 if (single1 < single3)
                 {
                     if (single19 < tf1.X)
                     {
                         tf1 = new PointF(single19, single18);
                         goto Label_0738;
                     }
                     if (single19 > tf2.X)
                     {
                         tf2 = new PointF(single19, single18);
                     }
                 }
                 else if (single19 < tf2.X)
                 {
                     tf2 = new PointF(single19, single18);
                 }
                 else if (single19 > tf1.X)
                 {
                     tf1 = new PointF(single19, single18);
                 }
             Label_0738:;
             }
             float single20 = single1;
             float single21 = single3 - single1;
             for (int num8 = 0; num8 < singleArray2.Length; num8++)
             {
                 singleArray2[num8] = ((single20 + (single21 * singleArray2[num8])) - tf1.X) / (tf2.X - tf1.X);
             }
         }
         if (singleArray2[0] != 0f)
         {
             float[] singleArray5 = (float[]) singleArray2.Clone();
             Color[] colorArray5 = (Color[]) colorArray2.Clone();
             singleArray2 = new float[singleArray2.Length + 1];
             colorArray2 = new Color[colorArray2.Length + 1];
             colorArray5.CopyTo(colorArray2, 1);
             singleArray5.CopyTo(singleArray2, 1);
             singleArray2[0] = 0f;
             colorArray2[0] = color2;
         }
         if (singleArray2[singleArray2.Length - 1] != 1f)
         {
             float[] singleArray6 = (float[]) singleArray2.Clone();
             Color[] colorArray6 = (Color[]) colorArray2.Clone();
             singleArray2 = new float[singleArray2.Length + 1];
             singleArray6.CopyTo(singleArray2, 0);
             singleArray2[singleArray2.Length - 1] = 1f;
             colorArray2 = new Color[colorArray2.Length + 1];
             colorArray6.CopyTo(colorArray2, 0);
             colorArray2[colorArray2.Length - 1] = color3;
         }
     }
     this.brush = new LinearGradientBrush(tf1, tf2, color2, color3);
     if (methods1 == SpreadMethods.Reflect)
     {
         this.brush.WrapMode = WrapMode.TileFlipXY;
     }
     else
     {
         this.brush.WrapMode = WrapMode.Tile;
     }
     blend1.Colors = colorArray2;
     blend1.Positions = singleArray2;
     this.brush.InterpolationColors = blend1;
     this.coord.Multiply(this.ratiomatrix);
     this.brush.Transform = this.coord;
     GraphicsPath path1 = (GraphicsPath) path.Clone();
     if (this.pen != null)
     {
         this.pen.Brush = this.brush;
         g.DrawPath(this.pen, path1);
     }
     if (!base.OwnerDocument.PlayAnim)
     {
         this.gradientpath = new GraphicsPath();
         PointF[] tfArray6 = new PointF[8] { new PointF((single5 + single7) / 2f, ((single6 + single8) / 2f) + 0.5f), new PointF(single7, single8 + 0.5f), new PointF(single7, single8), PointF.Empty, new PointF(single7, ((single6 + single8) / 2f) + 1f), PointF.Empty, PointF.Empty, PointF.Empty } ;
         this.boundsPoints = tfArray6;
         this.gradientpath.AddLine(new PointF(single5, single6), new PointF(single5, single6 + 1f));
         this.gradientpath.StartFigure();
         this.gradientpath.AddLine(new PointF(single7, single8), new PointF(single7, single8 + 1f));
     }
     this.pretime = time;
     g.EndContainer(container1);
 }
    //On GUI.
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //Set the row height and initial position.
        float rowHeight = base.GetPropertyHeight(property, label);
        position = new Rect(position.xMin, position.yMin, position.width, rowHeight);
        rowHeight += EditorGUIUtility.standardVerticalSpacing;

        //If the sprite doesn't have its "readable" flag set, warn the user and given them the option to set it.
        SpriteRenderer spriteRenderer = ((SpriteShatter.Shatter) property.serializedObject.targetObject).gameObject.GetComponent<SpriteRenderer>();
        if (spriteRenderer == null || spriteRenderer.sprite == null) {
            position.height *= 2;
            EditorGUI.HelpBox(position, "Sprite Renderer does not have a sprite!", MessageType.Error);
            return;
        }
        string assetPath = AssetDatabase.GetAssetPath(spriteRenderer.sprite);
        TextureImporter textureImporter = (TextureImporter) AssetImporter.GetAtPath(assetPath);
        if (!textureImporter.isReadable) {
            addRow(ref position, rowHeight);
            position.height *= 2;
            EditorGUI.HelpBox(position, "Texture \"Read/Write\" flag not set!", MessageType.Error);
            position.height /= 2;
            addRow(ref position, rowHeight * 2);
            if (GUI.Button(position, new GUIContent("Set Texture Read/Write Flag", "Sprite Shatter requires that the sprite's texture has its \"Read/Write\"" +
                    "flag set. This is to ensure that the pixels can be read from the texture in order to shatter it. The flag is not currently set on the " +
                    "texture associated with this sprite, but you can click the button below to set it."))) {
                textureImporter.isReadable = true;
                AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
                EditorUtility.DisplayDialog("Texture Read/Write Flag Set", "The \"Read/Write\" flag has been set on the texture associated with this sprite.",
                        "OK");
            }
            addRow(ref position, rowHeight);
        }

        //Display the property fields.
        addRow(ref position, rowHeight);
        EditorGUI.LabelField(position, "Create Shatter Objects", EditorStyles.boldLabel);
        addRow(ref position, rowHeight);
        property.Next(true);
        EditorGUI.BeginProperty(position, label, property);
        property.intValue = EditorGUI.IntSlider(position, new GUIContent("Horizontal Cuts", "The number of cuts to make going horizontally across the " +
                "sprite. More cuts will shatter the sprite into smaller pieces, but will require more game objects and may affect performance."),
                property.intValue, 1, 32);
        EditorGUI.EndProperty();
        int horizontalCuts = property.intValue;
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.intValue = EditorGUI.IntSlider(position, new GUIContent("Vertical Cuts", "The number of cuts to make going vertically down the sprite. More " +
                "cuts will shatter the sprite into smaller pieces, but will require more game objects and may affect performance."), property.intValue, 1, 32);
        EditorGUI.EndProperty();
        int verticalCuts = property.intValue;
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.boolValue = EditorGUI.Toggle(position, new GUIContent("Randomize at Runtime", "Generate a completely random seed at runtime, meaning the " +
                "layout of the shattered sprite pieces will be different every time the game is run. This only has any effect if \"Randomness\" is set to " +
                "greater than zero."), property.boolValue);
        EditorGUI.EndProperty();
        bool randomizeAtRuntime = property.boolValue;
        addRow(ref position, rowHeight);
        property.Next(false);
        if (!randomizeAtRuntime) {
            EditorGUI.BeginProperty(position, label, property);
            property.intValue = EditorGUI.IntField(position, new GUIContent("Random Seed", "The seed value to use when generating random numbers. The same " +
                    "seed will always generate cuts in the same way, which is useful if you want multiple objects to shatter in an identical way. Otherwise " +
                    "you can select \"Randomize at Runtime\" below to generate a different random set of cuts each time the game runs. The random seed only " +
                    "has any effect if \"Randomness\" is set to greater than zero."), property.intValue);
            EditorGUI.EndProperty();
            addRow(ref position, rowHeight);
        }
        int randomSeed = property.intValue;
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.floatValue = EditorGUI.Slider(position, new GUIContent("Randomness", "The amount of randomness to apply to the cuts. A value of zero will " +
                "result in perfectly straight cuts, whereas a value of one will result in cuts that potentially could be almost touching each other."),
                property.floatValue, 0, 1);
        EditorGUI.EndProperty();
        float randomness = property.floatValue;
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.floatValue = EditorGUI.Slider(position, new GUIContent("Zigzag Frequency", "This property, along with \"Zigzag Amplitude\" allows for a " +
                "zigzag shape to be added to the cuts to make more jagged edges and more random-looking pieces. \"Zigzag Frequency\" specifies the number of " +
                "jagged edges across or down the cuts, but will have no effect if \"Zigzag Amplitude\" is zero."), property.floatValue, 0, 1);
        EditorGUI.EndProperty();
        float zigzagFrequency = property.floatValue;
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.floatValue = EditorGUI.Slider(position, new GUIContent("Zigzag Amplitude", "This property, along with \"Zigzag Amplitude\" allows for a " +
                "zigzag shape to be added to the cuts to make more jagged edges and more random-looking pieces. \"Zigzag Frequency\" specifies the number of " +
                "jagged edges across or down the cuts, but will have no effect if \"Zigzag Amplitude\" is zero."), property.floatValue, 0, 1);
        EditorGUI.EndProperty();
        float zigzagAmplitude = property.floatValue;
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.intValue = EditorGUI.IntPopup(position, new GUIContent("Collider Types", "The collider type to add to each of the shattered pieces of the " +
                "sprite. Having no collider is the most efficient way of shattering a sprite, but the shattered pieces will not collide with anything. A " +
                "polygon collider is the least-efficient collider, but produces the most accurate collisions."), property.intValue, new GUIContent[] {
                new GUIContent("None", "Do not apply any any colliders to the shattered pieces."),
                new GUIContent("Circle", "Apply circle colliders to the shattered pieces."),
                new GUIContent("Box", "Apply box colliders to the shattered pieces."),
                new GUIContent("Polygon", "Apply polygon colliders to the shattered pieces that match the shape each piece.") },
                new int[] { 0, 1, 2, 3 });
        EditorGUI.EndProperty();
        addRow(ref position, rowHeight);
        addRow(ref position, rowHeight);
        EditorGUI.LabelField(position, "Sprite Shattering Properties", EditorStyles.boldLabel);
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.vector2Value = EditorGUI.Vector2Field(position, new GUIContent("Explode From", "The position from which to apply the explosion force when " +
                "exploding the shattered pieces of the sprite. The X co-ordinate should be 0 for the left edge of the sprite and 1 for the right edge, and " +
                "the Y co-ordinate should be 0 for bottom of the sprite and 1 for the top, although the values can be outside this range. For example to " +
                "make the sprite explode up from the bottom, co-ordinates of (0.5, 0) could be used."), property.vector2Value);
        EditorGUI.EndProperty();
        addRow(ref position, rowHeight);
        property.Next(false);
        EditorGUI.BeginProperty(position, label, property);
        property.vector2Value = EditorGUI.Vector2Field(position, new GUIContent("Explosion Force", "The force to apply in the X and Y direction when " +
                "exploding the shattered pieces of the sprite. A force of zero will make the sprite just collapse in its current position"),
                property.vector2Value);
        EditorGUI.EndProperty();
        addRow(ref position, rowHeight);

        //Display a preview texture with the cuts made. First display a "Preview" header.
        addRow(ref position, rowHeight);
        EditorGUI.LabelField(position, "Preview", EditorStyles.boldLabel);
        addRow(ref position, rowHeight);
        if (!textureImporter.isReadable) {
            position.height *= 2;
            EditorGUI.HelpBox(position, "Texture \"Read/Write\" flag not set!", MessageType.Error);
        }
        else {
            int textureWidth = (int) spriteRenderer.sprite.rect.width;
            int textureHeight = (int) spriteRenderer.sprite.rect.height;

            //Calculate the texture width and height from the window width.
            int previewTextureWidth = (int) (position.width * 0.75f);
            int previewTextureHeight = (int) (((float) textureHeight / (float) textureWidth) * position.width * 0.75f);
            Color[] sourcePixels = spriteRenderer.sprite.texture.GetPixels((int) spriteRenderer.sprite.rect.xMin, (int) spriteRenderer.sprite.rect.yMin,
                    (int) spriteRenderer.sprite.rect.width, (int) spriteRenderer.sprite.rect.height);

            //If the preview texture is at least two pixels wide...
            if (previewTextureWidth > 1) {

                //Call the method that makes the cuts as these will be drawn onto the texture.
                int[,] horizontalCutTop, verticalCutLeft;
                ((SpriteShatter.Shatter) property.serializedObject.targetObject).makeCuts(spriteRenderer.sprite, horizontalCuts, verticalCuts, randomSeed,
                        randomness, zigzagFrequency, zigzagAmplitude, out horizontalCutTop, out verticalCutLeft);

                //Create the preview texture and set its pixels from the main texture.
                Texture2D previewTexture = new Texture2D(previewTextureWidth, previewTextureHeight, TextureFormat.RGBA32, false);
                previewTexture.hideFlags = HideFlags.HideAndDontSave;
                Color[] previewTexturePixels = new Color[previewTextureWidth * previewTextureHeight];
                for (int i = 0; i < previewTextureWidth; i++)
                    for (int j = 0; j < previewTextureHeight; j++)
                        previewTexturePixels[(j * previewTextureWidth) + i] = sourcePixels[(((j * textureHeight) / previewTextureHeight) * textureWidth) +
                                ((i * textureWidth) / previewTextureWidth)];

                //Loop over the cuts and draw them on the texture (white with a black outline to cover all texture colours).
                Color[] originalPreviewTexturePixels = (Color[]) previewTexturePixels.Clone();
                for (int l = 0; l < 2; l++) {
                    for (int i = 0; i < horizontalCuts; i++)
                        for (int j = 0; j < textureWidth; j++) {
                            int previewTextureX = (j * previewTextureWidth) / textureWidth;
                            int previewTextureY = (horizontalCutTop[i, j] * previewTextureHeight) / textureHeight;
                            if (originalPreviewTexturePixels[(previewTextureY * previewTextureWidth) + previewTextureX].a > 0.001f) {
                                for (int m = l == 0 ? -1 : 0; m <= (l == 0 ? 1 : 0); m++)
                                    for (int k = l == 0 ? -1 : 0; k <= (l == 0 ? 1 : 0); k++) {
                                        if (previewTextureX + m >= 0 && previewTextureX + m < previewTextureWidth && previewTextureY + k >= 0 &&
                                                previewTextureY + k < previewTextureHeight)
                                            previewTexturePixels[((previewTextureY + k) * previewTextureWidth) + previewTextureX + m] = l == 0 ? Color.black :
                                                    Color.white;
                                    }
                            }
                        }
                    for (int i = 0; i < verticalCuts; i++)
                        for (int j = 0; j < textureHeight; j++) {
                            int previewTextureX = (verticalCutLeft[i, j] * previewTextureWidth) / textureWidth;
                            int previewTextureY = (j * previewTextureHeight) / textureHeight;
                            if (originalPreviewTexturePixels[(previewTextureY * previewTextureWidth) + previewTextureX].a > 0.001f) {
                                for (int m = l == 0 ? -1 : 0; m <= (l == 0 ? 1 : 0); m++)
                                    for (int k = l == 0 ? -1 : 0; k <= (l == 0 ? 1 : 0); k++)
                                        if (previewTextureX + m >= 0 && previewTextureX + m < previewTextureWidth && previewTextureY + k >= 0 &&
                                                previewTextureY + k < previewTextureHeight)
                                            previewTexturePixels[((previewTextureY + k) * previewTextureWidth) + previewTextureX + m] = l == 0 ? Color.black :
                                                    Color.white;
                            }
                        }
                }
                previewTexture.SetPixels(previewTexturePixels);
                previewTexture.Apply();

                //Draw the texture in the editor window.
                position.xMin += position.width * 0.125f;
                position.xMax -= position.width * 0.125f;
                position.height = previewTextureHeight;
                GUIStyle style = new GUIStyle();
                style.normal.background = previewTexture;
                EditorGUI.LabelField(position, GUIContent.none, style);
            }
        }
    }
Esempio n. 34
0
 public Board(Color[,] colors)
 {
     Colors = (Color[,])colors.Clone();
     FireBoardUpdated();
 }
Esempio n. 35
0
        public void SetObject( Vector3[] vertices, Color[] colors, int[,] ribs )
        {
            if ( vertices.Length != colors.Length )
            {
                throw new ArgumentException( "Number of colors must be equal to number of vertices." );
            }

            if ( ribs.GetLength( 1 ) != 2 )
            {
                throw new ArgumentException( "Ribs array must have 2 coordinates per rib." );
            }

            this.objectPoints = (Vector3[]) vertices.Clone( );
            this.colors = (Color[]) colors.Clone( );
            this.lines = (int[,]) ribs.Clone( );

            Recalculate( );
        }
Esempio n. 36
0
 public PaletteTable(Color[] palette)
 {
     this.palette = (Color[])palette.Clone();
 }
Esempio n. 37
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aclr"></param>
 public Palette(Color[] aclr)
 {
     m_aclr = (Color[])aclr.Clone();
 }
Esempio n. 38
0
        public Color[,] Colorize(Color[,] input)
        {
            Color[,] output = (Color[,])input.Clone();

            for (int i = -4; i < 5; i++)
            {
                for (int j = -4; j < 5; j++)
                {
                    output[OffsetX + LongestChord.firstPixel.X + i, OffsetY + LongestChord.firstPixel.Y + j] = Color.Red;
                    output[OffsetX + LongestChord.secondPixel.X + i, OffsetY + LongestChord.secondPixel.Y + j] = Color.Orange;
                    output[OffsetX + LongestPerpendicularChord.firstPixel.X + i, OffsetY + LongestPerpendicularChord.firstPixel.Y + j] = Color.Blue;
                    output[OffsetX + LongestPerpendicularChord.secondPixel.X + i, OffsetY + LongestPerpendicularChord.secondPixel.Y + j] = Color.Cyan;
                }
            }

            return output;
        }
Esempio n. 39
0
        public Color[,] ColorizeVectors(Color[,] input)
        {
            if (LongestChord.firstPixel == null || LongestChord.secondPixel == null
                || LongestPerpendicularChord.firstPixel == null || LongestPerpendicularChord.secondPixel == null)
                return input;

            Color[,] output = (Color[,])input.Clone();

            double angle = LongestChord.orientation;
            double uv1CosAngle = Math.Cos(angle);
            double uv1SinAngle = Math.Sin(angle);

            double pAngle = Math.PI / 2;
            double[] rotationArray = new double[] { Math.Cos(pAngle), -1.0 * Math.Sin(pAngle), Math.Sin(pAngle), Math.Cos(pAngle) };
            Matrix<double> rotationMatrix = new DenseMatrix(2, 2, rotationArray);

            Vector<double> unitVector1 = new DenseVector(new double[] { uv1CosAngle, uv1SinAngle });
            Vector<double> unitVector2 = new DenseVector(new double[2]);
            rotationMatrix.LeftMultiply(unitVector1, unitVector2);

            double uv2CosAngle = unitVector2[0];
            double uv2SinAngle = unitVector2[1];

            int lcX = 0;
            if (uv1CosAngle > 0)
                if (LongestChord.firstPixel.X < LongestChord.secondPixel.X)
                    lcX = LongestChord.firstPixel.X;
                else
                    lcX = LongestChord.secondPixel.X;
            else
                if (LongestChord.firstPixel.X < LongestChord.secondPixel.X)
                    lcX = LongestChord.secondPixel.X;
                else
                    lcX = LongestChord.firstPixel.X;

            int lcY = 0;
            if (uv1SinAngle > 0)
                if (LongestChord.firstPixel.Y < LongestChord.secondPixel.Y)
                    lcY = LongestChord.firstPixel.Y;
                else
                    lcY = LongestChord.secondPixel.Y;
            else
                if (LongestChord.firstPixel.Y < LongestChord.secondPixel.Y)
                    lcY = LongestChord.secondPixel.Y;
                else
                    lcY = LongestChord.firstPixel.Y;

            for (int i = 0; i < LongestChord.distance; i++)
            {
                int uv1X = OffsetX + lcX + ((int)Math.Round(uv1CosAngle * i));
                int uv1Y = OffsetY + lcY + ((int)Math.Round(uv1SinAngle * i));
                output[uv1X, uv1Y] = Color.Red;
            }

            int lpcX = 0;
            if (uv2CosAngle > 0)
                if (LongestPerpendicularChord.firstPixel.X < LongestPerpendicularChord.secondPixel.X)
                    lpcX = LongestPerpendicularChord.firstPixel.X;
                else
                    lpcX = LongestPerpendicularChord.secondPixel.X;
            else
                if (LongestPerpendicularChord.firstPixel.X < LongestPerpendicularChord.secondPixel.X)
                    lpcX = LongestPerpendicularChord.secondPixel.X;
                else
                    lpcX = LongestPerpendicularChord.firstPixel.X;

            int lpcY = 0;
            if (uv2SinAngle > 0)
                if (LongestPerpendicularChord.firstPixel.Y < LongestPerpendicularChord.secondPixel.Y)
                    lpcY = LongestPerpendicularChord.firstPixel.Y;
                else
                    lpcY = LongestPerpendicularChord.secondPixel.Y;
            else
                if (LongestPerpendicularChord.firstPixel.Y < LongestPerpendicularChord.secondPixel.Y)
                    lpcY = LongestPerpendicularChord.secondPixel.Y;
                else
                    lpcY = LongestPerpendicularChord.firstPixel.Y;

            for (int i = 0; i < LongestPerpendicularChord.distance; i++)
            {
                int uv2X = OffsetX + lpcX + ((int)Math.Round(uv2CosAngle * i));
                int uv2Y = OffsetY + lpcY + ((int)Math.Round(uv2SinAngle * i));
                output[uv2X, uv2Y] = Color.Blue;
            }

            return output;
        }
Esempio n. 40
0
        public Color[,] FillObject(Color[,] input)
        {
            if (perimeterPixels == null)
                return input;

            Color[,] output = (Color[,])input.Clone();

            for (int i = 0; i < perimeterListPixels.Count; i++)
            {
                int x1 = perimeterListPixels[i].X, y1 = perimeterListPixels[i].Y;

                for (int j = 0; j < perimeterListPixels.Count; j++)
                {
                    if (i == j)
                        continue;

                    int x2 = perimeterListPixels[j].X, y2 = perimeterListPixels[j].Y;

                    double distance = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
                    double stepXDistance = ((double)(x2 - x1)) / distance;
                    double stepYDistance = ((double)(y2 - y1)) / distance;

                    for (int k = 0; k < distance; k++)
                    {
                        int uv1X = OffsetX + x1 + ((int)Math.Round(stepXDistance * k));
                        int uv1Y = OffsetY + y1 + ((int)Math.Round(stepYDistance * k));

                        if (uv1X < 0) // For safety
                            uv1X = 0;
                        if (uv1X > output.GetLength(0) - 1)
                            uv1X = output.GetLength(0) - 1;

                        if (uv1Y < 0)
                            uv1Y = 0;
                        if (uv1Y > output.GetLength(1) - 1)
                            uv1Y = output.GetLength(1) - 1;

                        output[uv1X, uv1Y] = Color.Black;
                    }
                }
            }

            return output;
        }
Esempio n. 41
0
 public void Stroke(GraphicsPath path, Graphics g, int time, float opacity)
 {
     int num1 = 0;
     int num2 = 0;
     AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
     path.FillMode = FillMode.Alternate;
     g.SmoothingMode = base.OwnerDocument.SmoothingMode;
     SpreadMethods methods1 = this.SpreadMethod;
     bool flag1 = this.Units == Units.UserSpaceOnUse;
     float single1 = this.CX;
     float single2 = this.CY;
     float single3 = this.R;
     float single4 = this.FX;
     float single5 = this.FY;
     PointF[] tfArray2 = new PointF[7] { new PointF(single1, single2), new PointF(single1 + single3, single2), new PointF(single1 + (single3 * ((float) Math.Sin(1.8325957145940459))), single2 + (single3 * ((float) Math.Cos(1.8325957145940459)))), new PointF(single1 + (single3 * ((float) Math.Sin(1.3089969389957472))), single2 + (single3 * ((float) Math.Cos(1.3089969389957472)))), new PointF(single1, single2 + single3), PointF.Empty, PointF.Empty } ;
     this.boundsPoints = tfArray2;
     GraphicsPath path1 = this.gradientpath;
     path1.Reset();
     path1.AddEllipse((float) (single1 - single3), (float) (single2 - single3), (float) (2f * single3), (float) (2f * single3));
     RectangleF ef1 = RectangleF.Empty;
     RectangleF ef2 = PathFunc.GetBounds(path);
     RectangleF ef3 = RectangleF.Empty;
     this.coord.Reset();
     if (flag1)
     {
         ef3 = ((SVG) base.OwnerDocument.DocumentElement).ViewPort;
     }
     else
     {
         ef2 = new RectangleF(0f, 0f, 1f, 1f);
         ef3 = ef2;
         ef1 = PathFunc.GetBounds(path);
         this.coord.Translate(ef1.X, ef1.Y);
         this.coord.Scale(ef1.Width, ef1.Height);
     }
     ColorBlend blend1 = new ColorBlend(this.Stops.Count);
     Color[] colorArray1 = new Color[this.Stops.Count];
     float[] singleArray1 = new float[this.Stops.Count];
     SvgElementCollection collection1 = this.Stops;
     for (int num3 = 0; num3 < collection1.Count; num3++)
     {
         GradientStop stop1 = (GradientStop) collection1[num3];
         AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
         int num4 = 0xff;
         if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
         {
             if (stop1.Opacity <= 1f)
             {
                 num4 = (int) (stop1.Opacity * 255f);
             }
             else
             {
                 num4 = (int) stop1.Opacity;
             }
         }
         num4 = (int) Math.Min((float) (opacity * 255f), (float) num4);
         Color color1 = stop1.Color;
         float single6 = Math.Min((float) 1f, Math.Max((float) 0f, stop1.ColorOffset));
         colorArray1[num3] = Color.FromArgb(num4, color1.R, color1.G, color1.B);
         singleArray1[num3] = single6;
     }
     float[] singleArray2 = (float[]) singleArray1.Clone();
     Color[] colorArray2 = (Color[]) colorArray1.Clone();
     Array.Sort(singleArray2, colorArray2);
     Color color2 = colorArray2[0];
     Color color3 = colorArray2[colorArray2.Length - 1];
     if (singleArray2[0] != 0f)
     {
         float[] singleArray3 = (float[]) singleArray2.Clone();
         Color[] colorArray3 = (Color[]) colorArray2.Clone();
         singleArray2 = new float[singleArray2.Length + 1];
         colorArray2 = new Color[colorArray2.Length + 1];
         colorArray3.CopyTo(colorArray2, 1);
         singleArray3.CopyTo(singleArray2, 1);
         singleArray2[0] = 0f;
         colorArray2[0] = color2;
     }
     if (singleArray2[singleArray2.Length - 1] != 1f)
     {
         float[] singleArray4 = (float[]) singleArray2.Clone();
         Color[] colorArray4 = (Color[]) colorArray2.Clone();
         singleArray2 = new float[singleArray2.Length + 1];
         singleArray4.CopyTo(singleArray2, 0);
         singleArray2[singleArray2.Length - 1] = 1f;
         colorArray2 = new Color[colorArray2.Length + 1];
         colorArray4.CopyTo(colorArray2, 0);
         colorArray2[colorArray2.Length - 1] = color3;
     }
     if (methods1 == SpreadMethods.Pad)
     {
         float single7 = Math.Min((float) (single1 - single3), ef2.X);
         float single8 = Math.Min((float) (single2 - single3), ef2.Y);
         float single9 = Math.Max(single3, (float) (ef2.Width / 2f));
         float single10 = this.cx - single3;
         float single11 = this.r;
         for (int num5 = 0; num5 < singleArray2.Length; num5++)
         {
             singleArray2[num5] = ((single10 + (single11 * singleArray2[num5])) - single7) / single9;
         }
         if (singleArray2[0] != 0f)
         {
             float[] singleArray5 = (float[]) singleArray2.Clone();
             Color[] colorArray5 = (Color[]) colorArray2.Clone();
             singleArray2 = new float[singleArray2.Length + 1];
             colorArray2 = new Color[colorArray2.Length + 1];
             colorArray5.CopyTo(colorArray2, 1);
             singleArray5.CopyTo(singleArray2, 1);
             singleArray2[0] = 0f;
             colorArray2[0] = color2;
         }
         if (singleArray2[singleArray2.Length - 1] != 1f)
         {
             float[] singleArray6 = (float[]) singleArray2.Clone();
             Color[] colorArray6 = (Color[]) colorArray2.Clone();
             singleArray2 = new float[singleArray2.Length + 1];
             singleArray6.CopyTo(singleArray2, 0);
             singleArray2[singleArray2.Length - 1] = 1f;
             colorArray2 = new Color[colorArray2.Length + 1];
             colorArray6.CopyTo(colorArray2, 0);
             colorArray2[colorArray2.Length - 1] = color3;
         }
     }
     Array.Reverse(colorArray2);
     Array.Reverse(singleArray2);
     for (int num6 = 0; num6 < singleArray2.Length; num6++)
     {
         singleArray2[num6] = 1f - singleArray2[num6];
     }
     Matrix matrix1 = this.Transform.Matrix.Clone();
     path1 = (GraphicsPath) this.gradientpath.Clone();
     path1.Transform(matrix1);
     this.brush = new PathGradientBrush(path1);
     blend1.Colors = colorArray2;
     blend1.Positions = singleArray2;
     this.brush.InterpolationColors = blend1;
     if (methods1 == SpreadMethods.Reflect)
     {
         this.brush.WrapMode = WrapMode.TileFlipXY;
     }
     else if (methods1 == SpreadMethods.Reflect)
     {
         this.brush.WrapMode = WrapMode.Tile;
     }
     else
     {
         this.brush.WrapMode = WrapMode.Clamp;
     }
     if (AttributeFunc.FindAttribute("fx", this).ToString() == string.Empty)
     {
         single4 = this.CX;
     }
     if (AttributeFunc.FindAttribute("fy", this).ToString() == string.Empty)
     {
         single5 = this.CY;
     }
     PointF[] tfArray3 = new PointF[1] { new PointF(single4, single5) } ;
     PointF[] tfArray1 = tfArray3;
     matrix1.TransformPoints(tfArray1);
     this.brush.CenterPoint = tfArray1[0];
     this.brush.Transform = this.coord;
     if (this.pen != null)
     {
         this.pen.Brush = this.brush;
         g.DrawPath(this.pen, path);
     }
     this.pretime = -1;
 }