本文整理汇总了C#中IGraphics.FillPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.FillPolygon方法的具体用法?C# IGraphics.FillPolygon怎么用?C# IGraphics.FillPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.FillPolygon方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(int size, int x, int y, IGraphics g, Pen pen, Brush brush)
{
int s2 = size/2;
Point[] points = new[]{new Point(x - s2, y), new Point(x, y - s2), new Point(x + s2, y), new Point(x, y + s2)};
g.FillPolygon(brush, points);
g.DrawPolygon(pen, points);
}
示例2: Draw
public override void Draw(int size, float x, float y, IGraphics g, Pen2 pen, Brush2 brush)
{
int s2 = size/2;
Point2[] points = {new Point2(x - s2, y), new Point2(x, y - s2), new Point2(x + s2, y), new Point2(x, y + s2)};
g.FillPolygon(brush, points);
g.DrawPolygon(pen, points);
}
示例3: OnRenderInternal
/// <summary>
/// Method that does the actual rendering of geometries
/// </summary>
/// <param name="map">The map</param>
/// <param name="polygon">The feature</param>
/// <param name="g">The graphics object</param>
protected override void OnRenderInternal(Map map, IPolygon polygon, IGraphics g)
{
// convert points
var pts = /*LimitValues(*/polygon.TransformToImage(map)/*)*/;
// clip
if (UseClipping)
pts = RendererHelper.ClipPolygon(pts, map.Size.Width, map.Size.Height);
// fill the polygon
if (Fill != null)
g.FillPolygon(Fill, pts);
// outline the polygon
if (Outline != null)
g.DrawPolygon(Outline, pts);
}
示例4: Render
//.........这里部分代码省略.........
ig.DrawClosedCurve(new Pen(Color.Green, 3), ccurvy, 1f, FillMode.Alternate);
ig.DrawClosedCurve(new Pen(Color.Purple, 1), ccurvy, 0f, FillMode.Alternate);
Point[] fcc = new Point[]
{
new Point(160, 350),
new Point(190, 370),
new Point(130, 390),
new Point(190, 400),
new Point(195, 410),
new Point(100, 430),
new Point(160, 450)
};
ig.FillClosedCurve(new SolidBrush(Color.Red), fcc, FillMode.Winding, 1f);
ig.FillClosedCurve(new SolidBrush(Color.Aquamarine), fcc, FillMode.Alternate, .2f);
}
else if (s == "Transparency")
{
Point[] fillpoly = new Point[]
{
new Point(20, 130),
new Point(60, 90),
new Point(30, 20),
new Point(80, 20),
new Point(15, 90),
new Point(100, 50),
new Point(0, 50)
};
Color col = Color.FromArgb(96,255,0,0);
ig.FillEllipse(new SolidBrush(Color.Ivory), 60, 140, 60, 30);
ig.FillPolygon(new SolidBrush(Color.Ivory), fillpoly, FillMode.Winding);
ig.TranslateTransform(10,10);
ig.FillEllipse(new SolidBrush(col), 60, 140, 60, 30);
ig.FillPolygon(new SolidBrush(col), fillpoly, FillMode.Alternate);
ig.ResetTransform();
ig.FillPie(new SolidBrush(Color.FromArgb(100,255,0,0)), 10, 200, 200, 80, 315, 90);
ig.FillPie(new SolidBrush(Color.FromArgb(100,128,128,0)), 10, 200, 200, 80, 250, -90);
ig.FillPie(new SolidBrush(Color.FromArgb(100,128,0,128)), 15, 205, 190, 70, 180, 270);
ig.FillPie(new SolidBrush(Color.FromArgb(100,200,60,60)), 20, 210, 180, 60, 45, -270);
}
else if (s == "Fills")
{
LinearGradientBrush gbr1 = new LinearGradientBrush(new Point(0,0), new Point(30,20), Color.Blue, Color.Plum);
ColorBlend blend = new ColorBlend(3);
blend.Colors = new Color[] {Color.Red, Color.Yellow, Color.MediumSlateBlue};
blend.Positions = new float[] {0, .3f, 1f};
gbr1.InterpolationColors = blend;
Point[] sp = new Point[]
{
new Point(145, 145),
new Point(305, 250),
new Point(220, 250),
new Point(180, 250)
};
ig.FillPolygon(gbr1, sp);
LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0,0), new Point(10,20), Color.WhiteSmoke, Color.CornflowerBlue);
示例5: DrawStartCap
protected override void DrawStartCap(IGraphics g, bool onScreen, Style style)
{
linePen.Color = style.RelationshipColor;
linePen.Width = style.RelationshipWidth;
if (association.IsAggregation)
{
g.FillPolygon(Brushes.White, diamondPoints);
g.DrawPolygon(linePen, diamondPoints);
}
else if (association.IsComposition)
{
lineBrush.Color = style.RelationshipColor;
g.FillPolygon(lineBrush, diamondPoints);
g.DrawPolygon(linePen, diamondPoints);
}
}
示例6: DrawBorder
/// <summary>
/// Draw simple border.
/// </summary>
/// <param name="border">Desired border</param>
/// <param name="g">the device to draw to</param>
/// <param name="box">Box which the border corresponds</param>
/// <param name="brush">the brush to use</param>
/// <param name="rectangle">the bounding rectangle to draw in</param>
/// <returns>Beveled border path, null if there is no rounded corners</returns>
public static void DrawBorder(Border border, IGraphics g, CssBox box, Brush brush, RectangleF rectangle)
{
SetInOutsetRectanglePoints(border, box, rectangle, true, true);
g.FillPolygon(brush, _borderPts);
}
示例7: Render
public void Render(IGraphics g, OpenGLTextureReference tex)
{
g.SetColor (Colors.White);
var x = tex.X + tex.ShapeOffset.X;
var y = tex.Y + tex.ShapeOffset.Y;
switch (ShapeType) {
case OpenGLShapeType.Line:
g.DrawLine (x, y, x + A, y + B, C);
break;
case OpenGLShapeType.Rect:
if (Fill) {
g.FillRect (x, y, A, B);
}
else {
g.DrawRect (x, y, A, B, C);
}
break;
case OpenGLShapeType.RoundedRect:
if (Fill) {
g.FillRoundedRect (x, y, A, B, C);
}
else {
g.DrawRoundedRect (x, y, A, B, C, D);
}
break;
case OpenGLShapeType.Oval:
if (Fill) {
g.FillOval (x, y, A, B);
}
else {
g.DrawOval (x, y, A, B, C);
}
break;
case OpenGLShapeType.Character:
g.SetFont (Font);
g.DrawString (Char.ToString (), x, y);
break;
case OpenGLShapeType.Polygon: {
var dx = x - Poly.Points[0].X;
var dy = y - Poly.Points[0].Y;
var dpoly = new Polygon ();
for (var i = 0; i < Poly.Points.Count; i++) {
dpoly.AddPoint (Poly.Points[i].X + dx, Poly.Points[i].Y + dy);
}
if (Fill) {
g.FillPolygon (dpoly);
}
else {
g.DrawPolygon (dpoly, A);
}
}
break;
case OpenGLShapeType.Arc:
if (Fill) {
g.FillArc (x, y, A, B, C);
}
else {
g.DrawArc (x, y, A, B, C, D);
}
break;
case OpenGLShapeType.Polyline: {
var dx = x - PolylinePoints[0].X;
var dy = y - PolylinePoints[0].Y;
g.BeginLines (true);
for (var i = 0; i < PolylineLength - 1; i++) {
g.DrawLine (
PolylinePoints[i].X + dx,
PolylinePoints[i].Y + dy,
PolylinePoints[i + 1].X + dx,
PolylinePoints[i + 1].Y + dy,
A);
}
g.EndLines ();
}
break;
default:
throw new NotSupportedException ();
}
}
示例8: OnRender
/// <summary>
/// Function to render the actual map decoration
/// </summary>
/// <param name="g"></param>
/// <param name="map"></param>
protected override void OnRender(IGraphics 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;
}
示例9: 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
PointF pix1 = this.Location.TransformTopLeft( pane );
PointF pix2 = this.Location.TransformBottomRight( pane );
if ( pix1.X > -10000 && pix1.X < 100000 && pix1.Y > -100000 && pix1.Y < 100000 &&
pix2.X > -10000 && pix2.X < 100000 && pix2.Y > -100000 && pix2.Y < 100000 )
{
// get a scaled size for the arrowhead
float scaledSize = (float)( _size * scaleFactor );
// calculate the length and the angle of the arrow "vector"
double dy = pix2.Y - pix1.Y;
double dx = pix2.X - pix1.X;
float angle = (float)Math.Atan2( dy, dx ) * 180.0F / (float)Math.PI;
float length = (float)Math.Sqrt( dx * dx + dy * dy );
// Save the old transform matrix
Matrix transform = g.Transform;
// Move the coordinate system so it is located at the starting point
// of this arrow
g.TranslateTransform( pix1.X, pix1.Y );
// Rotate the coordinate system according to the angle of this arrow
// about the starting point
g.RotateTransform( angle );
// get a pen according to this arrow properties
using ( Pen pen = _line.GetPen( pane, scaleFactor ) )
//new Pen( _color, pane.ScaledPenWidth( _penWidth, scaleFactor ) ) )
{
//pen.DashStyle = _style;
// Only show the arrowhead if required
if ( _isArrowHead )
{
// Draw the line segment for this arrow
g.DrawLine( pen, 0, 0, length - scaledSize + 1, 0 );
// Create a polygon representing the arrowhead based on the scaled
// size
PointF[] polyPt = new PointF[4];
float hsize = scaledSize / 3.0F;
polyPt[0].X = length;
polyPt[0].Y = 0;
polyPt[1].X = length - scaledSize;
polyPt[1].Y = hsize;
polyPt[2].X = length - scaledSize;
polyPt[2].Y = -hsize;
polyPt[3] = polyPt[0];
using ( SolidBrush brush = new SolidBrush( _line._color ) )
// render the arrowhead
g.FillPolygon( brush, polyPt );
}
else
g.DrawLine( pen, 0, 0, length, 0 );
}
// Restore the transform matrix back to its original state
g.Transform = transform;
}
}