本文整理汇总了C#中IGraphics.DrawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.DrawEllipse方法的具体用法?C# IGraphics.DrawEllipse怎么用?C# IGraphics.DrawEllipse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.DrawEllipse方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(int size, float x, float y, IGraphics g, Pen2 pen, Brush2 brush)
{
int s2 = size/2;
g.FillEllipse(brush, x - s2, y - s2, size, size);
if (pen != null){
g.DrawEllipse(pen, x - s2, y - s2, size, size);
}
}
示例2: BotCircle
public static void BotCircle(IGraphics graphics, double X, double Y, bool fill)
{
if (fill)
{
var transparentGreen = new SolidBrush(Color.FromArgb(30, 0, 0xFF, 0));
graphics.FillEllipse(transparentGreen, (int)(X - 60), (int)(Y - 60), 120, 120);
}
graphics.DrawEllipse(Pens.Red, (int)(X - 50), (int)(Y - 50), 100, 100);
}
示例3: DrawStartCap
protected override void DrawStartCap(IGraphics g, bool onScreen, Style style)
{
linePen.Color = style.RelationshipColor;
linePen.Width = style.RelationshipWidth;
g.FillEllipse(Brushes.White, -Radius, 0, Diameter, Diameter);
g.DrawEllipse(linePen, -Radius, 0, Diameter, Diameter);
g.DrawLine(linePen, 0, Radius - CrossSize / 2, 0, Radius + CrossSize / 2);
g.DrawLine(linePen, -CrossSize / 2, Radius, CrossSize / 2, Radius);
}
示例4: Predict
public PointF Predict(double turns, IGraphics graphics)
{
if (History.Count < 2) return History.Last().Location;
var last = History.Last();
var previous = History[History.Count - 2];
double turnRate = Geometry.NormalizeHeading(last.Heading - previous.Heading) / (last.Turn - previous.Turn);
double velocity = (last.Velocity + previous.Velocity) / 2;
double totalTurns = last.Age + turns;
if (Math.Abs(turnRate) < .01) return last.Location;
if (this.Verbose) {
last.Observer.Out.WriteLine("");
last.Observer.Out.WriteLine("Circular predictor:");
last.Observer.Out.WriteLine("last: {0} {1} {2}", last.Location, last.Heading, last.Turn);
last.Observer.Out.WriteLine("previous: {0} {1} {2}", previous.Location, previous.Heading, previous.Turn);
last.Observer.Out.WriteLine("turnRate: {0}", turnRate);
last.Observer.Out.WriteLine("velocity: {0} totalTurns: {1}", velocity, totalTurns);
}
double timeToCompleteCircle = 360 / Math.Abs(turnRate);
double circumference = velocity * timeToCompleteCircle;
double radius = circumference / 2 / Math.PI;
PointF center = last.Location.ShiftBy(last.Heading + 90 * Math.Sign(turnRate), radius, last.Observer.GetArenaBounds());
if (graphics != null) {
float diameter = 2 * (float)radius;
graphics.DrawEllipse(Pens.MintCream, center.X - (float)radius, center.Y - (float)radius, diameter, diameter);
}
if (this.Verbose) last.Observer.Out.WriteLine("radius: {0} center: {1}", radius, center);
double angularVelocityRadians = velocity / radius;
double startAngleRadians = Math.Atan2(last.Location.X - center.X, last.Location.Y - center.Y);
double endAngleRadians = startAngleRadians + angularVelocityRadians * Math.Sign(turnRate) * totalTurns;
double endAngleDegrees = Geometry.RadiansToDegrees(endAngleRadians);
if (this.Verbose) last.Observer.Out.WriteLine("startAngleRadians: {0}, endAngleRadians: {1}", startAngleRadians, endAngleRadians);
var result = center.ShiftBy(endAngleDegrees, radius, last.Observer.GetArenaBounds());
if (this.Verbose) last.Observer.Out.WriteLine("center: {0}, result: {1}", center, result);
return result;
}
示例5: Draw
/// <summary>
/// Do all rendering associated with this <see cref="CurveItem"/> to the specified
/// <see cref="Graphics"/> device. This method is normally only
/// called by the Draw method of the parent <see cref="CurveList"/>
/// collection object.
/// </summary>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="GraphPane"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="pos">The ordinal position of the current <see cref="Bar"/>
/// curve.</param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
public override void Draw(IGraphics g, GraphPane pane, int pos, float scaleFactor)
{
RectangleF rect = GetDrawingRect(pane);
g.FillEllipse(MakeBrush(), rect);
g.DrawEllipse(MakePen(), rect);
if(Image != null)
{
var left = rect.Left + rect.Width / 2.0 - Image.Width / 2.0;
var top = rect.Top + rect.Height / 2.0 - Image.Height / 2.0;
var tmpRect = new RectangleF((float)left, (float)top, Image.Width, Image.Height);
Region clip = g.Clip;
g.SetClip(tmpRect);
g.DrawImageUnscaled(Image, Rectangle.Round(tmpRect));
g.SetClip(clip, CombineMode.Replace);
}
}
示例6: OnPaint
/// <summary>
/// Paint a red circle around our PaintingRobot
/// </summary>
public override void OnPaint(IGraphics graphics)
{
var transparentGreen = new SolidBrush(Color.FromArgb(30, 0, 0xFF, 0));
graphics.FillEllipse(transparentGreen, (int) (X - 60), (int) (Y - 60), 120, 120);
graphics.DrawEllipse(Pens.Red, (int) (X - 50), (int) (Y - 50), 100, 100);
}
示例7: OnPaint
// Called in order to paint graphics for this robot.
// "Paint" button on the robot console window for this robot must be
// enabled in order to see the paintings.
public override void OnPaint(IGraphics g)
{
// Draw a red cross hair with the center at the current aim
// coordinate (x,y)
g.DrawEllipse(Pens.Red, aimX - 15, aimY - 15, 30, 30);
g.DrawLine(Pens.Red, aimX, aimY - 4, aimX, aimY + 4);
g.DrawLine(Pens.Red, aimX - 4, aimY, aimX + 4, aimY);
}
示例8: Draw
/// <summary>
/// Render this object to the specified <see cref="Graphics"/> device.
/// </summary>
/// <remarks>
/// This method is normally only called by the Draw method
/// of the parent <see cref="GraphObjList"/> collection object.
/// </remarks>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
public override void Draw( IGraphics g, PaneBase pane, float scaleFactor )
{
// Convert the arrow coordinates from the user coordinate system
// to the screen coordinate system
RectangleF pixRect = this.Location.TransformRect( pane );
if ( Math.Abs( pixRect.Left ) < 100000 &&
Math.Abs( pixRect.Top ) < 100000 &&
Math.Abs( pixRect.Right ) < 100000 &&
Math.Abs( pixRect.Bottom ) < 100000 )
{
if ( _fill.IsVisible )
using ( Brush brush = _fill.MakeBrush( pixRect ) )
g.FillEllipse( brush, pixRect );
if ( _border.IsVisible )
using ( Pen pen = _border.GetPen( pane, scaleFactor ) )
g.DrawEllipse( pen, pixRect );
}
}
示例9: Draw
public override void Draw(int size, int x, int y, IGraphics g, Pen pen, Brush brush)
{
int s2 = size/2;
g.DrawEllipse(pen, x - s2, y - s2, size, size);
}
示例10: DrawText
private void DrawText(IGraphics g, PointF[] points, int maxPoints)
{
//GraphicsPath gp = new GraphicsPath(_pathdata.Points, _pathdata.Types) { FillMode = FillMode.Winding };
//gp.Flatten();
//gp.Dispose();
//var g = _graphics;
//GraphicsContainer graphicsContainer= g.BeginContainer();
//g.TranslateTransform(_graphicsPath.GetBounds().X, _graphicsPath.GetBounds().Y);
if (ShowPath)
{
var pen = new Pen(PathColorTop);
foreach (var p in points)
g.DrawEllipse(pen, (int) p.X, (int) p.Y, 1, 1);
pen.Dispose();
}
var count = 0;
var point1 = default(PointF);
var charStep = 0;
var maxWidthText = default(double);
int i;
for (i = 0; i <= Text.Length - 1; i++)
{
maxWidthText += StringRegion(g, i) * LetterSpacePercentage / 100;
}
switch (_pathalign)
{
case TextPathAlign.Left:
point1 = points[0];
count = 0;
break;
case TextPathAlign.Center:
count = (int)((maxPoints - maxWidthText) / 2);
point1 = count > 0 ? points[count] : points[0];
break;
case TextPathAlign.Right:
count = (int)(maxPoints - maxWidthText - (double)StringRegion(g, Text.Length - 1) * LetterSpacePercentage / 100);
point1 = count > 0 ? points[count] : points[0];
break;
}
var lStrWidth = (int)(StringRegion(g, charStep) * LetterSpacePercentage / 100);
if ((count + lStrWidth / 2) < 0)
{
count = -(lStrWidth / 2);
}
while (!(charStep > Text.Length - 1))
{
lStrWidth = (int)(StringRegion(g, charStep) * LetterSpacePercentage / 100);
if ((count + lStrWidth / 2) >= 0 && (count + lStrWidth) <= maxPoints)
{
count += lStrWidth;
var point2 = points[count];
//PointF point = points[count - lStrWidth / 2];
var point = new PointF((point2.X+point1.X)/2,(point2.Y+point1.Y)/2);
var angle = GetAngle(point1, point2);
DrawRotatedText(g, Text[charStep].ToString(CultureInfo.InvariantCulture), (float)angle, point);
point1 = points[count];
}
else
{
count += lStrWidth;
}
charStep += 1;
}
}
示例11: PaintRoundButton
public static void PaintRoundButton(IGraphics g, Brush2 b, Pen2 w, int x, int y, int size, bool selected)
{
if (selected){
g.FillEllipse(Brushes2.Red, x - 1, y - 1, size + 2, size + 2);
}
g.FillEllipse(b, x, y, size, size);
g.DrawEllipse(w, x + 2, y + 2, size - 4, size - 4);
}