当前位置: 首页>>代码示例>>C#>>正文


C# TextureBrush.ScaleTransform方法代码示例

本文整理汇总了C#中System.Drawing.TextureBrush.ScaleTransform方法的典型用法代码示例。如果您正苦于以下问题:C# TextureBrush.ScaleTransform方法的具体用法?C# TextureBrush.ScaleTransform怎么用?C# TextureBrush.ScaleTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.TextureBrush的用法示例。


在下文中一共展示了TextureBrush.ScaleTransform方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: setPaint

        public override void setPaint(java.awt.Paint paint)
        {
            if (paint is java.awt.Color)
            {
                setColor((java.awt.Color)paint);
                return;
            }

            if (paint == null || this.javaPaint == paint)
            {
                return;
            }
            this.javaPaint = paint;

            if (paint is java.awt.GradientPaint)
            {
                java.awt.GradientPaint gradient = (java.awt.GradientPaint)paint;
                LinearGradientBrush linear;
                if (gradient.isCyclic())
                {
                    linear = new LinearGradientBrush(
                        J2C.ConvertPoint(gradient.getPoint1()),
                        J2C.ConvertPoint(gradient.getPoint2()),
                        composite.GetColor(gradient.getColor1()),
                        composite.GetColor(gradient.getColor2()));
                }
                else
                {
                    //HACK because .NET does not support continue gradient like Java else Tile Gradient
                    //that we receize the rectangle very large (factor z) and set 4 color values
                    // a exact solution will calculate the size of the Graphics with the current transform
                    Color color1 = composite.GetColor(gradient.getColor1());
                    Color color2 = composite.GetColor(gradient.getColor2());
                    float x1 = (float)gradient.getPoint1().getX();
                    float x2 = (float)gradient.getPoint2().getX();
                    float y1 = (float)gradient.getPoint1().getY();
                    float y2 = (float)gradient.getPoint2().getY();
                    float diffX = x2 - x1;
                    float diffY = y2 - y1;
                    const float z = 60; //HACK zoom factor, with a larger factor .NET will make the gradient wider.
                    linear = new LinearGradientBrush(
                        new PointF(x1 - z * diffX, y1 - z * diffY),
                        new PointF(x2 + z * diffX, y2 + z * diffY),
                        color1,
                        color1);
                    ColorBlend colorBlend = new ColorBlend(4);
                    Color[] colors = colorBlend.Colors;
                    colors[0] = colors[1] = color1;
                    colors[2] = colors[3] = color2;
                    float[] positions = colorBlend.Positions;
                    positions[1] = z / (2 * z + 1);
                    positions[2] = (z + 1) / (2 * z + 1);
                    positions[3] = 1.0f;
                    linear.InterpolationColors = colorBlend;
                }
                linear.WrapMode = WrapMode.TileFlipXY;
                brush = linear;
                pen.Brush = brush;
                return;
            }

            if (paint is java.awt.TexturePaint)
            {
                java.awt.TexturePaint texture = (java.awt.TexturePaint)paint;
                Bitmap txtr = J2C.ConvertImage(texture.getImage());
                java.awt.geom.Rectangle2D anchor = texture.getAnchorRect();
                TextureBrush txtBrush;
                brush = txtBrush = new TextureBrush(txtr, new Rectangle(0, 0, txtr.Width, txtr.Height), composite.GetImageAttributes());
                txtBrush.TranslateTransform((float)anchor.getX(), (float)anchor.getY());
                txtBrush.ScaleTransform((float)anchor.getWidth() / txtr.Width, (float)anchor.getHeight() / txtr.Height);
                txtBrush.WrapMode = WrapMode.Tile;
                pen.Brush = brush;
                return;
            }

            if (paint is java.awt.LinearGradientPaint) {
                java.awt.LinearGradientPaint gradient = (java.awt.LinearGradientPaint)paint;
                PointF start = J2C.ConvertPoint(gradient.getStartPoint());
                PointF end = J2C.ConvertPoint(gradient.getEndPoint());

                java.awt.Color[] javaColors = gradient.getColors();
                ColorBlend colorBlend;
                Color[] colors;
                bool noCycle = gradient.getCycleMethod() == java.awt.MultipleGradientPaint.CycleMethod.NO_CYCLE;
                if (noCycle) {
                    //HACK because .NET does not support continue gradient like Java else Tile Gradient
                    //that we receize the rectangle very large (factor z) and set 2 additional color values
                    //an exact solution will calculate the size of the Graphics with the current transform
                    float diffX = end.X - start.X;
                    float diffY = end.Y - start.Y;
                    SizeF size = GetSize();
                    //HACK zoom factor, with a larger factor .NET will make the gradient wider.
                    float z = Math.Min(10, Math.Max(size.Width / diffX, size.Height / diffY));
                    start.X -= z * diffX;
                    start.Y -= z * diffY;
                    end.X += z * diffX;
                    end.Y += z * diffY;

                    colorBlend = new ColorBlend(javaColors.Length + 2);
                    colors = colorBlend.Colors;
//.........这里部分代码省略.........
开发者ID:kenasogoo,项目名称:ikvm-fork,代码行数:101,代码来源:graphics.cs

示例2: CreatePatternBrush

        void CreatePatternBrush(float pixelSize)
        {
            //  Determine adjusted pixel size of the brush to create.
            const float MAX_PATTERN_SIZE = 80;
            const float MIN_PATTERN_SIZE = 10;
            if (pixelSize < patternWidth / MAX_PATTERN_SIZE)
                pixelSize = patternWidth / MAX_PATTERN_SIZE;
            if (pixelSize < patternHeight / MAX_PATTERN_SIZE)
                pixelSize = patternHeight / MAX_PATTERN_SIZE;
            if (pixelSize > patternWidth / MIN_PATTERN_SIZE)
                pixelSize = patternWidth / MIN_PATTERN_SIZE;
            if (pixelSize > patternHeight / MIN_PATTERN_SIZE)
                pixelSize = patternHeight / MIN_PATTERN_SIZE;

            if (patternBrushes != null && Math.Abs(pixelSize - pixelSizeCached) / pixelSize < 0.01)
                return;         // the pattern brush is already OK size.

            // Get size of bitmap to create with the image of the pattern.
            float width = (float) Math.Round(patternWidth / pixelSize);
            float height = (float) Math.Round(patternHeight / pixelSize);

            // Create dictionary to hold brushes for each color.
            patternBrushes = new Dictionary<SymColor, Brush>(2);
            pixelSizeCached = pixelSize;

            RenderOptions renderOpts = new RenderOptions();
            renderOpts.minResolution = pixelSize;
            renderOpts.usePatternBitmaps = false;

            foreach (SymColor color in map.colors) {
                if (!patternGlyph.HasColor(color))
                    continue;

                // Create a new bitmap and fill it transparent.
                Bitmap bitmap = new Bitmap((int) width, (int) (offsetRows ? height * 2 : height));
                Graphics g = Graphics.FromImage(bitmap);
                g.CompositingMode = CompositingMode.SourceCopy;
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, bitmap.Width, bitmap.Height);

                // Set the center of the bitmap to 0,0, and scale to mm (each pixel is 0.01 mm).
                g.TranslateTransform(width / 2.0F, height / 2.0F);
                g.ScaleTransform(width / patternWidth, height / patternHeight);

                // Draw the pattern into the bitmap.
                GraphicsTarget grTarget = new GraphicsTarget(g);
                patternGlyph.Draw(grTarget, new PointF(0F, 0F), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts);

                if (offsetRows) {
                    patternGlyph.Draw(grTarget, new PointF(patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts);
                    patternGlyph.Draw(grTarget, new PointF(-patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts);
                }

                // Create a TextureBrush on the bitmap.
                TextureBrush brush = new TextureBrush(bitmap);

                // Scale and the texture brush.
                brush.RotateTransform(patternAngle);
                brush.ScaleTransform(patternWidth / width, patternHeight / height);
                brush.TranslateTransform(-width / 2.0F, -height / 2.0F);

                // Dispose of the graphics.
                g.Dispose();

                // Add it to the collection of brushes.
                patternBrushes.Add(color, brush);
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:68,代码来源:SymDef.cs

示例3: DrawGraph

        /// <summary>
        /// Draws a graph of friends into a Bitmap
        /// </summary>
        /// <param name="graph">Friend connection graf</param>
        /// <param name="srcDir">Where to take user profile picture thumbnails from</param>
        /// <param name="settings">Settings - when left blank, default settings are used</param>
        /// <param name="worker">To report the progress</param>
        /// <returns>Bitmap with the graph</returns>
        private static Bitmap DrawGraph(FriendGraph graph, string imageDir, BackgroundWorker worker = null)
        {
            Bitmap bmp = new Bitmap(GraphSettings.ImageWidth, GraphSettings.ImageHeight);
            Graphics g = Graphics.FromImage(bmp);

            g.Clear(Color.White);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // if we have the autosize option on, we find the maximum number of friends
            int maxFriends = 0;

            // we draw lines connecting friends
            int i = 0;
            List<Friend> done = new List<Friend>(); // so we dont draw lines both ways
            foreach(KeyValuePair<Friend, List<Friend>> pair in graph) {
                if(worker != null && worker.CancellationPending)
                    throw new InterruptedException();

                Pen pen = new Pen(Color.FromArgb(64, 0, 0, 0), 1);

                foreach(Friend f in pair.Value) {
                    if(!done.Contains(f))
                        g.DrawLine(pen, pair.Key.coordinates, f.coordinates);
                }

                if(pair.Value.Count > maxFriends)
                    maxFriends = pair.Value.Count;

                pen.Dispose();

                done.Add(pair.Key);

                if(worker != null)
                    worker.ReportProgress(Math.Min(99, ++i * 50 / graph.Count));
            }

            int photoSize = GraphSettings.PhotoSize;

            // if we have the autosize option on, we would like bigger pictures be on top of smaller
            // we sort them by their friend count asc
            if(GraphSettings.AutoSize) {
                done.Sort((x, y) =>
                {
                    if(graph[x].Count < graph[y].Count)
                        return -1;
                    else if(graph[y].Count < graph[x].Count)
                        return 1;

                    return 0;
                });
            }

            // we draw profile photos inside
            foreach(Friend f in done) {
                if(worker != null && worker.CancellationPending)
                    throw new InterruptedException();

                Image photo = Image.FromFile(imageDir + "/photos/" + f.id + ".jpg");

                if(GraphSettings.AutoSize) {
                    photoSize = (int) (15 + 35 * ((float) graph[f].Count / (float) maxFriends));
                }

                if(GraphSettings.PhotoShape == Shape.Circle) { // we must crop circle out of the profile picture

                    // we create brush
                    TextureBrush brush = new TextureBrush(photo, WrapMode.Clamp);

                    // resize the brush
                    brush.ScaleTransform(((float) photoSize) / 50f,
                                         ((float) photoSize) / 50f,
                                         MatrixOrder.Append);

                    // we reset the brush starting position
                    brush.TranslateTransform(f.coordinates.X - photoSize / 2,
                                             f.coordinates.Y - photoSize / 2, MatrixOrder.Append);

                    // and fill a circle with it
                    g.FillEllipse(brush,
                                  f.coordinates.X - photoSize / 2,
                                  f.coordinates.Y - photoSize / 2,
                                  photoSize,
                                  photoSize);

                    brush.Dispose();

                } else { // square - just draw the image
                    g.DrawImage(photo,
                                f.coordinates.X - photoSize / 2,
                                f.coordinates.Y - photoSize / 2,
                                photoSize,
                                photoSize);
//.........这里部分代码省略.........
开发者ID:premun,项目名称:FaceGraph,代码行数:101,代码来源:Generator.cs

示例4: CreateImageBrush

        private static Brush CreateImageBrush(Rectangle rect,
                                              Image image,
                                              PaletteImageStyle imageStyle)
        {
            // Create brush based on the provided image
            TextureBrush brush = new TextureBrush(image);

            // Create appropriate wrapping mode from image style
            switch (imageStyle)
            {
                case PaletteImageStyle.TopLeft:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left, rect.Top);
                    break;
                case PaletteImageStyle.TopMiddle:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left + (rect.Width - image.Width) / 2, rect.Top);
                    break;
                case PaletteImageStyle.TopRight:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Right - image.Width, rect.Top);
                    break;
                case PaletteImageStyle.CenterLeft:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left, rect.Top + (rect.Height - image.Height) / 2);
                    break;
                case PaletteImageStyle.CenterMiddle:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left + (rect.Width - image.Width) / 2, rect.Top + (rect.Height - image.Height) / 2);
                    break;
                case PaletteImageStyle.CenterRight:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Right - image.Width, rect.Top + (rect.Height - image.Height) / 2);
                    break;
                case PaletteImageStyle.BottomLeft:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left, rect.Bottom - image.Height);
                    break;
                case PaletteImageStyle.BottomMiddle:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left + (rect.Width - image.Width) / 2, rect.Bottom - image.Height);
                    break;
                case PaletteImageStyle.BottomRight:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Right - image.Width, rect.Bottom - image.Height);
                    break;
                case PaletteImageStyle.Stretch:
                    brush.WrapMode = WrapMode.Clamp;
                    brush.TranslateTransform(rect.Left, rect.Top);
                    brush.ScaleTransform((float)rect.Width / (float)image.Width, (float)rect.Height / (float)image.Height);
                    break;
                case PaletteImageStyle.Tile:
                    brush.WrapMode = WrapMode.Tile;
                    brush.TranslateTransform(rect.Left, rect.Top);
                    break;
                case PaletteImageStyle.TileFlipX:
                    brush.WrapMode = WrapMode.TileFlipX;
                    brush.TranslateTransform(rect.Left, rect.Top);
                    break;
                case PaletteImageStyle.TileFlipY:
                    brush.WrapMode = WrapMode.TileFlipY;
                    brush.TranslateTransform(rect.Left, rect.Top);
                    break;
                case PaletteImageStyle.TileFlipXY:
                    brush.WrapMode = WrapMode.TileFlipXY;
                    brush.TranslateTransform(rect.Left, rect.Top);
                    break;
                default:
                    // Should never happen!
                    Debug.Assert(false);
                    throw new ArgumentOutOfRangeException("imageStyle");
            }

            return brush;
        }
