BGRABitmap图像操作3:用鼠标在窗体画连续的曲线
来源:互联网 发布:蓝胖升级数据 编辑:程序博客网 时间:2024/05/22 15:07
unit Unit1;{$mode objfpc}{$H+}interfaceuses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, BGRABitmap, BGRABitmapTypes;type { TForm1 } TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormPaint(Sender: TObject); private { private declarations } image: TBGRABitmap; mouseDrawing: boolean; mouseOrigin: TPoint; procedure DrawBrush(X, Y: Integer; Closed: Boolean); procedure PaintImage; public { public declarations } end;var Form1: TForm1;implementation{$R *.lfm}{ TForm1 }procedure TForm1.FormCreate(Sender: TObject);begin image := TBGRABitmap.Create(640,480,BGRAWhite); //create a 640x480 imageend;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin if Button = mbLeft then begin mouseDrawing := True; mouseOrigin := Point(X,Y); DrawBrush(X,Y,True); // or DrawBrush(X,Y); end;end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin if mouseDrawing then DrawBrush(X,Y,False);end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin if Button = mbLeft then mouseDrawing := False;end;procedure TForm1.FormPaint(Sender: TObject);begin PaintImage;end;procedure TForm1.PaintImage;begin image.Draw(Canvas,0,0,True);end;procedure TForm1.DrawBrush(X, Y: Integer; Closed: Boolean);const brushRadius = 20;begin image.DrawLineAntialias(X,Y,mouseOrigin.X,mouseOrigin.Y,BGRA(0,0,0,128),brushRadius,Closed); mouseOrigin := Point(X,Y); PaintImage;end;end.
0 0
- BGRABitmap图像操作3:用鼠标在窗体画连续的曲线
- BGRABitmap图像操作3:用鼠标在窗体画断续的曲线
- BGRABitmap图像操作1:最简单的例子,在窗体上画一个长方体
- BGRABitmap图像操作7:开放的样条曲线(spline)
- BGRABitmap图像操作7:封闭的样条曲线(spline)
- BGRABitmap图像操作7:贝塞尔曲线
- BGRABitmap图像操作14:BGRABitmap的 Canvas2D
- BGRABitmap图像操作13:BGRABitmap的坐标系统
- BGRABitmap图像操作6:平的线头
- BGRABitmap图像操作的其余内容链接
- BGRABitmap图像操作8:纹理
- BGRABitmap图像操作6:使用不同的线型与形状
- BGRABitmap图像操作6:前面的长方形改成圆角
- BGRABitmap图像操作6:线的两种连接方式
- BGRABitmap图像操作8:轴向的木质纹理
- BGRABitmap图像操作9d:渲染前面的水纹
- BGRABitmap图像操作8:用正弦函数生成纹理
- BGRABitmap图像操作9:用 phong 阴影制作纹理
- 语音识别入门
- JAVA反射的基本使用
- C++之内存管理介绍
- Sensors传感器介绍(一)
- oracle 列转行 多行数据转为一行
- BGRABitmap图像操作3:用鼠标在窗体画连续的曲线
- java调用http请求
- 如何用Gson解析复杂的Json数据
- 【《代码整洁之道》精读与演绎】之一 让代码比你来时更干净
- eclipse中的properties editor
- SICP 1.11-1.13
- shell 变量
- 【数组2】数组中出现次数超过一半的数
- POJ3159 Candies(差分约束+SPFA的栈实现)