396 |
length+=Math.Sqrt((x2-x3)*(x2-x3) + (y2-y3) * (y2-y3)); |
length+=Math.Sqrt((x2-x3)*(x2-x3) + (y2-y3) * (y2-y3)); |
397 |
length+=Math.Sqrt((x3-x4)*(x3-x4) + (y3-y4) * (y3-y4)); |
length+=Math.Sqrt((x3-x4)*(x3-x4) + (y3-y4) * (y3-y4)); |
398 |
|
|
399 |
return (int)Math.Ceiling(length); |
return (int)Math.Ceiling(length); |
400 |
} |
} |
401 |
|
|
402 |
private Point[] ComputeBezier(int x1, int y1, int x2, int y2, |
private Point[] ComputeBezier(int x1, int y1, int x2, int y2, |
465 |
{ |
{ |
466 |
// TODO: Optimize this to plot points without |
// TODO: Optimize this to plot points without |
467 |
// involving line-drawing operations |
// involving line-drawing operations |
468 |
Point [] points = ComputeBezier(x1,y1,x2,y2,x3,y3,x4,y4); |
Point [] points = ComputeBezier(x1,y1,x2,y2,x3,y3,x4,y4); |
469 |
if (points.Length > 2) |
if (points.Length > 2) |
470 |
{ |
{ |
471 |
DrawLines(points); |
DrawLines(points); |
472 |
} |
} |
473 |
} |
} |
474 |
|
|
475 |
|
// Fill a bezier curve using the current pen. |
476 |
|
public virtual void FillBezier(int x1, int y1, int x2, int y2, |
477 |
|
int x3, int y3, int x4, int y4, FillMode fillMode ) |
478 |
|
{ |
479 |
|
// TODO: Optimize this to plot points without |
480 |
|
// involving line-drawing operations |
481 |
|
Point [] points = ComputeBezier(x1,y1,x2,y2,x3,y3,x4,y4); |
482 |
|
if (points.Length > 2) |
483 |
|
{ |
484 |
|
FillPolygon(points,fillMode); |
485 |
|
} |
486 |
|
} |
487 |
|
|
488 |
// Draw a closed cardinal curve using the current pen. |
// Draw a closed cardinal curve using the current pen. |
489 |
public virtual void DrawClosedCurve(Point[] points, float tension) |
public virtual void DrawClosedCurve(Point[] points, float tension) |
490 |
{ |
{ |