本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Scale方法的具体用法?C# Matrix.Scale怎么用?C# Matrix.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.Matrix
的用法示例。
在下文中一共展示了Matrix.Scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeBitmap
private void InitializeBitmap()
{
m_Bitmap = new Bitmap(m_PictureBox.Width, m_PictureBox.Height);
m_Graphics = Graphics.FromImage(m_Bitmap);
Matrix matrix = new Matrix();
matrix.Scale(1.0f, -1.0f);
matrix.Translate(m_OriginX, m_OriginY);
matrix.Translate(m_TranslationX, m_TranslationY);
matrix.Scale(m_ZoomFactor, m_ZoomFactor);
m_Graphics.Transform = matrix;
}
示例2: Scale
public virtual void Scale(float X, float Y)
{
Matrix tempMatrix = new Matrix();
tempMatrix.Scale(X,Y);
tempMatrix.Multiply(TransformationMatrix);
TransformationMatrix = tempMatrix;
}
示例3: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics g = e.Graphics)
{
// Создаем траекторию
GraphicsPath path = new GraphicsPath();
Rectangle rect = new Rectangle(20, 20, 150, 150);
path.AddRectangle(rect);
// Создаем градиентную кисть
PathGradientBrush pgBrush =
new PathGradientBrush(path.PathPoints);
// Уснинавливаем цвета кисти
pgBrush.CenterColor = Color.Red;
pgBrush.SurroundColors = new Color[] { Color.Blue };
// Создаем объект Matrix
Matrix X = new Matrix();
// Translate
X.Translate(30.0f, 10.0f, MatrixOrder.Append);
// Rotate
X.Rotate(10.0f, MatrixOrder.Append);
// Scale
X.Scale(1.2f, 1.0f, MatrixOrder.Append);
// Shear
X.Shear(.2f, 0.03f, MatrixOrder.Prepend);
// Применяем преобразование к траектории и кисти
path.Transform(X);
pgBrush.Transform = X;
// Выполняем визуализацию
g.FillPath(pgBrush, path);
}
}
示例4: OnPaint
public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
{
Graphics graphics = e.Graphics;
Bitmap memoryBitmap = viewPortData.MemoryBitmap;
Rectangle rect = new Rectangle(Point.Empty, memoryBitmap.Size);
graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
if (((base.parentView.RootDesigner != null) && (base.parentView.RootDesigner.Bounds.Width >= 0)) && (base.parentView.RootDesigner.Bounds.Height >= 0))
{
GraphicsContainer container = graphics.BeginContainer();
Matrix matrix = new Matrix();
matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
Point[] pts = new Point[] { viewPortData.LogicalViewPort.Location };
matrix.TransformPoints(pts);
matrix.Translate((float) (-pts[0].X + viewPortData.ShadowDepth.Width), (float) (-pts[0].Y + viewPortData.ShadowDepth.Height), MatrixOrder.Append);
graphics.Transform = matrix;
using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.parentView.RootDesigner, false)))
{
Region clip = graphics.Clip;
graphics.Clip = region;
AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
graphics.FillRectangle(Brushes.White, base.parentView.RootDesigner.Bounds);
if (ambientTheme.WorkflowWatermarkImage != null)
{
ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, base.parentView.RootDesigner.Bounds, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
}
graphics.Clip = clip;
}
graphics.EndContainer(container);
}
}
示例5: GetMatrix
static public Matrix GetMatrix (int index)
{
// not defined (-1) or first (0)
if (index <= 0)
return null;
Matrix m = new Matrix ();
switch (index) {
case 1:
// empty
break;
case 2:
m.Rotate (15);
break;
case 3:
m.RotateAt (45, new PointF (100, 100));
break;
case 4:
m.Scale (1.5f, 0.5f);
break;
case 5:
m.Shear (2.0f, 2.0f);
break;
case 6:
m.Translate (50, 50);
break;
}
return m;
}
示例6: TankPolygonPoints
/// <summary>
/// Returned points 1-4 are the left track, points 5-8 are the right track, 9-16 are the turret
/// They should be drawn individually
/// </summary>
public static PointF[] TankPolygonPoints(int offsetX, int offsetY, float rotDegrees, float size)
{
var points = new PointF[16] {
// Left track
new PointF(-1, -1),
new PointF(-1, 1),
new PointF(-0.5f, 1),
new PointF(-0.5f, -1),
// Right track
new PointF(0.5f, -1),
new PointF(1, -1),
new PointF(1, 1),
new PointF(0.5f, 1),
// Turret
new PointF(-0.5f, -0.5f),
new PointF(0.5f, -0.5f),
new PointF(-0.5f, 0.5f),
new PointF(-0.25f, 0.5f),
new PointF(-0.25f, 1.75f),
new PointF(0.25f, 1.75f),
new PointF(0.25f, 0.5f),
new PointF(0.5f, 0.5f)
};
var matrix = new Matrix();
matrix.Rotate(rotDegrees, MatrixOrder.Append);
matrix.Translate(offsetX, offsetY, MatrixOrder.Append);
matrix.Scale(size, size);
matrix.TransformPoints(points);
return points;
}
示例7: RenderPage
/// <summary>
/// Demonstrates the use of XGraphics.Transform.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
//gfx.Clear(this.properties.General.BackColor.Color);
base.RenderPage(gfx);
gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));
Matrix matrix = new Matrix();
//matrix.Scale(2f, 1.5f);
//matrix.Translate(-200, -400);
//matrix.Rotate(45);
//matrix.Translate(200, 400);
//gfx.Transform = matrix;
//gfx.TranslateTransform(50, 30);
#if true
gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
bool id = matrix.IsIdentity;
matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
//matrix.Translate(30, -50);
matrix.Rotate(15, MatrixOrder.Prepend);
//Matrix mtx = gfx.Transform.ToGdiMatrix();
//gfx.Transform = matrix;
gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));
}
示例8: Dessine
//----------------------------------------------------------
//--------------------- METHODES --------------------------
//----------------------------------------------------------
public override void Dessine(Graphics g, Point offsetPoint, float XScale, float YScale)
{
Matrix m = new Matrix();
m.Scale(XScale, YScale);
g.Transform = m;
if (this.GradientForTup.isEnabled== true)
{
LinearGradientBrush br = null;
Rectangle rectDest = new Rectangle(new Point(this.Location.X + offsetPoint.X, this.Location.Y + offsetPoint.Y), this.Size);
br = this.GradientForTup.getBrushForDrawing(rectDest,255);
g.FillRectangle(br, rectDest);
}
else
{
}
SolidBrush brBottom = new SolidBrush(Color.FromArgb(this.BottomFillAlpha, this.BottomFillColor));
g.FillRectangle(brBottom, new Rectangle(new Point(this.Location.X + offsetPoint.X, this.Location.Y + this.Size.Height / 2 + offsetPoint.Y), new Size(this.Size.Width, this.Size.Height / 2)));
/* if (this.backgroundImage != null)
{
g.DrawImage(this.backgroundImage, new Rectangle(new Point(this.location.X+offsetPoint.X,this.location.Y+offsetPoint.Y), this.size));
}
else
{
}*/
}
示例9: Draw
public override void Draw(CGRect rect)
{
Graphics g = Graphics.FromCurrentContext ();
int offset = 20;
// Scale:
var m = new Matrix(1, 2, 3, 4, 0, 1);
g.DrawString ("Original Matrix:", Font, Brushes.Black, 10, 10);
DrawMatrix (m, g, 10, 10 + offset);
g.DrawString ("Scale - Prepend:", Font, Brushes.Black, 10, 10 + 2 * offset);
m.Scale (1, 0.5f, MatrixOrder.Prepend);
DrawMatrix (m, g, 10, 10 + 3 * offset);
g.DrawString ("Scale - Append:", Font, Brushes.Black, 10, 10 + 4 * offset);
m = new Matrix (1, 2, 3, 4, 0, 1);
m.Scale (1, 0.5f, MatrixOrder.Append);
DrawMatrix (m, g, 10, 10 + 5 * offset);
// Translation:
m = new Matrix (1, 2, 3, 4, 0, 1);
g.DrawString ("Translation - Prepend:", Font, Brushes.Black, 10, 10 + 6 * offset);
m.Translate (1, 0.5f, MatrixOrder.Prepend);
DrawMatrix (m, g, 10, 10 + 7 * offset);
g.DrawString ("Translation - Append:", Font, Brushes.Black, 10, 10 + 8 * offset);
// Reset m to the original matrix:
m = new Matrix(1, 2, 3, 4, 0, 1);
m.Translate (1, 0.5f, MatrixOrder.Append);
DrawMatrix (m, g, 10, 10 + 9 * offset);
m = new Matrix (1, 2, 3, 4, 0, 1);
g.DrawString ("Rotation - Prepend:", Font, Brushes.Black, 10, 10 + 10 * offset);
m.Rotate (45, MatrixOrder.Prepend);
DrawMatrix (m, g, 10, 10 + 11 * offset);
g.DrawString ("Rotation - Append:", Font, Brushes.Black, 10, 10 + 12 * offset);
// Reset m to the original matrix:
m = new Matrix (1, 2, 3, 4, 0, 1);
m.Rotate (45, MatrixOrder.Append);
DrawMatrix (m, g, 10, 10 + 13 * offset);
// Rotation at (x = 1, y = 2):
m = new Matrix (1, 2, 3, 4, 0, 1);
g.DrawString ("Rotation At - Prepend:", Font, Brushes.Black, 10, 10 + 14 * offset);
m.RotateAt (45, new Point (1, 2), MatrixOrder.Prepend);
DrawMatrix (m, g, 10, 10 + 15 * offset);
g.DrawString ("Rotation At - Append:", Font, Brushes.Black, 10, 10 + 16 * offset);
m = new Matrix (1, 2, 3, 4, 0, 1);
m.RotateAt (45, new Point (1, 2), MatrixOrder.Append);
DrawMatrix(m, g, 10, 10 + 17 * offset);
// Shear:
m = new Matrix (1, 2, 3, 4, 0, 1);
g.DrawString ("Shear - Prepend:", Font, Brushes.Black, 10, 10 + 18 * offset);
m.Shear (1, 2, MatrixOrder.Prepend);
DrawMatrix (m, g, 10, 10 + 19 * offset);
g.DrawString ("Shear - Append:", Font, Brushes.Black, 10, 10 + 20 * offset);
// Reset m to the original matrix:
m = new Matrix (1, 2, 3, 4, 0, 1);
m.Shear (1, 2, MatrixOrder.Append);
DrawMatrix (m, g, 10, 10 + 21 * offset);
}
示例10: ScaleBitmapMatrix
public static Matrix ScaleBitmapMatrix(Matrix m)
{
System.Drawing.Drawing2D.Matrix mx =
new System.Drawing.Drawing2D.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY);
mx.Scale(1 / 20F, 1 / 20F);
float[] els = mx.Elements;
return new Matrix(els[0], els[1], els[2], els[3], els[4], els[5]);
}
示例11: full_transform
public void full_transform(float ScX, float ScY, float ShX, float ShY, float RoAngle)
{
Matrix transform_matrix = new Matrix();
transform_matrix.Scale(ScX, ScY, MatrixOrder.Append);
transform_matrix.Shear(ShX, ShY, MatrixOrder.Append);
transform_matrix.Rotate(RoAngle, MatrixOrder.Append);
Transform(transform_matrix);
}
示例12: drawGraphLine
private void drawGraphLine(Graphics graphics, PointF[] points, Pen pen, float yScale, float xScale)
{
var matrix = new Matrix();
matrix.Scale(xScale, yScale);
matrix.Translate(5, 5, MatrixOrder.Append);
matrix.TransformPoints(points);
graphics.DrawLines(pen, points);
}
示例13: CalcTransform
private void CalcTransform()
{
Matrix m = new Matrix();
m.Translate(Width / 2, Height / 2);
m.Scale((float)zoom, (float)zoom);
m.Translate(offset.X, offset.Y);
transform = m;
itransform = m.Clone();
itransform.Invert();
}
示例14: ImageEdit
public ImageEdit()
{
InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
_transform = new Matrix();
_transform.Scale(1, 1);
_scale = 1;
}
示例15: QuotePartButton
public QuotePartButton(float scaleX, float scaleY, BrushesStorage brushes, PenStorage pens, bool isLeft = true)
{
brushesStor = brushes;
pensStor = pens;
colorScheme.Add(ButtonFigureColorScheme.Normal, Color.FromArgb(255, 180, 247, 180));
colorScheme.Add(ButtonFigureColorScheme.Pressed, Color.FromArgb(255, 200, 247, 210));
colorScheme.Add(ButtonFigureColorScheme.Light, Color.FromArgb(255, 160, 195, 180));
currentBrush = brushesStor.GetBrush(colorScheme[ButtonFigureColorScheme.Normal]) as SolidBrush;
ScaleX = scaleX;
ScaleY = scaleY;
this.isLeft = isLeft;
translateMatrix = new Matrix();
string buySellIndicatorHaderText;
if (isLeft)
{
translateMatrix.Translate(paddingLeftRightProportion / 2, PaddingTopProportion);
buySellIndicatorHaderText = "Bid";
}
else
{
translateMatrix.Translate(QuotePartButtonFigure.OriginalWidth * 2 + paddingLeftRightProportion / 2, PaddingTopProportion);
translateMatrix.Scale(-1, 1);
buySellIndicatorHaderText = "Ask";
}
buySellIndicator = new BuySellIndicator
{
ScaleX = scaleX,
ScaleY = scaleY,
OriginalLocation = isLeft
?
new Point(
Convert.ToInt32(paddingLeftRightProportion),
Convert.ToInt32(PaddingTopProportion + PaddingTopBuySellIndicator))
:
new Point(
Convert.ToInt32(QuotePartButtonFigure.OriginalWidth + paddingLeftRightProportion),
Convert.ToInt32(PaddingTopProportion + PaddingTopBuySellIndicator)),
HaderText = buySellIndicatorHaderText,
Volume = null
};
arrowTrend = new ArrowTrend
{
Sx = ScaleX,
Sy = ScaleY,
Brushes = brushes,
Pens = pens,
OriginalLocation = isLeft ? new PointF(QuotePartButtonFigure.OriginalWidth - paddingLeftRightProportion - 2, PaddingTopArrow) :
new PointF(QuotePartButtonFigure.OriginalWidth * 2 - paddingLeftRightProportion - 2, PaddingTopArrow)
};
}