PolyBezier(tpoint);
如何实现鼠标任意点击四点画出Bezier曲线!~

解决方案 »

  1.   

    canvas.PolyBezier(const points:array of Tpoint)
    canvas.PolyBezier必须要求实数!~ 
    我想获得鼠标的坐标!~ 然后传到 points里 应该怎么做?想实现的功能就是,连续点四下坐标!~ 把这四点坐标全放在Points 里,然后画出曲线!~
    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
     var point:array [0..3] of Tpoint;begin
      if  z<>3 then
       begin
       point[z].X:=X;
       point[z].Y:=y;
       end else   canvas.PolyBezier(point);
    end;
    procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    z:=z+1;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    z:=0;
    end;
    这样 没有办法实现 我不知道是为什么 ?
    请大家帮我看看 !~
      

  2.   

    先点第一个点的时候先moveto到那个点!!
    即这么样!
    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
     var point:array [0..3] of Tpoint;begin
      if  z<>3 then
       begin
         point[z].X:=X;
         point[z].Y:=y;
       end 
       else
       if z=0 then
        canvas.moveto(x,y)
       else
            canvas.PolyBezier(point);
    end;
      

  3.   

    我错了,应该是
    if z=0 then
        canvas.MoveTo(x,y ) ;
       if  z<>3 then
       begin
         point[z].X:=X;
         point[z].Y:=y;
       end
       if z=3 then     canvas.PolyBezier(point);
      

  4.   

    我试了 还是不行!~ 当点第四个点的什么时候,并没有画!~ 当点第五点时!~ 程序出错了!~
    为什么要在Z=0的时候移动到 那点而 Z=1 2 3 的时候不用MOVETO到那个点!~ 
    我好像还犯了个错误!~ 当Z=3时 还是要传值的! 因为Z=3是第四个点!~
      

  5.   

    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
     var point:array [0..3] of Tpoint;
     begin
    if z=0 then
        canvas.MoveTo(x,y ) ;
       if  z<>4 then
       begin
         point[z].X:=X;
         point[z].Y:=y;
         z:=z+1;
       end  ;
       if z=4 then
          canvas.PolyBezier(point);
    end;
    程序改成这样后,虽然画了,可是画出一条线!~ 不知道为什么!~
      

  6.   

    <Windows图形编程>里有讲如何画出通过指定四个点的贝塞尔曲线。
      

  7.   

    不是,你看我在外面给你的那个帖子了么?
    改成
    mousedown应该这么样
       if z=0 then
        canvas.MoveTo(x,y ) ;   point[z].X:=X;
       point[z].Y:=y;   if z=3 then     canvas.PolyBezier(point);
    我试过了
      

  8.   

    在哪里 ? CSDN?? 书?
      

  9.   

    不行!~ 画完是一条直线啊!~  你画完是曲线吗?? 现在把完整程序贴出来!~ 
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormCreate(Sender: TObject);
        procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        z:integer;
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
     var point:array [0..3] of Tpoint;
     begin
     if z=0 then
        canvas.MoveTo(x,y ) ;   point[z].X:=X;
       point[z].Y:=y;   if z=3 then
         canvas.PolyBezier(point);
     end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    z:=0;
    end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    z:=z+1;
    end;end.
      

  10.   

    看这里吧,绝对没问题,点击4下后画出besizer曲线。unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}var
      count:integer;
      points:array[0..3] of TPoint;
      rec:boolean;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if rec then
      begin
        points[count].X:=x;
        points[count].Y:=y;
        inc(count);
        if count>=4 then
        begin
          form1.Canvas.PolyBezier(points);
          rec:=false;
        end;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      rec:=true;
    end;end.
      

  11.   

    少作修改,画多少条都行,  每单击四次画一条:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}var
      count:integer;
      points:array[0..3] of TPoint;
      rec:boolean;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if rec then
      begin
        points[count].X:=x;
        points[count].Y:=y;
        inc(count);
        if count=4 then
        begin
          form1.Canvas.PolyBezier(points);
          //rec:=false;
          count:=0;
        end;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      rec:=true;
    end;end.
      

  12.   

    古木 正确 !~  谢谢你 !~
    也谢谢 walterwl(I Love Delphi)的热心让帖子不沉!~ :)
      

  13.   

    明白了!~  关键在这!~  count:=0;