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


C# Matrix.Scale方法代码示例

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


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

示例1: WorldTransform

        //	sets up a translation matrix for the sweeper according to its
        public void WorldTransform(ref List<Point> sweeper)
        {
            //create the world transformation matrix
            var transform = new Matrix();

            //scale
            transform.Scale(Scale, Scale);

            //rotate
            transform.Rotate(Rotation);

            //and translate
            transform.Translate(Position.X, Position.Y);

            //now transform the ships vertices
            transform.TransformPoints(ref sweeper);
        }
开发者ID:Oxymoron290,项目名称:CSharp-AI-Mine-Sweepers,代码行数:18,代码来源:MineSweeper.cs

示例2: DrawGlyphs

        // Draw the glyphs along the path. "longPath" is the same as path unless shortening of the ends has occurred, in which case
        // path is the shortened path (used for all glyphs except start and end), and longPath is used for the start and end.
        private void DrawGlyphs(GraphicsTarget g, GlyphInfo glyphInfo, SymPath path, SymPath longPath, SymColor color, RenderOptions renderOpts)
        {
            float[] distances;
            PointF[] points;
            float[] perpAngles, subtendedAngles;
            float firstDistance;

            // Figure out the distances of the glyphs along the line.
            switch (glyphInfo.location) {
            case GlyphLocation.Corners:
                // Corner points are done somewhat differently. Only can have 1 symbol.
                // There is an interesting feature in OCAD where the dimensions of corner glyphs are stretched a certain amount at
                // very acute angles. This is so that power line crossbars always extend beyond the power lines themselves.
                // This is handled by stretching the glyph based on the subtended angle at the corner.
                points = path.FindCornerPoints(out perpAngles, out subtendedAngles);
                if (points != null) {
                    for (int i = 0; i < points.Length; ++i) {
                        float subtendedAngle = subtendedAngles[i];
                        float stretch;
                        if (subtendedAngle != 0)
                            stretch = Util.MiterFactor(subtendedAngle);
                        else
                            stretch = 1.0F;
                        stretch = Math.Min(stretch, CORNER_GLYPH_STRETCH_LIMIT);

                        Matrix stretchMatrix = new Matrix();
                        stretchMatrix.Scale(1.0F, stretch);

                        glyphInfo.glyph.Draw(g, points[i], perpAngles[i] + 90.0F, stretchMatrix, null, color, renderOpts);
                    }
                }
                return;

            case GlyphLocation.Spaced:
                distances = ComputeDashDistances(path, LocationKind.GapCenters, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.SpacedOffset:
                distances = ComputeDashDistances(path, LocationKind.GapCentersOffset, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, glyphInfo.offset, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.SpacedDecrease:
                distances = ComputeDashDistances(path, LocationKind.GapCentersDecrease, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, 0, 0, 0, 0, 0, glyphInfo.decreaseLimit, glyphInfo.decreaseBothEnds);

                if (distances != null && distances.Length > 0) {
                    firstDistance = distances[0];

                    for (int n = 0; n < glyphInfo.number; ++n) {
                        distances[0] = Math.Max(0.0F, firstDistance - ((glyphInfo.number - 1 - n * 2) * (glyphInfo.spacing / 2.0F)));

                        points = path.FindPointsAlongLineBizzarro(distances, out perpAngles);

                        for (int i = 0; i < points.Length; ++i) {
                            float decreaseFactor;
                            if (glyphInfo.decreaseBothEnds) {
                                if (points.Length <= 2)
                                    decreaseFactor = glyphInfo.decreaseLimit;
                                else
                                    decreaseFactor = 1.0F - (Math.Abs(i - ((points.Length-1) / 2F)) * (1 - glyphInfo.decreaseLimit) / ((points.Length-1) / 2F));
                            }
                            else {
                                if (i == 0)
                                    decreaseFactor = 1.0F;
                                else
                                    decreaseFactor = 1.0F - (i * (1 - glyphInfo.decreaseLimit) / (points.Length - 1));
                            }
                            Matrix matrixTransform = new Matrix();
                            matrixTransform.Scale(decreaseFactor, decreaseFactor);
                            glyphInfo.glyph.Draw(g, points[i], perpAngles[i], matrixTransform, null, color, renderOpts);
                        }
                    }
                }

                return;
            case GlyphLocation.DashCenters:
                distances = ComputeDashDistances(path, LocationKind.DashCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, dashInfo.minGaps, 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.MiddleDashCenters:
                distances = ComputeDashDistances(path, LocationKind.MiddleDashCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, dashInfo.minGaps, 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.GapCenters:
                // OCAD doesn't respect the "0 minimum gaps" for the symbols, although it does for the gaps. Always have at least one symbol. This is handled on import by having glyphInfo.minimum be 1.
                distances = ComputeDashDistances(path, LocationKind.GapCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, Math.Max(glyphInfo.minimum, dashInfo.minGaps), 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.Start:
                distances = new float[1] { 0 };
                break;
            case GlyphLocation.End:
                distances = new float[1] { longPath.BizzarroLength };
                break;
            default:
                Debug.Fail("bad glyph location");
                return;
            }

            if (distances == null || distances.Length == 0)
                return;
            firstDistance = distances[0];

            for (int n = 0; n < glyphInfo.number; ++n) {
//.........这里部分代码省略.........
开发者ID:jonc,项目名称:carto,代码行数:101,代码来源:SymDef.cs

示例3: ScalingMatrix

 // Create scale matrix.
 public static Matrix ScalingMatrix(float dx, float dy)
 {
     #if false
     Matrix m = Matrix.Identity;
     m.ScalePrepend(dx, dy);
     return m;
     #else
     Matrix m = new Matrix();
     m.Scale(dx, dy);
     return m;
     #endif
 }
开发者ID:jonc,项目名称:carto,代码行数:13,代码来源:GraphicsTarget.cs

示例4: BrushTransform

			internal BrushTransform(Brush brush, Rect bounds) {
				ToAbsolute = Matrix.Identity;
				ToAbsolute.Scale(bounds.Width, bounds.Height);
				ToAbsolute.Translate(bounds.X, bounds.Y);
				var fromAbsolute = ToAbsolute;
				fromAbsolute.Invert();
				ToBrush = fromAbsolute * brush.RelativeTransform.Value * ToAbsolute * brush.Transform.Value;
				if (!ToBrush.HasInverse) {
					var dv = new DrawingVisual();
					using (var dc = dv.RenderOpen()) dc.DrawRectangle(brush, null, new Rect(0, 0, 1, 1));
					var rtb = new RenderTargetBitmap(1, 1, 0, 0, PixelFormats.Pbgra32);
					rtb.Render(dv);
					var c = new byte[4];
					rtb.CopyPixels(c, 4, 0);
					DegenerateBrush = new d.SolidBrush(d.Color.FromArgb(c[3], c[2], c[1], c[0])); 
				}
			}
开发者ID:goutkannan,项目名称:ironlab,代码行数:17,代码来源:XamlToys.cs

示例5: WorldTransform

        public void WorldTransform(ref List<Point> verticalBuffer, Vector vPos)
        {
            //create the world transformation matrix
            var transform = new Matrix();
	
            //scale
            transform.Scale(Properties.Settings.Default.MinScale, Properties.Settings.Default.MinScale);
	
            //translate
            transform.Translate(vPos.X, vPos.Y);

            //transform the ships vertices
            transform.TransformPoints(ref verticalBuffer);
        }
开发者ID:Oxymoron290,项目名称:CSharp-AI-Mine-Sweepers,代码行数:14,代码来源:Controller.cs

示例6: RenderPage

    internal bool RenderPage(Graphics gfx)
    {
      //delete m_RenderContext;
      //m_RenderContext = new HdcRenderContext(wdc.m_hdc);

      gfx.TranslateTransform(-this.posOffset.X, -this.posOffset.Y);
      gfx.SetClip(new Rectangle(this.virtualPage.X + 1, this.virtualPage.Y + 1, this.virtualPage.Width - 1, this.virtualPage.Height - 1));

      float scaleX = virtualPage.Width / this.pageSize.Width;
      float scaleY = virtualPage.Height / this.pageSize.Height;

      //gfx.SetSmoothingMode(SmoothingModeAntiAlias);
      //PaintBackground(gfx);

#if DRAW_BMP
      Matrix matrix = new Matrix();
      matrix.Translate(virtualPage.X, virtualPage.Y);
      matrix.Translate(-this.posOffset.X, -this.posOffset.Y);
      //matrix.Scale(scaleX, scaleY);
      gfx.Transform = matrix;

#if DRAW_X
      gfx.DrawLine(Pens.Red, 0, 0, pageSize.Width, pageSize.Height);
      gfx.DrawLine(Pens.Red, 0, pageSize.Height, pageSize.Width, 0);
#endif
      if (this.renderEvent != null)
      {
        Bitmap bmp = new Bitmap(this.virtualPage.Width, this.virtualPage.Height, gfx);
        Graphics gfx2 = Graphics.FromImage(bmp);
        gfx2.Clear(this.pageColor);
        gfx2.ScaleTransform(scaleX, scaleY);
        gfx2.SmoothingMode = SmoothingMode.HighQuality;
        XGraphics xgfx = XGraphics.FromGraphics(gfx2, new XSize(this.pageSize.Width, this.pageSize.Height));
        try
        {
          this.renderEvent(xgfx);
          gfx.DrawImage(bmp, 0, 0);
        }
        finally
        {
          bmp.Dispose();
        }
      }
#else
      Matrix matrix = new Matrix();
      matrix.Translate(virtualPage.X, virtualPage.Y);
      matrix.Translate(-this.posOffset.X, -this.posOffset.Y);
      matrix.Scale(scaleX, scaleY);
      gfx.Transform = matrix;

#if DRAW_X
      gfx.DrawLine(Pens.Red, 0, 0, pageSize.Width, pageSize.Height);
      gfx.DrawLine(Pens.Red, 0, pageSize.Height, pageSize.Width, 0);
#endif

      if (this.renderEvent != null)
      {
        gfx.SmoothingMode = SmoothingMode.HighQuality;
        XGraphics xgfx = XGraphics.FromGraphics(gfx, new XSize(this.pageSize.Width, this.pageSize.Height));
        try
        {
          this.renderEvent(xgfx);
        }
        catch (Exception ex)
        {
          MessageBox.Show(ex.Message, "Exception");
        }
      }
#endif

      // Old C++ stuff, may be useful later...
#if false
      switch (m_mode)
      {
        case RenderModeDirect:
        {
          delete m_PreviewMetafile;
          m_PreviewMetafile = NULL;

          float cxPage = Metric::MillimetersToPoints(m_dimPage.cx / 10.0f);
          float cyPage = Metric::MillimetersToPoints(m_dimPage.cy / 10.0f);

          float scaleX = virtualPage.Width  / cxPage;
          float scaleY = virtualPage.Height / cyPage;

          Graphics gfx(m_RenderContext);
          gfx.SetSmoothingMode(SmoothingModeAntiAlias);
          PaintBackground(gfx, &virtualPage);

          Matrix matrix;
          matrix.Translate((float)virtualPage.X, (float)virtualPage.Y);
          matrix.Translate((float) - m_posOffset.x, (float) -m_posOffset.y);
          matrix.Scale(scaleX, scaleY);

          m_RenderContext->SetDefaultViewMatrix(&matrix);
          gfx.ResetTransform();
          if (m_PreviewRenderer && m_PreviewRenderer->CanRender())
            m_PreviewRenderer->Render(&gfx, m_Page);
        }
          break;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:101,代码来源:PagePreview.cs

示例7: Test

    /// <summary>
    /// Some test code to check that there are no typing errors in the formulars.
    /// </summary>
    public static void Test()
    {
      XMatrix xm1 = new XMatrix(23, -35, 837, 332, -3, 12);
      Matrix  m1 = new Matrix(23, -35, 837, 332, -3, 12);
      DumpMatrix(xm1, m1);
      XMatrix xm2 = new XMatrix(12, 235, 245, 42, 33, -56);
      Matrix  m2 = xm2.ToMatrix();
      DumpMatrix(xm2, m2);

//      xm1.Multiply(xm2, XMatrixOrder.Prepend);
//      m1.Multiply(m2, MatrixOrder.Append);
      xm1.Multiply(xm2, XMatrixOrder.Append);
      m1.Multiply(m2, MatrixOrder.Append);
      DumpMatrix(xm1, m1);

      xm1.Translate(-243, 342, XMatrixOrder.Append);
      m1.Translate(-243, 342, MatrixOrder.Append);
      DumpMatrix(xm1, m1);

      xm1.Scale(-5.66, 7.87);
      m1.Scale(-5.66f, 7.87f);
//      xm1.Scale(-5.66, 7.87, XMatrixOrder.Prepend);
//      m1.Scale(-5.66f, 7.87f, MatrixOrder.Prepend);
      DumpMatrix(xm1, m1);


      xm1.Rotate(135, XMatrixOrder.Append);
      m1.Rotate(135, MatrixOrder.Append);
      //      xm1.Scale(-5.66, 7.87, XMatrixOrder.Prepend);
      //      m1.Scale(-5.66f, 7.87f, MatrixOrder.Prepend);
      DumpMatrix(xm1, m1);

      xm1.RotateAt(177, new XPoint(-3456, 654), XMatrixOrder.Append);
      m1.RotateAt(177, new PointF(-3456, 654), MatrixOrder.Append);
      DumpMatrix(xm1, m1);

      xm1.Shear(0.76, -0.87, XMatrixOrder.Prepend);
      m1.Shear(0.76f, -0.87f, MatrixOrder.Prepend);
      DumpMatrix(xm1, m1);

      xm1 = new XMatrix(23, -35, 837, 332, -3, 12);
      m1 = new Matrix(23, -35, 837, 332, -3, 12);

      XPoint[] xpoints = new XPoint[3]{new XPoint(23, 10), new XPoint(-27, 120), new XPoint(-87, -55)};
      PointF[] points = new PointF[3]{new PointF(23, 10), new PointF(-27, 120), new PointF(-87, -55)};

      xm1.TransformPoints(xpoints);
      m1.TransformPoints(points);

      xm1.Invert();
      m1.Invert();
      DumpMatrix(xm1, m1);

    }
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:57,代码来源:XMatrix.cs


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