本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.AddPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.GraphicsPath.AddPolygon方法的具体用法?C# System.Drawing.Drawing2D.GraphicsPath.AddPolygon怎么用?C# System.Drawing.Drawing2D.GraphicsPath.AddPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath.AddPolygon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPolygon polygon, IAreaStyle style)
{
if (polygon == null || style == null) return;
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddPolygon(RenderUtil.CoordToPoint(polygon.Shell.Coordinates));
foreach (ILinearRing l in polygon.Holes)
gp.AddPolygon(RenderUtil.CoordToPoint(l.Coordinates));
gp.CloseFigure();
if (style.Fill != null) RenderUtil.RenderFill(engine, graphics, gp, style.Fill);
if (style.Outline != null) RenderUtil.RenderOutline(engine, graphics, gp, style.Outline);
}
示例2: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
// Cut the form
System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
myPath.AddPolygon(new Point[] { new Point(0, 0), new Point(0, this.Height), new Point(this.Width, 0) });
Region myRegion = new Region(myPath); this.Region = myRegion;
}
示例3: TestPathPointSymbolizer
public void TestPathPointSymbolizer()
{
var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
var pps =
SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue), 20);
layer.Style.PointSymbolizer = pps;
var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
map.Layers.Add(layer);
map.ZoomToExtents();
map.GetMap().Save("PathPointSymbolizer1.bmp");
pps.Rotation = -30;
map.GetMap().Save("PathPointSymbolizer2.bmp");
pps.Rotation = 0f;
pps.Offset = new System.Drawing.PointF(4, 4);
map.GetMap().Save("PathPointSymbolizer3.bmp");
var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath();
gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), });
var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath();
gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), });
pps = new
SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[]
{
new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
{
Path = gpTriangle1,
Line =
new System.Drawing.Pen(
System.Drawing.Color.Red, 2),
Fill =
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue)
},
new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
{
Path = gpTriangle2,
Line =
new System.Drawing.Pen(
System.Drawing.Color.DodgerBlue, 2),
Fill =
new System.Drawing.SolidBrush(
System.Drawing.Color.Red)
}
}){ Rotation = 45 };
layer.Style.PointSymbolizer = pps;
map.GetMap().Save("PathPointSymbolizer4.bmp");
pps.Rotation = 180;
map.GetMap().Save("PathPointSymbolizer5.bmp");
}
示例4: RangePolygon
/// <summary>
/// Constructor
/// </summary>
/// <param name="points">points of the polygon</param>
/// <param name="rType">Range Type</param>
public RangePolygon(PointF[] points, RANGETYPE rType,int id)
{
this.rangeType = rType;
this.polygonPoints = points;
if(rType == RANGETYPE.TOP)
{
fillColor=Color.FromArgb(15,0,255,0);
}
else
{
fillColor=Color.FromArgb(15,255,0,0);
}
this.polygonID = id;
graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
graphicsPath.AddPolygon(polygonPoints);
}
示例5: AnalyzeVertexGroup
/// <summary>
/// Analyzuje pole vertexů jako polygon a zjistí jeho geometrický střed (centroid), šířku a výšku
/// </summary>
/// <param name="Vertices">Pole vertexů</param>
/// <returns>Výsledek analýzy polygonu</returns>
public static GeometryDescriptor AnalyzeVertexGroup(PointF[] Vertices)
{
if (Vertices.Length <= 1)
throw new ArgumentException();
GeometryDescriptor Description = new GeometryDescriptor(Vertices);
Description.FrontalArea = PolygonArea(Vertices);
for (int i = 0,j = 0; i < Vertices.Length; i++)
{
j = (i + 1) % Vertices.Length;
Description.Centroid.X += (Vertices[i].X + Vertices[j].X) * (Vertices[i].X * Vertices[j].Y - Vertices[i].Y * Vertices[j].X);
Description.Centroid.Y += (Vertices[i].Y + Vertices[j].Y) * (Vertices[i].X * Vertices[j].Y - Vertices[i].Y * Vertices[j].X);
}
Description.ConvexHull = ConvexHull.GetConvexHull(Vertices);
Description.Centroid.X /= (float)(Description.FrontalArea * 6);
Description.Centroid.Y /= (float)(Description.FrontalArea * 6);
using (System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath())
{
p.AddPolygon(Vertices);
RectangleF r = p.GetBounds();
Description.Width = r.Width;
Description.Height = r.Height;
}
return Description;
}
示例6: DrawPolygon
/// <summary>
/// Renders a polygon to the map.
/// </summary>
/// <param name="g">Graphics reference</param>
/// <param name="pol">Polygon to render</param>
/// <param name="brush">Brush used for filling (null or transparent for no filling)</param>
/// <param name="pen">Outline pen style (null if no outline)</param>
/// <param name="clip">Specifies whether polygon clipping should be applied</param>
/// <param name="map">Map reference</param>
public static void DrawPolygon(System.Drawing.Graphics g, SharpMap.Geometries.Polygon pol, System.Drawing.Brush brush, System.Drawing.Pen pen, bool clip, SharpMap.Map map)
{
if (pol.ExteriorRing == null)
return;
if (pol.ExteriorRing.Vertices.Count > 2)
{
//Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
//Add the exterior polygon
if (!clip)
gp.AddPolygon(pol.ExteriorRing.TransformToImage(map));
else
gp.AddPolygon(clipPolygon(pol.ExteriorRing.TransformToImage(map), map.Size.Width, map.Size.Height));
//Add the interior polygons (holes)
for (int i = 0; i < pol.InteriorRings.Count; i++)
if (!clip)
gp.AddPolygon(pol.InteriorRings[i].TransformToImage(map));
else
gp.AddPolygon(clipPolygon(pol.InteriorRings[i].TransformToImage(map), map.Size.Width, map.Size.Height));
// Only render inside of polygon if the brush isn't null or isn't transparent
if (brush != null && brush != System.Drawing.Brushes.Transparent)
g.FillPath(brush, gp);
// Create an outline if a pen style is available
if (pen != null)
g.DrawPath(pen, gp);
}
}
示例7: Start
public void Start()
{
if (m_fixtures.Count == 0) return;
MainForm.ProgressStartMarquee("Sorting fixtures ....");
// Create paths out of the rivers
Dictionary<WaterConfiguration, System.Drawing.Drawing2D.GraphicsPath> riverPaths = new Dictionary<WaterConfiguration, System.Drawing.Drawing2D.GraphicsPath>();
foreach (WaterConfiguration rConf in rivers)
{
System.Drawing.Drawing2D.GraphicsPath riverPath = new System.Drawing.Drawing2D.GraphicsPath();
System.Drawing.PointF[] points = rConf.GetCoordinates().Select(c => new System.Drawing.PointF(Convert.ToSingle(c.X * zoneConfiguration.MapScale), Convert.ToSingle(c.Y * zoneConfiguration.MapScale))).ToArray();
riverPath.AddPolygon(points);
riverPaths.Add(rConf, riverPath);
}
foreach (DrawableFixture model in m_fixtures)
{
// ignote the model if there are no polygons
if(model.ProcessedPolygons.Count() == 0) continue;
// UI options
if (!DrawTrees && (model.IsTree || model.IsTreeCluster))
{
continue;
}
if (!DrawFixtures && !(model.IsTree || model.IsTreeCluster))
{
continue;
}
if (!DrawTreesAsImages && (model.IsTree || model.IsTreeCluster))
{
model.RendererConf = FixtureRendererConfigurations.GetRendererById("TreeShaded");
}
double modelCenterX = zoneConfiguration.ZoneCoordinateToMapCoordinate(model.FixtureRow.X);
double modelCenterY = zoneConfiguration.ZoneCoordinateToMapCoordinate(model.FixtureRow.Y);
// Check if on river or not
int riverHeight = 0;
foreach (KeyValuePair<WaterConfiguration, System.Drawing.Drawing2D.GraphicsPath> river in riverPaths)
{
if (river.Value.IsVisible(Convert.ToSingle(modelCenterX), Convert.ToSingle(modelCenterY)))
{
riverHeight = river.Key.Height;
break;
}
}
if (riverHeight == 0 || (riverHeight != 0 && model.FixtureRow.Z > riverHeight))
{
m_fixturesAboveWater.Add(model);
}
else
{
m_fixturesUnderWater.Add(model);
}
}
m_fixturesAboveWater = m_fixturesAboveWater.OrderBy(f => f.CanvasZ).ToList();
m_fixturesUnderWater = m_fixturesUnderWater.OrderBy(f => f.CanvasZ).ToList();
// Dispose all paths
riverPaths.Select(d => d.Value).ToList().ForEach(r => r.Dispose());
MainForm.ProgressReset();
}
示例8: UpdateNodeGraphics
/// <summary>
/// aktualisiert das Feld nodeGraphics
/// </summary>
private void UpdateNodeGraphics()
{
if ((position != null) && (inSlope != null) && (outSlope != null))
{
// Linien zu den Stützpunkten
_nodeGraphics[0] = new System.Drawing.Drawing2D.GraphicsPath(new PointF[] { inSlopeAbs, position }, new byte[] { 1, 1 });
_nodeGraphics[1] = new System.Drawing.Drawing2D.GraphicsPath(new PointF[] { outSlopeAbs, position }, new byte[] { 1, 1 });
// Stützpunkte
System.Drawing.Drawing2D.GraphicsPath inPoint = new System.Drawing.Drawing2D.GraphicsPath();
inPoint.AddEllipse(inSlopeRect);
_nodeGraphics[2] = inPoint;
System.Drawing.Drawing2D.GraphicsPath outPoint = new System.Drawing.Drawing2D.GraphicsPath();
// wir versuchen ein Dreieck zu zeichnen *lol*
Vector2 dir = outSlope.Normalized;
outPoint.AddPolygon(
new PointF[] {
(6*dir) + outSlopeAbs,
(6*dir.RotateCounterClockwise(Math.PI * 2 / 3)) + outSlopeAbs,
(6*dir.RotateCounterClockwise(Math.PI * 4 / 3)) + outSlopeAbs,
(6*dir) + outSlopeAbs
});
_nodeGraphics[3] = outPoint;
}
}
示例9: CreateGraphicsPath
/*******************************/
/// <summary>
/// Creates a GraphicsPath from two Int Arrays with a specific number of points.
/// </summary>
/// <param name="xPoints">Int Array to set the X points of the GraphicsPath</param>
/// <param name="yPoints">Int Array to set the Y points of the GraphicsPath</param>
/// <param name="pointsNumber">Number of points to add to the GraphicsPath</param>
/// <returns>A new GraphicsPath</returns>
public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(int[] xPoints, int[] yPoints, int pointsNumber)
{
System.Drawing.Drawing2D.GraphicsPath tempGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
if (pointsNumber == 2)
tempGraphicsPath.AddLine(xPoints[0], yPoints[0], xPoints[1], yPoints[1]);
else
{
System.Drawing.Point[] tempPointArray = new System.Drawing.Point[pointsNumber];
for (int index = 0; index < pointsNumber; index++)
tempPointArray[index] = new System.Drawing.Point(xPoints[index], yPoints[index]);
tempGraphicsPath.AddPolygon(tempPointArray);
}
return tempGraphicsPath;
}
示例10: intersectPolygon
//private static bool rectIntersectWithPolygon(RectangleF rect, Path path)
//{
// System.Drawing.Drawing2D.GraphicsPath temp = new System.Drawing.Drawing2D.GraphicsPath();
// temp.Reset();
// List<PointF> points = default(List<PointF>);
// foreach(object i in path.content)
// {
// if(i is Node)
// {
// Node node = (Node)i;
// if(rect.Contains((float)node.lon, (float)node.lat))
// return true;
// points.Add(new PointF((float)node.lon, (float)node.lat));
// }
// }
// temp.AddPolygon(points.ToArray());
// Region myRegion = new Region();
// myRegion.MakeEmpty();
// myRegion.Union(temp);
// PointF tempPt = new PointF();
// tempPt.X = rect.X;
// tempPt.Y = rect.Y;
// if(pointInPolygon(tempPt, myRegion))
// return true;
// tempPt.X = rect.X + rect.Width;
// tempPt.Y = rect.Y;
// if(pointInPolygon(tempPt, myRegion))
// return true;
// tempPt.X = rect.X;
// tempPt.Y = rect.Y + rect.Height;
// if(pointInPolygon(tempPt, myRegion))
// return true;
// tempPt.X = rect.X + rect.Width;
// tempPt.Y = rect.Y + rect.Height;
// if(pointInPolygon(tempPt, myRegion))
// return true;
// return false;
//}
private static bool intersectPolygon(RectangleF rect, Path path)
{
System.Drawing.Drawing2D.GraphicsPath temp = new System.Drawing.Drawing2D.GraphicsPath();
temp.Reset();
// List<PointF> points = default(List<PointF>);
List<PointF> points = new List<PointF>();
foreach (object i in path.content)
{
if (i is Node)
{
Node node = (Node)i;
if (rect.Contains((float)node.lon, (float)node.lat))
return true;
points.Add(new PointF((float)node.lon, (float)node.lat));
}
}
if (points.Count >= 3)
{
temp.AddPolygon(points.ToArray());
}
else if (points.Count == 2)
{
temp.AddLine(points[0], points[1]);
}
Region myRegion = new Region();
myRegion.MakeEmpty();
myRegion.Union(temp);
PointF tempPt = new PointF();
tempPt.X = rect.X;
tempPt.Y = rect.Y;
if (pointInPolygon(tempPt, myRegion))
return true;
tempPt.X = rect.X + rect.Width;
tempPt.Y = rect.Y;
if (pointInPolygon(tempPt, myRegion))
return true;
tempPt.X = rect.X;
tempPt.Y = rect.Y + rect.Height;
if (pointInPolygon(tempPt, myRegion))
return true;
tempPt.X = rect.X + rect.Width;
tempPt.Y = rect.Y + rect.Height;
if (pointInPolygon(tempPt, myRegion))
return true;
return false;
}
示例11: Carte_Paint
private void Carte_Paint(object sender, PaintEventArgs e)
{
int i;
double w, h;
//projet = ((Musliw.MusliW)(this.MdiParent)).projet;
Graphics page = e.Graphics;
//page.Clear(this.BackColor);
w = this.Width;
h = this.Height;
Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
this.ForeColor = Color.Black;
Brush brosse =new SolidBrush(fen.brosse_couleur);
Brush brosse_texte = new SolidBrush(fen.couleur_texte);
double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
double deltax,deltay,voldeltax,voldeltay;
double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);
//MessageBox.Show(xl.ToString() + " " + yu.ToString());
PointF p1=new PointF();
PointF p2 = new PointF();
PointF p3 = new PointF();
PointF p4 = new PointF();
PointF p5 = new PointF();
PointF[] points = new PointF[4] ;
double angle=0,norme=0;
double sinx = 0, cosx = 1;
if (fen.volume_echelle < 1e-6f)
{
fen.volume_echelle = 1e-6f;
}
for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
{
norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
{
//page.DrawRectangle(stylo, 0f, 0f, 200, 200);
//MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));
p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);
System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
epaisseur.StartFigure();
points[0] = p1;
points[1] = p2;
points[2] = p3;
points[3] = p4;
epaisseur.AddPolygon(points);
epaisseur.CloseFigure();
//page.FillPath(brosse, epaisseur);
//page.FillPolygon(brosse, points);
//page.DrawPolygon(stylo,points);
epaisseur.Reset();
texte_epaisseur.StartFigure();
p5.X = 0.5f * (p3.X + p2.X);
p5.Y = 0.5f * (p3.Y + p2.Y);
texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
RectangleF encombrement = texte_epaisseur.GetBounds();
// texte_epaisseur.AddRectangle(encombrement);
//texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);
page.FillPolygon(brosse, points);
page.DrawPolygon(stylo, points);
if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
{
System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();
if (cosx >= 0 && sinx <= 0)
{
angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
rotation.RotateAt((float)angle, p5);
rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
texte_epaisseur.Transform(rotation);
trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
//.........这里部分代码省略.........
示例12: AreaMiss
private double AreaMiss(BindableRect rect1, BindableRect rect2)
{
System.Drawing.PointF[] vertices1 = new System.Drawing.PointF[] {
rect1.BottomLeft.ToPointF(),
rect1.TopLeft.ToPointF(),
rect1.TopRight.ToPointF(),
rect1.BottomRight.ToPointF()};
var rectangle1 = new System.Drawing.Drawing2D.GraphicsPath();
rectangle1.AddPolygon(vertices1);
System.Drawing.PointF[] vertices2 = new System.Drawing.PointF[] {
rect2.BottomLeft.ToPointF(),
rect2.TopLeft.ToPointF(),
rect2.TopRight.ToPointF(),
rect2.BottomRight.ToPointF()};
var rectangle2 = new System.Drawing.Drawing2D.GraphicsPath();
rectangle2.AddPolygon(vertices2);
var region = new System.Drawing.Region(rectangle1);
region.Complement(rectangle2);
var rects = region.GetRegionScans(new System.Drawing.Drawing2D.Matrix());
float area = 0;
foreach (var rc in rects)
area += rc.Width * rc.Height;
return area;
}
示例13: Area
private double Area(BindableRect rect1)
{
System.Drawing.PointF[] vertices = new System.Drawing.PointF[] {
rect1.BottomLeft.ToPointF(),
rect1.TopLeft.ToPointF(),
rect1.TopRight.ToPointF(),
rect1.BottomRight.ToPointF()};
var rectangle = new System.Drawing.Drawing2D.GraphicsPath();
rectangle.AddPolygon(vertices);
var region = new System.Drawing.Region(rectangle);
var rects = region.GetRegionScans(new System.Drawing.Drawing2D.Matrix());
float area = 0;
foreach (var rc in rects)
area += rc.Width * rc.Height;
return area;
}
示例14: Render
public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPoint point, IPointStyle style)
{
if (point == null || style == null)
return;
if (style.Type == global::LittleSharpRenderEngine.Style.Point.PointType.Symbol)
{
return;
}
else
{
int w = style.Size.Width / 2;
int h = style.Size.Height / 2;
System.Drawing.Point[] points;
switch (style.Type)
{
case global::LittleSharpRenderEngine.Style.Point.PointType.Circle:
int pc = (int)Math.Max(8, Math.Log10(Math.Max(w, h)));
points = new System.Drawing.Point[pc + 1];
double fr = (2*Math.PI) / pc;
for (int i = 0; i < pc; i++)
points[i] = new System.Drawing.Point((int)(Math.Cos(fr * i) * w + point.X), (int)(Math.Sin(fr * i) * h + point.Y));
points[pc] = points[0];
break;
case global::LittleSharpRenderEngine.Style.Point.PointType.Square:
points = new System.Drawing.Point[]
{
new System.Drawing.Point((int)point.X - w, (int)point.Y - h),
new System.Drawing.Point((int)point.X + w, (int)point.Y - h),
new System.Drawing.Point((int)point.X + w, (int)point.Y + h),
new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
new System.Drawing.Point((int)point.X - w, (int)point.Y - h),
};
break;
case global::LittleSharpRenderEngine.Style.Point.PointType.Triangle:
points = new System.Drawing.Point[]
{
new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
new System.Drawing.Point((int)point.X, (int)point.Y - h),
new System.Drawing.Point((int)point.X + w, (int)point.Y + h),
new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
};
break;
default:
return;
}
//TODO: Apply rotation
if (style.Type != global::LittleSharpRenderEngine.Style.Point.PointType.Circle)
{
}
//Apply offset
for (int i = 0; i < points.Length; i++)
{
points[i].X += (w - style.Center.X);
points[i].Y += (h - style.Center.Y);
}
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddPolygon(points);
gp.CloseFigure();
if (style.Fill != null)
RenderUtil.RenderFill(engine, graphics, gp, style.Fill);
if (style.Outline != null)
RenderUtil.RenderOutline(engine, graphics, gp, style.Outline);
}
}
示例15: drawQuadTex
void drawQuadTex(Graphics g, Bitmap tex, PointF[] quad) {
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddPolygon(new PointF[] { quad[0], quad[1], quad[3] });
g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
g.DrawImage(tex, new PointF[] { quad[0], quad[1], quad[3] });
gp.Reset();
gp.AddPolygon(new PointF[] { quad[2], quad[3], quad[1] });
g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
g.DrawImage(tex, new PointF[] { quad[2], quad[3], quad[1] });
tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
gp.Dispose();
g.ResetClip();
}