BGRABitmap图像操作9e:用阈值制作雪上印迹纹理
来源:互联网 发布:研究生人工智能方向 编辑:程序博客网 时间:2024/04/30 15:47
unit Unit1;{$mode objfpc}{$H+}interfaceuses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, BGRABitmap, BGRABitmapTypes, BGRAGradients;type { TForm1 } TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormPaint(Sender: TObject); private { private declarations } phong: TPhongShading; chocolate: TBGRABitmap; public { public declarations } end;var Form1: TForm1;implementation{$R *.lfm}{ TForm1 }function CreateSnowPrintTexture(tx,ty: integer): TBGRABitmap;var v: integer; p: PBGRAPixel; i: Integer; temp: TBGRABitmap; phong: TPhongShading;begin //here a random map is generated result := CreateCyclicPerlinNoiseMap(tx,ty,1,1,1.2); //now we apply thresholds p := result.Data; for i := 0 to result.NbPixels-1 do begin v := p^.red; //if the value is above 80 or under 50, then we divide it by 10 to make it almost horizontal if v > 80 then v := (v-80) div 10+80; if v < 50 then v := 50-(50-v) div 10; p^.red := v; p^.green := v; p^.blue := v; inc(p); end; //to make phong shader aware of the cycle temp:= result.GetPart(rect(-2,-2,tx+2,ty+2)) as TBGRABitmap; //apply a radial blur BGRAReplace(temp,temp.FilterBlurRadial(2,rbFast)); phong := TPhongShading.Create; phong.LightSourceDistanceFactor := 0; phong.LightDestFactor := 0; phong.LightSourceIntensity := 100; phong.LightPositionZ := 100; phong.NegativeDiffusionFactor := 0.3; //want shadows phong.Draw(result,temp,30,-2,-2,BGRAWhite); phong.Free; temp.Free;end;procedure TForm1.FormCreate(Sender: TObject);begin phong := TPhongShading.Create; phong.LightPositionZ := 150; phong.SpecularIndex := 20; phong.AmbientFactor := 0.4; phong.LightSourceIntensity := 250; phong.LightSourceDistanceTerm := 200; //chocolate := CreateChocolateTexture(80,80);end;procedure TForm1.FormDestroy(Sender: TObject);begin phong.Free; chocolate.Free;end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin phong.LightPosition := point(X,Y); FormPaint(Sender);end;procedure TForm1.FormPaint(Sender: TObject);var image: TBGRABitmap; stone: TBGRABitmap;begin image := TBGRABitmap.Create(ClientWidth,ClientHeight,ColorToBGRA(ColorToRGB(clBtnFace))); stone := CreateSnowPrintTexture(100,100); image.FillEllipseAntialias(100,100,250,150,stone); stone.free; image.Draw(Canvas,0,0,True); image.free;end;end.
0 0
- BGRABitmap图像操作9e:用阈值制作雪上印迹纹理
- BGRABitmap图像操作9:用 phong 阴影制作纹理
- BGRABitmap图像操作8:彩色纹理,阈值
- BGRABitmap图像操作8:纹理
- BGRABitmap图像操作9c:同时使用莫林杂点和 phong 阴影制作纹理
- BGRABitmap图像操作8:另一个阈值控制方式,生成迷彩纹理
- BGRABitmap图像操作9b:巧克力纹理背景
- BGRABitmap图像操作8:用正弦函数生成纹理
- BGRABitmap图像操作8:彩色纹理
- BGRABitmap图像操作8:大理石纹理
- BGRABitmap图像操作8:木质纹理
- BGRABitmap图像操作10:使用纹理映射
- BGRABitmap图像操作8:纹理,前面椭圆外加一圆角长方形
- BGRABitmap图像操作8:轴向的木质纹理
- BGRABitmap图像操作10:使用Affine 变换进行纹理映射
- BGRABitmap图像操作14:BGRABitmap的 Canvas2D
- BGRABitmap图像操作8:生成纹理,基本的Perlin噪声地图
- BGRABitmap图像操作10:线型映射,让纹理图贴到多边形的边上
- 理解 Python 中的 *args 和 **kwargs
- 【《代码整洁之道》精读与演绎】之一 让代码比你来时更干净
- php基础之文件载入过程 路径及四种载入关键词区别
- 约数的计算
- 子串查找的算法-----BM
- BGRABitmap图像操作9e:用阈值制作雪上印迹纹理
- Light and Matter-The theory of Physically-Based Rendering and Shading
- LeetCode之Excel Sheet Column Number
- MFC之绘制线条
- 如何配置phpmyadmin,让其可以外网ip
- MySQL免安装配置
- 树形结构的数据库表Schema设计
- Java-接口
- Spark架构剖析