本文整理汇总了C#中System.Drawing.Graphics.RotateTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.RotateTransform方法的具体用法?C# Graphics.RotateTransform怎么用?C# Graphics.RotateTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.RotateTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Graphics g)
{
g.RotateTransform((float)-mRotation);
Point[] p = new Point[]{mImgSec.Location};
g.Transform.TransformPoints(p);
if(g.Transform != new System.Drawing.Drawing2D.Matrix() && p[0] == mImgSec.Location)
throw new OperationCanceledException("Ellipse.Draw: the rotation of the array affects the referenced items in that array: fix");
g.FillEllipse(new SolidBrush(this.mImgSec.MedianCol), new System.Drawing.Rectangle(p[0], new Size((int)mEllWidth, (int)mEllHeight)));
g.RotateTransform((float)mRotation);
base.Draw(g);
}
示例2: Draw
public void Draw(Graphics g)
{
float dL = length / 2.0f;
float dW = width / 2.0f;
g.TranslateTransform(x + dL, y + dW);
g.RotateTransform(angle);
g.TranslateTransform(-dL, -dW);
g.DrawRectangle(new Pen(Color.Black), 0, 0, length, width);
g.TranslateTransform(dL, dW);
g.RotateTransform(-angle);
g.TranslateTransform(-x - dL, -y - dW);
}
示例3: RenderSymbols
private void RenderSymbols( Graphics g )
{
float radius = _textureSize / 2 * 0.84f;
float centerX = _textureSize / 2;
float centerY = _textureSize / 2;
var symbols = GetSymbols();
using ( var font = new Font( "Meroitic - Hieroglyphics", _fontSize, FontStyle.Bold ) )
{
for ( int index = 0; index < _symbolCount; index++ )
{
char character = symbols[index];
float arc = 360f / _symbolCount;
float thetaDegrees = arc * index;
float thetaRadians = AsRadians( thetaDegrees );
var characterSize = MeasureCharacter( g, font, character );
var centerPoint = new PointF( centerX - characterSize.Width / 2, centerY - characterSize.Height / 2 );
float x = centerX + (float) Math.Cos( thetaRadians ) * radius;
float y = centerY + (float) Math.Sin( thetaRadians ) * radius;
g.TranslateTransform( x, y );
g.RotateTransform( thetaDegrees + 90 );
g.TranslateTransform( -x, -y );
g.TranslateTransform( -( characterSize.Width / 2 ), -( characterSize.Height / 2 ) );
g.DrawString( character.ToString(), font, _greenBrush, x, y );
g.ResetTransform();
}
}
}
示例4: Draw
public void Draw (Graphics graphics, Route route, bool atEnd)
{
if (graphics == null) return;
if (route == null) return;
GraphicsState state = graphics.Save();
float direction = 0;
PointF pos = default(PointF);
if (atEnd)
{
pos = route.GetEndPoint();
direction = ConvertDirection(route.GetEndDirection());
}
else
{
pos = route.GetStartPoint();
direction = ConvertDirection(route.GetStartDirection());
}
// In matrix math, the correct way is to put rotation BEFORE
// translation. However, the simple transformation maethods of
// GDI+ works in "Prepend" mode, which reverses the order of
// operations.
graphics.TranslateTransform(pos.X, pos.Y);
graphics.RotateTransform(direction);
Paint(graphics);
graphics.Restore(state);
}
示例5: DrawRobot
private void DrawRobot(Robot r, Graphics g)
{
var frame = (Math.Abs(r.Steps / (int)(0.02 * BPS)) + int.MaxValue / 2) % 8;
g.TranslateTransform((float)r.X, (float)r.Y);
g.RotateTransform((float)r.Angle);
g.DrawImage(RobotImage, new Rectangle(-16, -16, 32, 32), new Rectangle(0 + 32 * frame, 0, 32, 32), GraphicsUnit.Pixel);
g.RotateTransform((float)r.CannonAngle);
g.DrawImage(CannonImage, new Rectangle(-7, -7, 24, 14));
g.RotateTransform(-(float)r.CannonAngle);
g.RotateTransform(-(float)r.Angle);
//g.FillPolygon(Brushes.LightGray, new[] {
// new PointF((float)Math.Round(-15f), (float)Math.Round(-12f)),
// new PointF((float)Math.Round(15f), (float)Math.Round(-12f)),
// new PointF((float)Math.Round(15f), (float)Math.Round(-9f)),
// new PointF((float)Math.Round(-15f), (float)Math.Round(-9f)),
//});
g.FillPolygon(Brushes.Red, new[] {
new PointF((float)Math.Round(-15f), (float)Math.Round(-12f)),
new PointF((float)Math.Round(-15f + 30 * Math.Max(0, r.HP)), (float)Math.Round(-12f)),
new PointF((float)Math.Round(-15f + 30 * Math.Max(0, r.HP)), (float)Math.Round(-9f)),
new PointF((float)Math.Round(-15f), (float)Math.Round(-9f)),
});
//g.FillPolygon(Brushes.Blue, new[] {
// new PointF((float)Math.Round(-15f), (float)Math.Round(-9f)),
// new PointF((float)Math.Round(-15f + 30 * Math.Max(0, 1 - (double)r.FireCooldown / GameState.FIRE_COOLDOWN)), (float)Math.Round(-9f)),
// new PointF((float)Math.Round(-15f + 30 * Math.Max(0, 1 - (double)r.FireCooldown / GameState.FIRE_COOLDOWN)), (float)Math.Round(-7f)),
// new PointF((float)Math.Round(-15f), (float)Math.Round(-7f)),
//});
g.TranslateTransform(-(float)r.X, -(float)r.Y);
}
示例6: DrawLabel
/// <summary>
/// Renders a label to the map.
/// </summary>
/// <param name="graphics">Graphics reference</param>
/// <param name="labelPoint">Label placement</param>
/// <param name="offset">Offset of label in screen coordinates</param>
/// <param name="font">Font used for rendering</param>
/// <param name="forecolor">Font forecolor</param>
/// <param name="backcolor">Background color</param>
/// <param name="halo">Color of halo</param>
/// <param name="rotation">Text rotation in degrees</param>
/// <param name="text">Text to render</param>
/// <param name="viewport"></param>
public static void DrawLabel(Graphics graphics, Point labelPoint, Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport, StyleContext context)
{
SizeF fontSize = graphics.MeasureString(text, font.ToGdi(context)); //Calculate the size of the text
labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
if (Math.Abs(rotation) > Constants.Epsilon && !double.IsNaN(rotation))
{
graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
graphics.RotateTransform((float)rotation);
graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
graphics.FillRectangle(backcolor.ToGdi(context), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
var path = new GraphicsPath();
path.AddString(text, new FontFamily(font.FontFamily), (int)font.ToGdi(context).Style, font.ToGdi(context).Size, new System.Drawing.Point(0, 0), null);
if (halo != null)
graphics.DrawPath(halo.ToGdi(context), path);
graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
}
else
{
if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
graphics.FillRectangle(backcolor.ToGdi(context), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);
var path = new GraphicsPath();
//Arial hack
path.AddString(text, new FontFamily("Arial"), (int)font.ToGdi(context).Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
if (halo != null)
graphics.DrawPath(halo.ToGdi(context), path);
graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
}
}
示例7: OnRender
public override void OnRender(Graphics g)
{
#if !PocketPC
if(!Bearing.HasValue)
{
g.DrawImageUnscaled(Resources.shadow50, LocalPosition.X, LocalPosition.Y);
}
g.TranslateTransform(ToolTipPosition.X, ToolTipPosition.Y);
if(Bearing.HasValue)
{
g.RotateTransform(Bearing.Value - Overlay.Control.Bearing);
g.FillPolygon(Brushes.Lime, Arrow);
}
g.ResetTransform();
if(!Bearing.HasValue)
{
g.DrawImageUnscaled(Resources.bigMarkerGreen, LocalPosition.X, LocalPosition.Y);
}
#else
DrawImageUnscaled(g, Resources.shadow50, LocalPosition.X, LocalPosition.Y);
DrawImageUnscaled(g, Resources.marker, LocalPosition.X, LocalPosition.Y);
#endif
}
示例8: OnRender
public override void OnRender(Graphics g)
{
System.Drawing.Drawing2D.Matrix temp = g.Transform;
g.TranslateTransform(LocalPosition.X, LocalPosition.Y);
g.RotateTransform(-MainMap.Bearing);
try
{
g.RotateTransform(bearing);
}
catch { }
g.DrawImageUnscaled(icon, icon.Width / -2, icon.Height / -2);
g.Transform = temp;
}
示例9: onManagedDraw
public override void onManagedDraw(Graphics graphics)
{
graphics.TranslateTransform (this.CenterX, this.CenterY);
graphics.RotateTransform (90 + this.Angle / (float)Math.PI * 180);
graphics.TranslateTransform (-this.CenterX, -this.CenterY);
base.onManagedDraw (graphics);
graphics.ResetTransform ();
}
示例10: OnRender
public override void OnRender(Graphics g)
{
double width = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Width, 0)) * 1000.0);
double height = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Height, 0)) * 1000.0);
double m2pixelwidth = Overlay.Control.Width / width;
double m2pixelheight = Overlay.Control.Height / height;
Matrix temp = g.Transform;
g.TranslateTransform(LocalPosition.X + RectHeight, LocalPosition.Y + RectWidth);
g.RotateTransform(-Overlay.Control.Bearing);
base.OnRender(g);
if (RectHeight == 0 || Overlay.Control == null)
return;
// if we have drawn it, then keep that color
if (!initcolor.HasValue)
Color = Color.White;
//wprad = 300;
// undo autochange in mouse over
// if (Pen.Color == Color.Blue)
// Pen.Color = Color.White;
//GPoint loc = new GPoint((int)(LocalPosition.X - (m2pixelwidth * RectWidth * 2)), LocalPosition.Y);// MainMap.FromLatLngToLocal(wpradposition);
GPoint loc = new GPoint((int)(LocalPosition.X - (m2pixelwidth * RectWidth)), (int)(LocalPosition.Y - (m2pixelheight * RectHeight)));// MainMap.FromLatLngToLocal(wpradposition);
double direction = LandingDirection;
//mine
int x = Offset.X - (int)(Math.Abs(loc.X - (int)LocalPosition.X) / 2);
int y = Offset.Y - (int)(Math.Abs(loc.Y - (int)LocalPosition.Y) / 2);
int widtharc = (int)Math.Abs(loc.X - LocalPosition.X);
int heightarc = (int)Math.Abs(loc.Y - LocalPosition.Y);
if (widtharc > 0)
{
try
{
g.RotateTransform((int)LandingDirection);
}
catch { }
//draw circle
//g.DrawArc(Pen, new System.Drawing.Rectangle(x, y, widtharc, heightarc), 0, 360);
//g.FillPie(new SolidBrush(Color.FromArgb(25, FillColor)), x, y, widtharc, heightarc, 0, 360);
g.DrawRectangle(Pen, x, y, RectWidth * (int)m2pixelwidth, RectHeight * (int)m2pixelheight);
g.FillRectangle(new SolidBrush(Color.FromArgb(25, FillColor)), x, y, RectWidth * (int)m2pixelwidth, RectHeight * (int)m2pixelheight);
g.Transform = temp;
}
}
示例11: Draw
public override void Draw(Graphics g, GraphPane pane)
{
SizeF size;
PointF pos;
float x, y1, y2, y3;
string label;
//Draw Axis Title
if (mTitle.Visible) {
using (Brush brush = new SolidBrush(mTitle.Color)) {
if (mTitle.Orientation == Orientation.Vertical) {
g.RotateTransform(-90);
g.TranslateTransform(-mPane.ClientRectangle.Height, 0);
size = g.MeasureString(mTitle.Text, mTitle.Font);
pos = new PointF(mTitle.Padding, mRect.Left + mRect.Width / 2 - size.Height / 2);
g.DrawString(mTitle.Text, mTitle.Font, brush, pos);
g.ResetTransform();
} else {
size = g.MeasureString(mTitle.Text, mTitle.Font);
pos = new PointF(mRect.Left + (mRect.Width / 2 - size.Width / 2), mRect.Top + mTitle.Padding);
if (mLabels.Visible) pos.Y += (mLabels.Font.Height + (mLabels.Padding * 2));
g.DrawString(mTitle.Text, mTitle.Font, brush, pos);
}
}
}
//Draw Minor Gridlines and Marks
y1 = mRect.Top - mMinorMark.Size;
y2 = mRect.Top;
for (double dx = Minimum; dx <= Maximum; dx += mMinorStep) {
x = mRect.X + (float)((dx - mMinimum) * mScale);
if (mMinorMark.Visible) g.DrawLine(mMinorMark.Pen, x, y1, x, y2);
}
//Draw Major Gridlines, Marks and Labels
y1 = mRect.Top - mMajorMark.Size;
y2 = mRect.Top;
y3 = y2 + mLabels.Padding;
using (Brush b = new SolidBrush(mLabels.Color)) {
for (double dx = Minimum; dx <= Maximum; dx += mMajorStep) {
x = mRect.X + (float)((dx - mMinimum) * mScale);
if (mMajorMark.Visible) g.DrawLine(mMajorMark.Pen, x, y1, x, y2);
if (mLabels.Visible) {
label = FormatLabel(dx);
size = g.MeasureString(label, mLabels.Font);
x = x - size.Width / 2;
if (mPane.ClientRectangle.Contains(x, y3) && mPane.ClientRectangle.Contains(x + size.Width, y3 + size.Height))
g.DrawString(label, mLabels.Font, b, x, y3);
}
}
}
//Draw The Axis
g.DrawLine(mPen, mRect.Left, mRect.Top, mRect.Right, mRect.Top);
}
示例12: paint
public void paint(Graphics g)
{
int Xpos = (int)(xpos * frmKeyboard.width);
int Ypos = (int)(ypos * frmKeyboard.height);
int size = frmKeyboard.height / 10;
g.TranslateTransform(Xpos,Ypos);
g.RotateTransform((float)(angle/Math.PI*180.0f));
g.TranslateTransform(-1*Xpos,-1*Ypos);
g.FillRectangle(black, new Rectangle(Xpos-size/2,Ypos-size/2,size,size));
g.TranslateTransform(Xpos,Ypos);
g.RotateTransform(-1*(float)(angle/Math.PI*180.0f));
g.TranslateTransform(-1*Xpos,-1*Ypos);
Font font = new Font("Arial", 10.0f);
g.DrawString(fiducial_id+"",font, white, new PointF(Xpos-10,Ypos-10));
}
示例13: DrawBullet
private void DrawBullet(Bullet b, Graphics g)
{
if (b.Exploding && b.ExplosionTick > .5 * BPS) return;
var frame = (Math.Abs(b.ExplosionTick / (int)(.5 / 16 * BPS)) + int.MaxValue / 2) % 16;
g.TranslateTransform((float)b.X, (float)b.Y);
if (b.Exploding)
{
g.DrawImage(ExplosionImage, new Rectangle(-12, -12, 24, 24),
new Rectangle(0 + 24 * (frame % 4), 0 + 24 * (frame / 4), 24, 24), GraphicsUnit.Pixel);
}
else
{
g.RotateTransform((float)b.Angle);
g.DrawImage(BulletImage, new Rectangle(-2, -2, 13, 5));
g.RotateTransform(-(float)b.Angle);
}
g.TranslateTransform(-(float)b.X, -(float)b.Y);
}
示例14: Draw
public override void Draw(Graphics g, GraphPane pane)
{
SizeF size;
PointF pos;
float y, x1, x2, x3;
string label;
//Draw Axis Title
if (mTitle.Visible) {
using (Brush b = new SolidBrush(mTitle.Color)) {
if (mTitle.Orientation == Orientation.Vertical) {
g.RotateTransform(-90);
g.TranslateTransform(-mRect.Height, 0);
size = g.MeasureString(mTitle.Text, mTitle.Font);
pos = new PointF(mRect.Height / 2 - size.Width / 2, mRect.Left + mTitle.Padding);
g.DrawString(mTitle.Text, mTitle.Font, b, pos);
g.ResetTransform();
} else {
size = g.MeasureString(mTitle.Text, mTitle.Font);
pos = new PointF(mRect.Left + mTitle.Padding, mRect.Height / 2 - size.Width / 2);
g.DrawString(mTitle.Text, mTitle.Font, b, pos);
}
}
}
//Draw Minor Grid and Mark
x1 = mRect.Right + mMinorMark.Size;
x2 = x1 - mMinorMark.Size;
for (double dy = Minimum; dy < Maximum; dy += mMinorStep) {
y = mRect.Bottom - (float)((dy - mMinimum) * mScale);
if (mMinorMark.Visible) g.DrawLine(mMinorMark.Pen, x1, y, x2, y);
}
//Draw Major Gridlines, Marks and Labels
x1 = mRect.Right + mMajorMark.Size;
x2 = x1 - mMajorMark.Size;
using (Brush b = new SolidBrush(mLabels.Color)) {
for (double dy = Minimum; dy <= Maximum; dy += mMajorStep) {
y = mRect.Bottom - (float)((dy - mMinimum) * mScale);
if (mMajorMark.Visible) g.DrawLine(mMajorMark.Pen, x1, y, x2, y);
if (mLabels.Visible) {
label = dy.ToString(mLabels.Format);
size = g.MeasureString(label, mLabels.Font);
y = y - size.Height / 2;
x3 = x2 - (size.Width + mLabels.Padding);
if (mPane.ClientRectangle.Contains(x3, y) && mPane.ClientRectangle.Contains(x3, y + size.Height))
g.DrawString(label, mLabels.Font, b, x3, y);
}
}
}
//Draw The Axis
g.DrawLine(mPen, mRect.Right, mRect.Top, mRect.Right, mRect.Bottom);
}
示例15: Render
public void Render(Graphics g)
{
if (finish != null)
{
Matrix m = g.Transform;
g.TranslateTransform((float)(state.Position.X / CarModel.MM_PER_PIXEL + CarModel.OFFSET_X), (float)(state.Position.Y / CarModel.MM_PER_PIXEL + CarModel.OFFSET_Y));
g.RotateTransform((float)(state.Angle * 180 / Math.PI + 90));
g.DrawImage(finish, new Point((int)(-finish.Width / 1.5), (int)(-finish.Height / 1.5)));
g.Transform = m;
}
if ((selinside != 0) || (seloutside != 0))
{
Pen p = new Pen(Color.Black, 1);
int x = (int)(state.Position.X / CarModel.MM_PER_PIXEL + CarModel.OFFSET_X);
int y = (int)(state.Position.Y / CarModel.MM_PER_PIXEL + CarModel.OFFSET_Y);
int r = finish.Width / 2;
int x2 = (int)(state.Position.X / CarModel.MM_PER_PIXEL + CarModel.OFFSET_X);
int y2 = (int)(state.Position.Y / CarModel.MM_PER_PIXEL + CarModel.OFFSET_Y);
int r2 = finish.Width / 2 + OUT_WIDTH;
if (selinside == 1)
{
Pen p2 = new Pen(Color.FromArgb(64,255,255,255), r);
g.DrawEllipse(p2, x - r/2, y - r/2, r, r);
}
if (seloutside == 1)
{
int w = r2-r;
Pen p2 = new Pen(Color.FromArgb(64, 255, 255, 255), w);
g.DrawEllipse(p2, x2 - r2 + w / 2, y2 - r2 + w / 2, 2 * r2 - w, 2 * r2 - w);
}
g.DrawEllipse(p, x - r, y - r, 2 * r, 2 * r);
g.DrawEllipse(p, x2 - r2, y2 - r2, 2 * r2, 2 * r2);
if (selinside == 2)
{
Pen p2 = new Pen(Color.FromArgb(64, 255, 255, 255), r);
g.DrawEllipse(p2, x - r / 2, y - r / 2, r, r);
p = new Pen(Color.White, 4);
g.DrawEllipse(p, x - r, y - r, 2 * r, 2 * r);
}
if (seloutside == 2)
{
int w = r2 - r;
Pen p2 = new Pen(Color.FromArgb(64, 255, 255, 255), w);
g.DrawEllipse(p2, x2 - r2 + w / 2, y2 - r2 + w / 2, 2 * r2 - w, 2 * r2 - w);
p = new Pen(Color.White, 4);
g.DrawEllipse(p, x2 - r2, y2 - r2, 2 * r2, 2 * r2);
}
}
}