本文整理汇总了C#中Stroke.GetBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# Stroke.GetBoundingBox方法的具体用法?C# Stroke.GetBoundingBox怎么用?C# Stroke.GetBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stroke
的用法示例。
在下文中一共展示了Stroke.GetBoundingBox方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Node
public Node(Stroke stroke)
{
this.stroke = stroke;
this.id = stroke.Id;
Rectangle r = stroke.GetBoundingBox();
//Determine whether this node is a rectangle or not
isRect = r.Width*Math.PI < StrokeManager.StrokeLength(stroke);
centerPoint = new Point(r.X + r.Width/2, r.Y + r.Height/2);
fillColor = DEFAULT;
edges = new Edges();
textColor = TEXT_DEFAULT;
text = "";
//Set initial distance to infinity (max int)
distance = Int32.MaxValue;
}
示例2: FitsCircleProperties
/* Returns true if the stroke resembles a circle given a tolerance.
* Accomplishes this by taking the perimeter of a circle that
* would be bounded in the area the stroke is bounded and
* comparing it to the length of the stroke.
*/
public static bool FitsCircleProperties(Stroke e, double tolerance)
{
if(e == null) return false;
Rectangle r = e.GetBoundingBox();
double radius = StrokeManager.Avg(r.Height,r.Width) / 2.0;
if(radius < MIN_WIDTH/2) return false;
double perimeter = 2.0*radius*Math.PI;
Point[] points = e.GetPoints();
double strokeLength = StrokeManager.StrokeLength(e);
return Math.Abs(perimeter-strokeLength) <= tolerance;
}
示例3: makeRect
/* Makes a perfectly rectangular stroke out of the
* given stroke by using its bounding area.
*/
public static Stroke makeRect(InkOverlay i, Stroke s)
{
Rectangle r = s.GetBoundingBox();
Point[] points = new Point[5];
points[0] = new Point(r.X, r.Y + r.Height);
points[1] = new Point(r.X + r.Width, points[0].Y);
points[2] = new Point(points[1].X, r.Y);
points[3] = new Point(points[0].X, points[2].Y);
points[4] = new Point(points[0].X, points[0].Y);
Stroke rectangle = s.Ink.CreateStroke(points);
rectangle.DrawingAttributes = i.DefaultDrawingAttributes;
return rectangle;
}
示例4: makeCircle
/* Makes a perfectly circular stroke given another
* stroke by using its bounding area as a reference for
* radius.
*/
public static Stroke makeCircle(InkOverlay i, Stroke s)
{
Point[] points = new Point[101];
double theta = 2*Math.PI/100.0;
Rectangle r = s.GetBoundingBox();
double radius = (r.Width + r.Height)/4.0;
int deltaX = r.X + r.Width/2;
int deltaY = r.Y + r.Height/2;
for(int k = 0; k < points.Length - 1; k++)
{
int x = (int) (radius*Math.Cos(k*theta) + deltaX);
int y = (int) (radius*Math.Sin(k*theta) + deltaY);
points[k] = new Point(x, y);
}
//Last point is the first point, i.e. it is a closed stroke
points[100] = new Point(points[0].X, points[0].Y);
Stroke circle = s.Ink.CreateStroke(points);
circle.DrawingAttributes = i.DefaultDrawingAttributes;
return circle;
}
示例5: isScratchOut
/* Determines whether the stroke coule be interpreted as a
* scratchout by checking that the length is greater than
* three times the width of its bounding box, that it has
* at least three self intersections, and its height is at
* most three quarters of its width.
*/
public static bool isScratchOut(Stroke s)
{
Rectangle rect = s.GetBoundingBox();
double length = StrokeManager.StrokeLength(s);
return length > 3*rect.Width && rect.Height <= rect.Width*3/4 && s.SelfIntersections.Length > 2 ;
}
示例6: HitNodeTest
/* Checks if the given stroke is within the bounds of a
* Node. It accomplishes this by using the stroke hit test.
*/
public static Node HitNodeTest(Stroke s, Graph g)
{
Rectangle rectS = s.GetBoundingBox();
Point sCenter = new Point(rectS.X + rectS.Width/2, rectS.Y + rectS.Height/2);
for(int i=0; i<g.Nodes.Length(); i++)
{
Node n = g.Nodes[i];
Rectangle rectN =n.Stroke.GetBoundingBox();
if(s.HitTest(n.CenterPoint, (float)Math.Max(rectN.Height/2.0, rectN.Width/2.0))
||n.Stroke.HitTest(sCenter, (float)Math.Max(rectS.Height/2.0, rectS.Width/2.0)))
{
return n;
}
}
return null;
}
示例7: FitsRectProperties
/* Returns true if the stroke resembles a rectangle given a tolerance.
* Accomplishes this by taking the perimeter of a rectangle that
* would be bounded in the area the stroke is bounded and
* comparing it to the length of the stroke.
*/
public static bool FitsRectProperties(Stroke e, double tolerance)
{
if (e == null || FitsCircleProperties(e,CIRCLE_TOLERANCE)) return false;
Rectangle r = e.GetBoundingBox();
if(r.Height < MIN_WIDTH || r.Width < MIN_WIDTH) return false;
double perimeter = r.Height*2 + r.Width*2;
double strokeLength = StrokeManager.StrokeLength(e);
return Math.Abs(perimeter-strokeLength) <= tolerance;
}