开发者ID:Cocotteseb,项目名称:Krypton,代码行数:75,代码来源:RenderStandard.cs

示例5: ToGdiPlus

		public static d.Brush ToGdiPlus(this ImageBrush brush, Rect bounds) {
			var img = brush.ImageSource;
			var bt = new BrushTransform(brush, bounds);
			if (bt.DegenerateBrush != null) return bt.DegenerateBrush;

			var viewbox = brush.Viewbox;
			if (brush.ViewboxUnits == BrushMappingMode.RelativeToBoundingBox)
				viewbox.Scale(img.Width, img.Height);
			var viewport = brush.Viewport;
			if (brush.ViewportUnits == BrushMappingMode.RelativeToBoundingBox)
				viewport.Transform(bt.ToAbsolute);

			var ia = new di.ImageAttributes();
			ia.SetColorMatrix(new di.ColorMatrix { Matrix33 = (float)brush.Opacity });
			var b = new d.TextureBrush(img.ToGdiPlus(), viewbox.ToGdiPlus(), ia);
			b.WrapMode = brush.TileMode.ToGdiPlus();

			b.TranslateTransform((float)viewport.X, (float)viewport.Y);
			b.ScaleTransform((float)(viewport.Width/viewbox.Width), (float)(viewport.Height/viewbox.Height));
			b.MultiplyTransform(bt.ToBrush.ToGdiPlus(), d2.MatrixOrder.Append);

			return b;
		}
