本文整理汇总了C#中PdfSharp.Drawing.XGraphics.MultiplyTransform方法的典型用法代码示例。如果您正苦于以下问题:C# XGraphics.MultiplyTransform方法的具体用法?C# XGraphics.MultiplyTransform怎么用?C# XGraphics.MultiplyTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XGraphics
的用法示例。
在下文中一共展示了XGraphics.MultiplyTransform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderToGraphics
private static void RenderToGraphics(Render.RenderContext ctx, int rot, float translateX, float translateY, XGraphics graphics)
{
graphics.TranslateTransform(translateX, translateY);
graphics.RotateTransform(rot * 90);
using (Maps.Rendering.RenderUtil.SaveState(graphics))
{
if (ctx.clipPath != null)
{
XMatrix m = ctx.ImageSpaceToWorldSpace;
graphics.MultiplyTransform(m);
graphics.IntersectClip(ctx.clipPath);
m.Invert();
graphics.MultiplyTransform(m);
}
ctx.graphics = graphics;
Maps.Rendering.Render.RenderTile(ctx);
}
if (ctx.border && ctx.clipPath != null)
{
using (Maps.Rendering.RenderUtil.SaveState(graphics))
{
// Render border in world space
XMatrix m = ctx.ImageSpaceToWorldSpace;
graphics.MultiplyTransform(m);
XPen pen = new XPen(ctx.styles.imageBorderColor, 0.2f);
// PdfSharp can't ExcludeClip so we take advantage of the fact that we know
// the path starts on the left edge and proceeds clockwise. We extend the
// path with a counterclockwise border around it, then use that to exclude
// the original path's region for rendering the border.
ctx.clipPath.Flatten();
RectangleF bounds = PathUtil.Bounds(ctx.clipPath);
bounds.Inflate(2 * (float)pen.Width, 2 * (float)pen.Width);
List<byte> types = new List<byte>(ctx.clipPath.Internals.GdiPath.PathTypes);
List<PointF> points = new List<PointF>(ctx.clipPath.Internals.GdiPath.PathPoints);
PointF key = points[0];
points.Add(new PointF(bounds.Left, key.Y)); types.Add(1);
points.Add(new PointF(bounds.Left, bounds.Bottom)); types.Add(1);
points.Add(new PointF(bounds.Right, bounds.Bottom)); types.Add(1);
points.Add(new PointF(bounds.Right, bounds.Top)); types.Add(1);
points.Add(new PointF(bounds.Left, bounds.Top)); types.Add(1);
points.Add(new PointF(bounds.Left, key.Y)); types.Add(1);
points.Add(new PointF(key.X, key.Y)); types.Add(1);
XGraphicsPath path = new XGraphicsPath(points.ToArray(), types.ToArray(), XFillMode.Winding);
graphics.IntersectClip(path);
graphics.DrawPath(pen, ctx.clipPath);
}
}
}
示例2: Fill
public void Fill(XGraphics graphics, RectangleF rect, Brush fillBrush)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
RectangleF bounds = TransformedBounds;
if (bounds.IntersectsWith(rect))
{
XGraphicsPath path = Path;
using (RenderUtil.SaveState(graphics))
{
XMatrix matrix = new XMatrix();
matrix.ScalePrepend(ScaleX, ScaleY);
matrix.TranslatePrepend(-OriginX, -OriginY);
graphics.MultiplyTransform(matrix);
graphics.DrawPath(fillBrush, path);
}
}
}
示例3: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
PointF[] origins = new PointF[]
{
new PointF(100, 200), new PointF(300, 200),
new PointF(100, 400), new PointF(300, 400),
new PointF(100, 600), new PointF(350, 600),
};
PointF origin;
XGraphicsContainer container;
float length = 100;
// Not transformed
origin = origins[0];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, origin);
// Translation
container = gfx.BeginContainer(new RectangleF(10, 10, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[1];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(20, -30);
DrawAxes(gfx, XPens.DarkGray, origin, length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, origin);
gfx.EndContainer(container);
// Scaling
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[2];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.ScaleTransform(1.3f, 1.5f);
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0, 0);
gfx.EndContainer(container);
// Rotation
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[3];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.RotateTransform(-45);
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
gfx.EndContainer(container);
// Skewing (or shearing)
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[4];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(1, -0.3f, -0.4f, 1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
gfx.EndContainer(container);
// Reflection
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[5];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(-1, 0, 0, -1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
gfx.EndContainer(container);
}
示例4: DrawName
public void DrawName(XGraphics graphics, RectangleF rect, MapOptions options, XFont font, XBrush textBrush, LabelStyle labelStyle)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
RectangleF bounds = TransformedBounds;
if (bounds.IntersectsWith(rect))
{
if (Name != null)
{
string str = Name;
if (labelStyle.Uppercase)
str = str.ToUpperInvariant();
PointF pos = NamePosition;// PointF( bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2 );
using (RenderUtil.SaveState(graphics))
{
XMatrix matrix = new XMatrix();
matrix.TranslatePrepend(pos.X, pos.Y);
matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
matrix.RotatePrepend(-labelStyle.Rotation); // Rotate it
graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);
XSize size = graphics.MeasureString(str, font);
graphics.TranslateTransform(-size.Width / 2, -size.Height / 2); // Center the text
RectangleF textBounds = new RectangleF(0, 0, (float)size.Width, (float)size.Height * 2); // *2 or it gets cut off at high sizes
XTextFormatter tf = new XTextFormatter(graphics);
tf.Alignment = XParagraphAlignment.Center;
tf.DrawString(str, font, textBrush, textBounds);
}
}
}
}
示例5: Draw
public void Draw(XGraphics graphics, RectangleF rect, MapOptions options, XPen pen)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
RectangleF bounds = TransformedBounds;
//graphics.DrawRectangle( new XPen(XColors.Yellow, 1), bounds.X, bounds.Y, bounds.Width, bounds.Height );
if (bounds.IntersectsWith(rect))
{
XGraphicsPath path = Path;
using (RenderUtil.SaveState(graphics))
{
XMatrix matrix = new XMatrix();
matrix.ScalePrepend(ScaleX, ScaleY);
matrix.TranslatePrepend(-OriginX, -OriginY);
graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);
graphics.DrawPath(pen, path);
}
}
}
示例6: RenderPage
public override void RenderPage(XGraphics gfx)
{
//base.RenderPage(gfx);
XPoint[] origins = new XPoint[]
{
new XPoint(100, 200), new XPoint(300, 200),
new XPoint(100, 400), new XPoint(300, 400),
new XPoint(100, 600), new XPoint(350, 600),
};
XPoint origin;
XGraphicsState state;
float length = 100;
// Not transformed
origin = origins[0];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);
// Translation
state = gfx.Save();
origin = origins[1];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(20, -30);
DrawAxes(gfx, XPens.DarkGray, origin, length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);
gfx.Restore(state);
// Translation
state = gfx.Save();
origin = origins[2];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(20, -30);
DrawAxes(gfx, XPens.DarkGray, origin, length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);
gfx.Restore(state);
//// Scaling
//state = gfx.Save();
//origin = origins[2];
//DrawAxes(gfx, XPens.Black, origin, length);
//gfx.TranslateTransform(origin.X, origin.Y);
//gfx.ScaleTransform(1.3, 1.5);
//DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
//gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
//gfx.Restore(state);
// Rotation
state = gfx.Save();
origin = origins[3];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.RotateTransform(-45);
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0 , 0);
gfx.Restore(state);
// Skewing (or shearing)
state = gfx.Save();
origin = origins[4];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(1, -0.3f, -0.4f, 1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0 , 0);
gfx.Restore(state);
// Reflection
state = gfx.Save();
origin = origins[5];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(-1, 0, 0, -1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0 , 0);
gfx.Restore(state);
}
示例7: Render
public void Render(XGraphics graphics)
{
this.graphics = graphics;
solidBrush = new XSolidBrush();
pen = new XPen(XColor.Empty);
List<Timer> timers = new List<Timer>();
using (var fonts = new FontCache(styles))
{
#region resources
lock (s_imageInitLock)
{
if (styles.showNebulaBackground && s_nebulaImage == null)
s_nebulaImage = XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Nebula.png"));
if (styles.showRiftOverlay && s_riftImage == null)
s_riftImage = new ImageHolder(Image.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Rifts.png")));
if (styles.showGalaxyBackground && s_galaxyImage == null) {
// TODO: Don't load both unless necessary
s_galaxyImage = new ImageHolder(Image.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Galaxy.png")));
s_galaxyImageGray = new ImageHolder(Image.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Galaxy_Gray.png")));
}
if (styles.useWorldImages && s_worldImages == null)
{
s_worldImages = new Dictionary<string, XImage> {
{ "Hyd0", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd0.png")) },
{ "Hyd1", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd1.png")) },
{ "Hyd2", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd2.png")) },
{ "Hyd3", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd3.png")) },
{ "Hyd4", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd4.png")) },
{ "Hyd5", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd5.png")) },
{ "Hyd6", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd6.png")) },
{ "Hyd7", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd7.png")) },
{ "Hyd8", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd8.png")) },
{ "Hyd9", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Hyd9.png")) },
{ "HydA", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/HydA.png")) },
{ "Belt", XImage.FromFile(resourceManager.Server.MapPath(@"~/res/Candy/Belt.png")) }
};
}
if (Silly && s_sillyImageColor == null)
{
// Happy face c/o http://bighappyfaces.com/
s_sillyImageColor = XImage.FromFile(resourceManager.Server.MapPath(@"~/res/AprilFools/Starburst.png"));
s_sillyImageGray = XImage.FromFile(resourceManager.Server.MapPath(@"~/res/AprilFools/Starburst_Gray.png"));
}
}
#endregion
timers.Add(new Timer("preload"));
//////////////////////////////////////////////////////////////
//
// Image-Space Rendering
//
//////////////////////////////////////////////////////////////
using (RenderUtil.SaveState(graphics))
{
if (ClipPath != null)
{
graphics.MultiplyTransform(imageSpaceToWorldSpace);
graphics.IntersectClip(ClipPath);
graphics.MultiplyTransform(worldSpaceToImageSpace);
}
// Fill
graphics.SmoothingMode = XSmoothingMode.HighSpeed;
solidBrush.Color = styles.backgroundColor;
graphics.DrawRectangle(solidBrush, 0, 0, tileSize.Width, tileSize.Height);
}
timers.Add(new Timer("imagespace"));
//////////////////////////////////////////////////////////////
//
// World-Space Rendering
//
//////////////////////////////////////////////////////////////
graphics.MultiplyTransform(imageSpaceToWorldSpace);
using (RenderUtil.SaveState(graphics))
{
//------------------------------------------------------------
// Explicit Clipping
//------------------------------------------------------------
if (ClipPath != null)
graphics.IntersectClip(ClipPath);
//------------------------------------------------------------
// Background
//------------------------------------------------------------
timers.Add(new Timer("prep"));
#region nebula-background
//.........这里部分代码省略.........
示例8: DrawLabel
public static void DrawLabel(XGraphics g, string text, PointF labelPos, XFont font, XBrush brush, LabelStyle labelStyle)
{
using (RenderUtil.SaveState(g))
{
XTextFormatter tf = new XTextFormatter(g);
tf.Alignment = XParagraphAlignment.Center;
XMatrix matrix = new XMatrix();
matrix.TranslatePrepend(labelPos.X, labelPos.Y);
matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
if (labelStyle.Uppercase)
text = text.ToUpper();
if (labelStyle.Wrap)
text = text.Replace(' ', '\n');
matrix.TranslatePrepend(labelStyle.Translation.X, labelStyle.Translation.Y);
matrix.RotatePrepend(labelStyle.Rotation);
matrix.ScalePrepend(labelStyle.Scale.Width, labelStyle.Scale.Height);
g.MultiplyTransform(matrix, XMatrixOrder.Prepend);
XSize size = g.MeasureString(text, font);
size.Width *= 2; // prevent cut-off e.g. when rotated
XRect bounds = new XRect(-size.Width / 2, -size.Height / 2, size.Width, size.Height);
tf.DrawString(text, font, brush, bounds);
}
}