本文整理汇总了C#中System.Drawing.Drawing2D.Matrix类的典型用法代码示例。如果您正苦于以下问题:C# Matrix类的具体用法?C# Matrix怎么用?C# Matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Matrix类属于System.Drawing.Drawing2D命名空间,在下文中一共展示了Matrix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Marker
// Methods
internal Marker(string prefix, string localname, string ns, SvgDocument doc)
: base(prefix, localname, ns, doc)
{
markerTransForm = new Matrix();
brush = new SolidColor(Color.Black);
stroke = new Stroke();
}
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:8,代码来源:Marker.cs
示例2: GraphicsContainer
// Constructor, which saves away all of the important information.
// We assume that the lock on the "graphics" object is held by the caller.
internal GraphicsContainer(Graphics graphics)
{
// Push this container onto the stack.
this.graphics = graphics;
next = graphics.stackTop;
graphics.stackTop = this;
// Save the graphics state information.
clip = graphics.Clip;
if(clip != null)
{
clip = clip.Clone();
}
compositingMode = graphics.CompositingMode;
compositingQuality = graphics.CompositingQuality;
interpolationMode = graphics.InterpolationMode;
pageScale = graphics.PageScale;
pageUnit = graphics.PageUnit;
pixelOffsetMode = graphics.PixelOffsetMode;
renderingOrigin = graphics.RenderingOrigin;
smoothingMode = graphics.SmoothingMode;
textContrast = graphics.TextContrast;
textRenderingHint = graphics.TextRenderingHint;
if (graphics.transform == null)
{
transform = null;
}
else
{
transform = Matrix.Clone(graphics.transform);
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:34,代码来源:GraphicsContainer.cs
示例3: GetEyeOfSightImage
private static Bitmap GetEyeOfSightImage()
{
var roestte = new Bitmap(120, 120);
//Anyone for a more sophisticated roestte?
using (var g = Graphics.FromImage(roestte))
{
var t = new Matrix(1f, 0f, 0f, 1f, 60, 60);
g.Transform = t;
var f = new Font("Arial", 20, FontStyle.Bold);
var b = new SolidBrush(Color.Black);
var p = new Pen(Color.Black, 5);
var sf = new StringFormat(StringFormat.GenericTypographic) {Alignment = StringAlignment.Center};
var rect = new RectangleF(- 45f, - 45f, 90f, 90f);
foreach (var s in Directions)
{
g.DrawString(s, f, b, 0, -55, sf);
g.DrawArc(p, rect, 290f, 50f);
g.RotateTransform(90f);
}
}
return roestte;
}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:EyeOfSight.cs
示例4: OnRender
protected override void OnRender(Graphics g, Map map)
{
// Render the rosetta
base.OnRender(g, map);
var clip = g.ClipBounds;
var oldTransform = g.Transform;
var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width*0.5f, clip.Top + Size.Height*0.5f);
g.Transform = newTransform;
var width = Size.Width;
var height = Size.Height;
var pts = new[]
{
new PointF(0f, -0.35f*height),
new PointF(0.125f*width, 0.35f*height),
new PointF(0f, 0.275f*height),
new PointF(-0.125f*width, 0.35f*height),
new PointF(0f, -0.35f*height),
};
// need to outline the needle
if (NeedleOutlineWidth>0)
{
g.DrawPolygon(new Pen(OpacityColor(NeedleOutlineColor), NeedleOutlineWidth), pts);
}
// need to outline the needle
g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts );
g.Transform = oldTransform;
}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:EyeOfSight.cs
示例5: 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;
}
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:37,代码来源:Shapes.cs
示例6: InitializeMap
public static Map InitializeMap(float angle)
{
string wmsUrl = "http://dev:8080/geoserver/ows?service=wms&version=1.1.1&request=GetCapabilities";
Map map = new Map();
WmsLayer layWms = new WmsLayer("Demis Map", wmsUrl);
layWms.AddLayer("sf:roads");
//layWms.AddLayer("Topography");
//layWms.AddLayer("Hillshading");
layWms.SetImageFormat(layWms.OutputFormats[0]);
layWms.ContinueOnError = true;
//Skip rendering the WMS Map if the server couldn't be requested (if set to false such an event would crash the app)
layWms.TimeOut = 5000; //Set timeout to 5 seconds
layWms.SRID = 4326;
map.Layers.Add(layWms);
//limit the zoom to 360 degrees width
map.MaximumZoom = 360;
map.BackColor = Color.LightBlue;
map.Zoom = 360;
map.Center = new Point(0, 0);
Matrix mat = new Matrix();
mat.RotateAt(angle, map.WorldToImage(map.Center));
map.MapTransform = mat;
map.ZoomToExtents();
return map;
}
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:33,代码来源:WmsSample.cs
示例7: Draw
public void Draw(AnimationTrack track, SpriteBatch spBatch)
{
System.Drawing.Drawing2D.Matrix worldMatrix = new System.Drawing.Drawing2D.Matrix();
worldMatrix = track.CachedMatrix;
// fetch the image out.
Microsoft.Xna.Framework.Rectangle rect;
Texture2D texture = GetTexture(track, out rect);
System.Drawing.Drawing2D.Matrix finalTransform = mViewMatrix.Clone();
finalTransform.Multiply(worldMatrix);
float[] gM = finalTransform.Elements;
Microsoft.Xna.Framework.Matrix xM = new Microsoft.Xna.Framework.Matrix();
xM.M11 = gM[0];
xM.M12 = gM[1];
xM.M21 = gM[2];
xM.M22 = gM[3];
xM.M41 = gM[4];
xM.M42 = gM[5];
xM.M33 = 1;
xM.M44 = 1;
Microsoft.Xna.Framework.Rectangle dRect = new Microsoft.Xna.Framework.Rectangle();
dRect.X = 100;
dRect.Y = 100;
dRect.Width = rect.Width;
dRect.Height = rect.Height;
spBatch.Begin(SpriteSortMode.Immediate,BlendState.AlphaBlend,SamplerState.LinearClamp,DepthStencilState.None,RasterizerState.CullCounterClockwise,null,xM);
spBatch.Draw(texture, dRect, rect, Microsoft.Xna.Framework.Color.White);
spBatch.End();
}
开发者ID:gigiwotou,项目名称:GameEdit2,代码行数:33,代码来源:Player.cs
示例8: Draw
public override void Draw(CGRect rect)
{
Graphics g = Graphics.FromCurrentContext ();
int offset = 20;
// Invert matrix:
var m = new Matrix (1, 2, 3, 4, 0, 0);
g.DrawString ("Original Matrix:", Font, Brushes.Black, 10, 10);
DrawMatrix (m, g, 10, 10 + offset);
g.DrawString ("Inverted Matrix:", Font, Brushes.Black, 10, 10 + 2 * offset);
m.Invert ();
DrawMatrix (m, g, 10, 10 + 3 * offset);
// Matrix multiplication - MatrixOrder.Append:
var m1 = new Matrix (1, 2, 3, 4, 0, 1);
var m2 = new Matrix (0, 1, 2, 1, 0, 1);
g.DrawString ("Original Matrices:", Font, Brushes.Black, 10, 10 + 4 * offset);
DrawMatrix (m1, g, 10, 10 + 5 * offset);
DrawMatrix (m2, g, 10 + 130, 10 + 5 * offset);
m1.Multiply (m2, MatrixOrder.Append);
g.DrawString ("Resultant Matrix - Append:", Font, Brushes.Black, 10, 10 + 6 * offset);
DrawMatrix (m1, g, 10, 10 + 7 * offset);
// Matrix multiplication - MatrixOrder.Prepend:
m1 = new Matrix (1, 2, 3, 4, 0, 1);
m1.Multiply (m2, MatrixOrder.Prepend);
g.DrawString ("Resultant Matrix - Prepend:", Font, Brushes.Black, 10, 10 + 8 * offset);
DrawMatrix (m1, g, 10, 10 + 9 * offset);
}
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:29,代码来源:DrawingView.cs
示例9: GetBrush
public TextureBrush GetBrush(Matrix matrix)
{
Bitmap bmp;
if (_context2D != null)
{
bmp = _context2D.GetBitmap();
}
else
{
bmp = new Bitmap(_imagePath);
}
WrapMode wm = WrapMode.Tile;
switch (_repetition)
{
case "repeat":
wm = WrapMode.Tile;
break;
case "no-repeat":
wm = WrapMode.Clamp;
break;
case "repeat-x":
wm = WrapMode.TileFlipX;
break;
case "repeat-y":
wm = WrapMode.TileFlipY;
break;
}
var brush = new TextureBrush(bmp, wm);
brush.MultiplyTransform(matrix);
return brush;
}
开发者ID:podlipensky,项目名称:sharpcanvas,代码行数:31,代码来源:CanvasPattern.cs
示例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]);
}
开发者ID:Hamsand,项目名称:Swf2XNA,代码行数:8,代码来源:Utils.cs
示例11: Draw
/// <summary>
/// Draws the picture to the graphics.
/// </summary>
/// <param name="g">The g.</param>
public void Draw(Graphics g)
{
Point drawLocation = new Point((int)(location.X - offset.X), (int)(location.Y - offset.Y));
Matrix m = new Matrix();
m.RotateAt(-angle, location);
g.Transform = m;
g.DrawImage(bitmap, new Rectangle(drawLocation.X, drawLocation.Y, bitmap.Width / this.frameCountW, bitmap.Height / this.frameCountH),
new Rectangle(this.frameW * bitmap.Width / this.frameCountW, this.frameH * bitmap.Height / this.frameCountH, bitmap.Width / this.frameCountW, bitmap.Height / this.frameCountH), GraphicsUnit.Pixel);
}
开发者ID:ajrod,项目名称:Ratatat,代码行数:13,代码来源:Picture.cs
示例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);
}
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:9,代码来源:Graph.cs
示例13: DrawMatrix
void DrawMatrix(Matrix m, Graphics g, int x, int y)
{
string str = null;
for (int i = 0; i < m.Elements.Length; i++) {
str += m.Elements[i].ToString ();
str += ", ";
}
g.DrawString (str, Font, Brushes.Black, x, y);
}
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:10,代码来源:DrawingView.cs
示例14: ModifyCTM
public ModifyCTM(
Matrix value
)
: this(value.Elements[0],
value.Elements[1],
value.Elements[2],
value.Elements[3],
value.Elements[4],
value.Elements[5])
{
}
开发者ID:josuecorrea,项目名称:DanfeSharp,代码行数:11,代码来源:ModifyCTM.cs
示例15: DrawableAffine
/// <summary>
/// Initializes a new instance of the <see cref="DrawableAffine"/> class.
/// </summary>
/// <param name="matrix">The matrix.</param>
public DrawableAffine(Matrix matrix)
{
Throw.IfNull(nameof(matrix), matrix);
ScaleX = matrix.Elements[0];
ScaleY = matrix.Elements[1];
ShearX = matrix.Elements[2];
ShearY = matrix.Elements[3];
TranslateX = matrix.Elements[4];
TranslateY = matrix.Elements[5];
}
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:DrawableAffine.cs
示例16: DrawableAffine
///<summary>
/// Creates a new DrawableAffine instance using the specified Matrix.
///</summary>
///<param name="matrix">The matrix.</param>
public DrawableAffine(Matrix matrix)
{
Throw.IfNull("matrix", matrix);
ScaleX = (double)matrix.Elements[0];
ScaleY = (double)matrix.Elements[1];
ShearX = (double)matrix.Elements[2];
ShearY = (double)matrix.Elements[3];
TranslateX = (double)matrix.Elements[4];
TranslateY = (double)matrix.Elements[5];
}
开发者ID:levesque,项目名称:Magick.NET,代码行数:15,代码来源:DrawableAffine.cs
示例17: Render
protected override void Render(RectangleF sourceBounds, Matrix transform, Graphics g)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Transform = transform;
sourceBounds.Inflate(1, 1); // allow for pen widths
g.SetClip(sourceBounds);
foreach (IPrintingAdapter printingAdapter in m_viewingContext.Control.AsAll<IPrintingAdapter>())
printingAdapter.Print(this, g);
}
开发者ID:Joxx0r,项目名称:ATF,代码行数:12,代码来源:PrintableDocument.cs
示例18: CreateImage
/// <summary>
///
/// </summary>
/// <param name="flip"></param>
/// <returns></returns>
public Image CreateImage(AlignmentType flip)
{
Image image = Source;
Bitmap flippedImage = Opetion != null && Opetion.TragetSize != null
? new Bitmap(Opetion.TragetSize.Value.Width, Opetion.TragetSize.Value.Height)
: new Bitmap(image.Width, image.Height);
using (Graphics g = Graphics.FromImage(flippedImage))
{
//Matrix transformation
Matrix m = null;
switch (flip)
{
case AlignmentType.Horizontally | AlignmentType.Vertically:
{
m = new Matrix(-1, 0, 0, -1, 0, 0);
m.Translate(flippedImage.Width, flippedImage.Height, MatrixOrder.Append);
break;
}
case AlignmentType.Horizontally:
{
m = new Matrix(-1, 0, 0, 1, 0, 0);
m.Translate(flippedImage.Width, 0, MatrixOrder.Append);
break;
}
case AlignmentType.Vertically:
{
m = new Matrix(1, 0, 0, -1, 0, 0);
m.Translate(0, flippedImage.Height, MatrixOrder.Append);
break;
}
default: throw new ImageException("Not support");
}
//Draw
g.Transform = m;
if (Opetion != null)
{
var attributes = GetOpacity(Opetion.Opacity);
g.DrawImage(image, new Rectangle(0, 0, flippedImage.Width, flippedImage.Height), 0, 0, flippedImage.Width, flippedImage.Height, GraphicsUnit.Pixel, attributes);
}
else
{
g.DrawImage(image, 0, 0);
}
//clean up
m.Dispose();
}
return flippedImage;
}
开发者ID:Dason1986,项目名称:Lib,代码行数:56,代码来源:ImageFlip.cs
示例19: Draw
public void Draw(KalikoImage image) {
var graphics = image.Graphics;
var graphicsPath = new GraphicsPath();
var stringFormat = new StringFormat {
Alignment = Alignment,
LineAlignment = VerticalAlignment
};
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
if (Font == null) {
Font = image.Font ?? new Font("Arial", 32, FontStyle.Bold, GraphicsUnit.Pixel);
}
if (TargetArea == Rectangle.Empty) {
TargetArea = new Rectangle(0, 0, image.Width, image.Height);
}
if (Point == Point.Empty) {
graphicsPath.AddString(Text, Font.FontFamily, (int)Font.Style, Font.Size, TargetArea, stringFormat);
}
else {
graphicsPath.AddString(Text, Font.FontFamily, (int)Font.Style, Font.Size, Point, stringFormat);
}
if (Rotation != 0) {
var rotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
var bounds = graphicsPath.GetBounds();
rotationTransform.RotateAt(Rotation, new PointF(bounds.X + (bounds.Width / 2f), bounds.Y + (bounds.Height / 2f)));
graphicsPath.Transform(rotationTransform);
}
if (TextShadow != null) {
DrawShadow(graphics, graphicsPath);
}
if (Outline > 0) {
var pen = new Pen(OutlineColor, Outline) {
LineJoin = LineJoin.Round
};
graphics.DrawPath(pen, graphicsPath);
}
if (TextBrush == null) {
TextBrush = new SolidBrush(TextColor);
}
graphics.FillPath(TextBrush, graphicsPath);
}
开发者ID:dwinkelman,项目名称:imagelibrary,代码行数:50,代码来源:TextField.cs
示例20: Draw
/// <summary>
/// This routine draws the animated bomb
/// using two toggling graphics paths
/// giving the effect of a spinning bomb
/// </summary>
/// <param name="g"></param>
public override void Draw(Graphics g)
{
UpdateBounds();
Matrix m = new Matrix();
m.Translate(MovingBounds.Left, MovingBounds.Top);
// g.FillRectangle(Brushes.White , MovingBounds);
if (_invert)
{
bombInTransformed = (GraphicsPath)bombIn.Clone();
bombInTransformed.Transform(m);
g.DrawPath(BombPen, bombInTransformed);
bombInTransformed.Dispose();
}
else
{
bombOutTransformed = (GraphicsPath)bombOut.Clone();
bombOutTransformed.Transform(m);
g.DrawPath(BombPen, bombOutTransformed);
bombOutTransformed.Dispose();
}
/* Matrix flipMatrix = new Matrix();
flipMatrix.Scale(-1.0f, 1.0f);
m.Translate(MovingBounds.Left, MovingBounds.Top);
if (_invert)
{
m.Scale(-1, 1); // flip around the y axis
}
// g.FillRectangle(Brushes.White , MovingBounds);
bombInTransformed = (GraphicsPath)bombIn.Clone();
bombInTransformed.Transform(m);
g.DrawPath(BombPen, bombInTransformed);
bombInTransformed.Dispose();
*/
_invert = !_invert;
// g.DrawPolygon(Pens.White, new PointF[]{new PointF(Position.X, Position.Y),
// new PointF(Position.X + width, Position.Y + seg),
// new PointF(Position.X, Position.Y + seg*2),
// new PointF(Position.X + 3, Position.Y + seg*3)});
Position.Y += TheBombInterval;
}
开发者ID:brayanrp215,项目名称:Recursos,代码行数:56,代码来源:Bomb.cs
注:本文中的System.Drawing.Drawing2D.Matrix类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论