예제 #1
0
파일: SymDef.cs 프로젝트: jonc/carto
        // Draw the pattern (at the given angle) inside the path.
        void DrawPattern(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts)
        {
            object graphicsState = g.Save();

            try {
                // Set the clipping region to draw only inside the area.
                g.SetClip(path);

                // use a transform to rotate
                Matrix matrix = GraphicsUtil.RotationMatrix(patternAngle + angle, new PointF(0, 0));
                g.Transform(matrix);

                // Get the correct bounding rect.
                RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(patternAngle + angle));

                DrawPatternRows(g, bounding, color, renderOpts);
            }
            finally {
                // restore the clip region and the transform
                g.Restore(graphicsState);
            }
        }
예제 #2
0
파일: SymDef.cs 프로젝트: jonc/carto
        // Draw the pattern using the texture brush.
        void DrawPatternWithTexBrush(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts)
        {
            Brush brush = (Brush) patternBrushes[color];
            Debug.Assert(brush != null);

            if (angle != 0.0F) {
                object graphicsState = g.Save();

                try {
                    // Set the clipping region to draw only inside the area.
                    g.SetClip(path);

                    // use a transform to rotate.
                    Matrix matrix = GraphicsUtil.RotationMatrix(angle, new PointF(0, 0));
                    g.Transform(matrix);

                    // Get the correct bounding rect.
                    RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -angle);

                    g.FillRectangle(brush, bounding);
                }
                finally {
                    // restore the clip region and the transform
                    g.Restore(graphicsState);
                }
            }
            else {
                path.Fill(g, brush);
            }
        }
예제 #3
0
파일: SymDef.cs 프로젝트: jonc/carto
        // Draw the hatching into the interior of the SymPath.
        void DrawHatching(GraphicsTarget g, SymPathWithHoles path, float angle, RenderOptions renderOpts)
        {
            object graphicsState = g.Save();

            try {
                // Set the clipping region to draw only inside the area.
                g.SetClip(path);

                // use a transform to rotate and then draw hatching.
                Matrix matrix = GraphicsUtil.RotationMatrix(hatchAngle1 + angle, new PointF(0, 0));
                g.Transform(matrix);

                // Get the correct bounding rect.
                RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(hatchAngle1 + angle));

                DrawHatchLines(g, hatchPen, hatchSpacing, bounding, renderOpts);

                // and again for the second bound of hatching
                if (hatchMode == 2) {
                    // Get the correct bounding rect.
                    bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(hatchAngle2 + angle));

                    matrix = GraphicsUtil.RotationMatrix(hatchAngle2 - hatchAngle1, new PointF(0, 0));
                    g.Transform(matrix);
                    DrawHatchLines(g, hatchPen, hatchSpacing, bounding, renderOpts);
                }
            }
            finally {
                // restore the clip region and the transform
                g.Restore(graphicsState);
            }
        }