有数条首尾相连的线,即是一笔画成的线,有些是直线,有些是曲线(贝塞尔),第一条
线的起点与最后一条的结尾相合。即组成了一个闭合的路径。
现在要:  1。如何知道某个坐标点是落于图形内,图形边界上还是边界外?
  2。如何快速填充本图形(不能用边界扩散型的算法)。
  3。如谁有贝塞尔曲线的资料及算法也要。还有:不要用API的Region类函数。这个问题要在51五天中要摆平的,不过现在都还没头绪,以前的数学也大多
忘了,现在看数学和图形学也可能来不及,请高手帮忙啊!!!

解决方案 »

  1.   

    判断一点是否在区域中
    procedure TForm1.Button1Click(Sender: TObject);
    var
      bm : TBitmap;
    begin
      bm := TBitmap.Create;
      bm.Monochrome := true;
      bm.Height := 100;
      bm.Width := 100;
      bm.Canvas.Brush.Color := clWhite;
      bm.Canvas.FillRect(Rect(0, 0, 100, 100));
      bm.Canvas.Brush.Color := clBlack;
      bm.Canvas.Pen.Color := clBlack;
      bm.Canvas.Ellipse(10, 10, 90, 90);
      if bm.Canvas.Pixels[20, 20] = clBlack then
        ShowMessage('Point : (20, 20) is in region') else
        ShowMessage('Point : (20, 20) is not in region');
      if bm.Canvas.Pixels[50, 50] = clBlack then
        ShowMessage('Point : (50, 50) is in region') else
        ShowMessage('Point : (50, 50) is not in region');
      bm.Free;
    end;
      

  2.   

    在Delph下调用PolyBezier()画贝塞尔曲线;
    procedure TForm1.Button1Click(Sender: TObject);
    var point:array[0..6] of Tpoint;
        h:HDC;
    begin
    h:=getdc(form1.handle);
    point[0].x:=25; point[0].y:=25;
    point[1].x:=35; point[1].y:=170;
    point[2].x:=130;point[2].y:=120;
    point[3].x:=150;point[3].y:=150;
    point[4].x:=170;point[4].y:=280;
    point[5].x:=250;point[5].y:=115;
    point[6].x:=250;point[6].y:=225;
    polybezier(h,point,7);
    end;PolyBezier 画一系列相连的曲线,每一段包含4个point,第一点是曲线起点,
    第二点,第三点指定曲线形状的控制点,第四点是曲线终点。
    本例中,1为起点,4为中点,7为终点,2,3,5,6为控制点。
    OR 调用canvas.polybezier();
      

  3.   

    贝塞尔曲线由两个固定点和两个控制点来完成的,算法如下:x(t) = (1 - t)3 * x0 + 3t (1 - t)2 * x1 + 3t2 (1 - t) * x2 + t3 * x3 y(t) = (1 - t)3 * y0 + 3t (1 - t)2 * y1 + 3t2 (1 - t) * y2 + t3 * y3 
    1。这里(1 - t)3;(1 - t)2 ;t2;t3;都是表示次方的意思,也就是2或3是在右上角的。 
    2。The begin point is (x0, y0)
    3。the end point is (x3, y3).
    4。The two control points are (x1, y1) and (x2, y2).