Ejemplo n.º 1
0
        private void DrawAndTranslateARectangle(VisualRenderTarget render,
                                                VisualResourceOfSolidColorBrush originalShapeBrush,
                                                VisualResourceOfSolidColorBrush fillBrush,
                                                VisualResourceOfStrokeStyle stroke,
                                                VisualResourceOfSolidColorBrush transformedShapeBrush,
                                                VisualResourceOfTextFormat format,
                                                VisualResourceOfSolidColorBrush textBrush)
        {
            render.SetTransform();

            // 四角を作成
            var rectangle = new RectangleF(126.0f, 80.5f, 60.0f, 60.0f);

            // 変形前の四角を描画
            render.DrawRectangle(rectangle, originalShapeBrush, 1.0f, stroke);

            // 移動変形を適用
            render.SetTransform(20, 10);

            // 四角を描画
            render.FillRectangle(rectangle, fillBrush);
            render.DrawRectangle(rectangle, transformedShapeBrush, 1.0f);

            // タイトル描画
            render.SetTransform();
            render.DrawText("Translate", format, new RectangleF(126.0f, 170.5f, 110, 20), textBrush);
        }
Ejemplo n.º 2
0
        private void DrawAndRotateARectangle(VisualRenderTarget render,
                                             VisualResourceOfSolidColorBrush originalShapeBrush,
                                             VisualResourceOfSolidColorBrush fillBrush,
                                             VisualResourceOfStrokeStyle stroke,
                                             VisualResourceOfSolidColorBrush transformedShapeBrush,
                                             VisualResourceOfTextFormat format,
                                             VisualResourceOfSolidColorBrush textBrush)
        {
            render.SetTransform();

            // 四角を作成
            var rectangle = new RectangleF(438.0f, 301.5f, 60.0f, 60.0f);

            // 変形前の四角を描画
            render.DrawRectangle(rectangle, originalShapeBrush, 1.0f, stroke);

            // スケール変形を適用
            render.SetTransform(Matrix.Rotation(45.0f, new PointF(468.0f, 331.5f)));

            // 四角を描画
            render.FillRectangle(rectangle, fillBrush);
            render.DrawRectangle(rectangle, transformedShapeBrush, 1.0f);

            // タイトル描画
            render.SetTransform();
            render.DrawText("Rotate", format, new RectangleF(438.0f, 391.5f, 60, 20), textBrush);
        }
Ejemplo n.º 3
0
        private void TranslationRotation(VisualRenderTarget render,
                                         VisualResourceOfSolidColorBrush originalShapeBrush,
                                         VisualResourceOfSolidColorBrush fillBrush,
                                         VisualResourceOfStrokeStyle stroke,
                                         VisualResourceOfSolidColorBrush transformedShapeBrush,
                                         VisualResourceOfTextFormat format,
                                         VisualResourceOfSolidColorBrush textBrush)
        {
            render.SetTransform();

            // 四角を作成
            var rectangle = new RectangleF(40.0f, 40.0f, 60.0f, 60.0f);

            // 変形前の四角を描画
            render.DrawRectangle(rectangle, originalShapeBrush, 1.0f, stroke);

            // 変形を適用
            var rotation    = Matrix.Rotation(45.0f, new PointF(70.0f, 70.0f));
            var translation = Matrix.Translation(20.0f, 10.0f);

            render.SetTransform(translation * rotation);

            // 四角を描画
            render.FillRectangle(rectangle, fillBrush);
            render.DrawRectangle(rectangle, transformedShapeBrush, 1.0f);

            // タイトル描画
            render.SetTransform();
            render.DrawText("Translation then translation", format, new RectangleF(20.0f, 140.0f, 350, 170), textBrush);
        }