本文整理汇总了C#中MatterHackers.Agg.Graphics2D.SetTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics2D.SetTransform方法的具体用法?C# Graphics2D.SetTransform怎么用?C# Graphics2D.SetTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatterHackers.Agg.Graphics2D
的用法示例。
在下文中一共展示了Graphics2D.SetTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
graphics2D.PushTransform();
int numLines = Text.Split('\n').Length - 1;
if(Text.Contains("\r"))
{
throw new Exception("These should have be converted to \n.");
}
double yOffsetForText = Printer.TypeFaceStyle.EmSizeInPixels * numLines;
double xOffsetForText = 0;
switch (printer.Justification)
{
case Justification.Left:
break;
case Justification.Center:
xOffsetForText = (Width - Printer.LocalBounds.Width) / 2;
break;
case Justification.Right:
xOffsetForText = Width - Printer.LocalBounds.Width;
break;
default:
throw new NotImplementedException();
}
graphics2D.SetTransform(graphics2D.GetTransform() * Affine.NewTranslation(xOffsetForText, yOffsetForText));
RGBA_Bytes currentColor = this.textColor;
if (EllipsisIfClipped && Printer.LocalBounds.Width > LocalBounds.Width) // only do this if it's static text
{
TypeFacePrinter shortTextPrinter = Printer;
while (shortTextPrinter.LocalBounds.Width > LocalBounds.Width && shortTextPrinter.Text.Length > 4)
{
shortTextPrinter = new TypeFacePrinter(shortTextPrinter.Text.Substring(0, shortTextPrinter.Text.Length - 4).TrimEnd(spaceTrim) + "...", Printer);
}
shortTextPrinter.Render(graphics2D, currentColor);
}
else
{
// it all fits or it's editable (if editable it will need to be offset/scrolled sometimes).
Printer.Render(graphics2D, currentColor);
}
if (debugIt)
{
graphics2D.Line(-5, 0, 5, 0, RGBA_Bytes.Blue);
graphics2D.Line(0, -5, 0, 5, RGBA_Bytes.Blue);
}
graphics2D.PopTransform();
if (debugIt)
{
graphics2D.Line(-5, 0, 5, 0, RGBA_Bytes.Red);
graphics2D.Line(0, -5, 0, 5, RGBA_Bytes.Red);
}
base.OnDraw(graphics2D);
}
示例2: DrawCard
public void DrawCard(Graphics2D DestGraphics, int CardX, int CardY)
{
double StartX = CardX * CARD_WIDTH + m_BoardX;
double StartY = CardY * CARD_HEIGHT + m_BoardY;
RectangleDouble CardBounds = new RectangleDouble(StartX + 1.5, StartY + 1.5, StartX + CARD_WIDTH - 1.5, StartY + CARD_HEIGHT - 1.5);
RoundedRect CardFiledRoundedRect = new RoundedRect(CardBounds.Left, CardBounds.Bottom, CardBounds.Right, CardBounds.Top, 5);
Stroke CardRectBounds = new Stroke(CardFiledRoundedRect);
CardRectBounds.width(1);
CCard Card = MomsGame.GetCard(CardX, CardY);
int CardValue = Card.GetValue();
int CardSuit = Card.GetSuit();
String ValueString = "Uninitialized ";
if (CardValue > (int)CCard.CARD_VALUE.VALUE_ACE)
{
DestGraphics.SetTransform(Affine.NewIdentity());
DestGraphics.Render(CardRectBounds, new RGBA_Bytes(0, 0, 0));
if (CardValue > 10)
{
switch (CardValue)
{
case 11:
ValueString = "J";
break;
case 12:
ValueString = "Q";
break;
case 13:
ValueString = "K";
break;
default:
throw new Exception();
}
}
else
{
ValueString = CardValue.ToString();
}
TextWidget stringToDraw = new TextWidget(ValueString, 10);
RectangleDouble textBounds = stringToDraw.Printer.LocalBounds;
DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 2, CardBounds.Top - 8 - textBounds.Height / 2));
DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0));
DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 4 - textBounds.Width, CardBounds.Bottom + 9 - textBounds.Height / 2));
DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0));
RGBA_Bytes SuitColor = new RGBA_Bytes(0, 0, 0);
IVertexSource suitPath = new PathStorage();
switch (CardSuit)
{
case (int)CCard.CARD_SUIT.SUIT_DIAMOND:
{
SuitColor = new RGBA_Bytes(0xFF, 0x11, 0x11);
suitPath = m_DiamondShape;
}
break;
case (int)CCard.CARD_SUIT.SUIT_CLUB:
{
SuitColor = new RGBA_Bytes(0x22, 0x22, 0x66);
suitPath = new FlattenCurves(m_ClubShape);
}
break;
case (int)CCard.CARD_SUIT.SUIT_HEART:
{
SuitColor = new RGBA_Bytes(0xBB, 0x00, 0x00);
suitPath = new FlattenCurves(m_HeartShape);
}
break;
case (int)CCard.CARD_SUIT.SUIT_SPADE:
{
SuitColor = new RGBA_Bytes(0x00, 0x00, 0x00);
suitPath = new FlattenCurves(m_SpadeShape);
}
break;
default:
break;
}
textBounds = stringToDraw.Printer.LocalBounds;
if (CardValue < 11)
{
for (int CurDot = 0; CurDot < CardValue; CurDot++)
{
double OffsetX = 0, OffsetY = 0;
GetSuitOffset(ref OffsetX, ref OffsetY, CurDot, (int)CardValue);
DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + OffsetX, CardBounds.Bottom + OffsetY));
DestGraphics.Render(suitPath, SuitColor);
}
}
else
//.........这里部分代码省略.........