开发者ID:goutkannan,项目名称:ironlab,代码行数:23,代码来源:XamlToys.cs

示例6: CreateGDIBrush

		public override System.Drawing.Brush CreateGDIBrush(RectangleF rc, float dx, float dy)
		{
			RectangleF rct = new RectangleF(0, 0, _image.Width, _image.Height);
			System.Drawing.TextureBrush brush =
				new System.Drawing.TextureBrush(_image, _wrapMode, rct);

			brush.TranslateTransform(dx, dy);
			brush.ScaleTransform(24.0f/80, 24.0f/80, MatrixOrder.Append);
			return brush;
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:10,代码来源:GDI.cs

示例7: ScaleTransform_InvalidOrder

		public void ScaleTransform_InvalidOrder ()
		{
			TextureBrush t = new TextureBrush (image);
			t.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:TextureBrushTest.cs

示例8: ScaleTransform_MaxMin

		public void ScaleTransform_MaxMin ()
		{
			TextureBrush t = new TextureBrush (image);
			t.ScaleTransform (Single.MaxValue, Single.MinValue);
			float[] elements = t.Transform.Elements;
			Assert.AreEqual (Single.MaxValue, elements[0], 1e33, "matrix.0");
			Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
			Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
			Assert.AreEqual (Single.MinValue, elements[3], 1e33, "matrix.3");
			Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
			Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:TextureBrushTest.cs

示例9: ScaleTransform

		public void ScaleTransform ()
		{
			TextureBrush t = new TextureBrush (image);
			t.ScaleTransform (2, 4);
			float[] elements = t.Transform.Elements;
			Assert.AreEqual (2, elements[0], 0.1, "matrix.0");
			Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
			Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
			Assert.AreEqual (4, elements[3], 0.1, "matrix.3");
			Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
			Assert.AreEqual (0, elements[5], 0.1, "matrix.5");

			t.ScaleTransform (0.5f, 0.25f);
			Assert.IsTrue (t.Transform.IsIdentity, "Transform.IsIdentity");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:TextureBrushTest.cs

示例10: Redraw

        public void Redraw()
        {
            //float xScl = 0, yScl = 0;
            this._drawing = true;
            try
            {
                // Use a bitmap object for drawing.  This prevents the flicker.
                using (Bitmap bmp = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height))
                {
                    // Create a Graphics object to draw into the bitmap object.
                    using (Graphics gBmp = Graphics.FromImage(bmp))
                    {
                        if (_mSamp)
                        {
                            gBmp.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
                            gBmp.CompositingQuality = this._compQual;
                            gBmp.InterpolationMode = this._intrpQual;
                            gBmp.SmoothingMode = this._smthMode;
                        }
                        // Create a brush to use for drawing the control's background.
                        Brush backBrush = null; Bitmap bgImg = null;
                        {
                            // Calculate the center of the control's client area.
                            int xCen = this.ClientRectangle.Width / 2, yCen = this.ClientRectangle.Height / 2;

                            // Draw the background, effectively erasing the control.
                            // First, we need to clear the image to the proper
                            //   background color.
                            gBmp.Clear(this.BackColor);

                            // Then draw the background image, if there is one.
                            if (this.BackgroundImage != null)
                            {

                                // If the control has a background image, we need to draw
                                //   that image instead of the background color.
                                bgImg = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
                                using (Graphics gBg = Graphics.FromImage(bgImg))
                                {
                                    // Clear the bgImg with the backcolor.
                                    gBg.Clear(this.BackColor);

                                    // Get a texture brush to draw the control's
                                    //   background image onto.
                                    using (TextureBrush tBrush = new TextureBrush(this.BackgroundImage))
                                    {
                                        // Determine the image layout.
                                        switch (this.BackgroundImageLayout)
                                        {
                                            case ImageLayout.None:
                                                {
                                                    tBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                                                }
                                                break;
                                            case ImageLayout.Tile:
                                                {
                                                    tBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
                                                }
                                                break;
                                            case ImageLayout.Zoom:
                                                {
                                                    tBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                                                    Rectangle drawSize = RainstormStudios.Drawing.Imaging.ZoomImage(this.BackgroundImage, this.ClientRectangle);
                                                    tBrush.TranslateTransform(drawSize.X, drawSize.Y);
                                                    tBrush.ScaleTransform(((float)drawSize.Width) / ((float)this.BackgroundImage.Width), ((float)drawSize.Height) / ((float)this.BackgroundImage.Height));
                                                    //xScl = ((float)drawSize.Width) / ((float)this.BackgroundImage.Width);
                                                    //yScl = ((float)drawSize.Height) / ((float)this.BackgroundImage.Height);
                                                }
                                                break;
                                            case ImageLayout.Stretch:
                                                {
                                                    tBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                                                    tBrush.ScaleTransform(((float)this.ClientRectangle.Width) / ((float)this.BackgroundImage.Width), ((float)this.ClientRectangle.Height) / ((float)this.BackgroundImage.Height));
                                                    //xScl = ((float)this.ClientRectangle.Width) / ((float)this.BackgroundImage.Width);
                                                    //yScl = ((float)this.ClientRectangle.Height) / ((float)this.BackgroundImage.Height);
                                                }
                                                break;
                                            case ImageLayout.Center:
                                                {
                                                    tBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                                                    Point drawPoint = RainstormStudios.Drawing.Imaging.CenterImage(this.BackgroundImage, this.ClientRectangle);
                                                    tBrush.TranslateTransform(drawPoint.X, drawPoint.Y);
                                                }
                                                break;
                                        }
                                        if (this._bgRot != 0)
                                        {
                                            tBrush.RotateTransform(this._bgRot);

                                            // Rotation is done at the top-left corner, so to
                                            //   keep the image centered, we have to adjust
                                            //   the translation transformation.
                                            // TODO:: Will determine how to do this later.
                                        }
                                        gBg.FillRectangle(tBrush, 0, 0, bgImg.Width, bgImg.Height);
                                    }
                                }
                                backBrush = new TextureBrush(bgImg);
                                gBmp.FillRectangle(backBrush, this.ClientRectangle);
                            }
//.........这里部分代码省略.........
开发者ID:tenshino,项目名称:RainstormStudios,代码行数:101,代码来源:ctrlAnimWidgetRotator.cs

示例11: Draw

        public override void Draw(Graphics g, int time)
        {
            if (BackgroundImage == null) {
                base.Draw(g, time);
            } else {
                if (base.DrawVisible) {
                    Matrix matrix1 = base.Transform.Matrix.Clone();

                    GraphicsContainer container1 = g.BeginContainer();

                    g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                    Matrix matrix2 = base.GraphTransform.Matrix.Clone();
                    base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);

                    ClipAndMask.ClipPath.Clip(g, time, this);
                    bool flag1 = base.Visible;
                    if (!base.Visible) {
                        g.SetClip(Rectangle.Empty);
                    }
                    float single1 = this.Opacity;
                    if (this.svgAnimAttributes.ContainsKey("fill-opacity")) {
                        single1 = Math.Min(single1, (float)this.svgAnimAttributes["fill-opacity"]);
                    }

                    using (GraphicsPath path1 = (GraphicsPath)this.GPath.Clone()) {
                        path1.Transform(base.GraphTransform.Matrix);
                        if (!base.ShowBound) {
                            ImageAttributes imageAttributes = new ImageAttributes();
                            ColorMatrix cmatrix1 = new ColorMatrix();
                            cmatrix1.Matrix00 = 1f;
                            cmatrix1.Matrix11 = 1f;
                            cmatrix1.Matrix22 = 1f;
                            cmatrix1.Matrix33 = single1;//͸����
                            cmatrix1.Matrix44 = 1f;
                            //����͸����
                            imageAttributes.SetColorMatrix(cmatrix1, ColorMatrixFlag.Default, ColorAdjustType.Default);
                            TextureBrush tbush = new TextureBrush(BackgroundImage, new RectangleF(0, 0, image1.Width, image1.Height), imageAttributes);
                            tbush.WrapMode = WrapMode.Tile;
                            tbush.TranslateTransform(path1.PathPoints[0].X, path1.PathPoints[0].Y);
                            tbush.ScaleTransform(matrix2.Elements[0] / 8, matrix2.Elements[0] / 8);
                            //tbush.RotateTransform(45);
                            g.FillPath(tbush, path1);
                            ItopVector.Core.Paint.Stroke stroke1 = ItopVector.Core.Paint.Stroke.GetStroke(this);
                            this.GraphStroke.Update(this, time);
                            float penwidth = this.GraphStroke.StrokePen.Width * matrix2.Elements[0] / 6;
                            using (Pen pen1 = new Pen(this.GraphStroke.StrokeColor, penwidth)) {
                                g.DrawPath(pen1, path1);
                            }
                            //this.GraphStroke.Paint(g, this, path1, time);

                        } else {
                            g.DrawPath(new Pen(base.BoundColor), path1);
                        }
                        this.DrawConnect(g);
                    }
                    matrix1.Dispose();
                    ClipAndMask.ClipPath.DrawClip(g, time, this);
                    g.EndContainer(container1);
                    this.pretime = time;
                }
            }
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:63,代码来源:Polygon.cs


注:本文中的System.Drawing.TextureBrush.ScaleTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。