Стартовый пул
This commit is contained in:
18
bgrabitmap/test/test4ideu/fractal_tree/fractal_tree.pas
Normal file
18
bgrabitmap/test/test4ideu/fractal_tree/fractal_tree.pas
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
program demo;
|
||||
|
||||
{$IFDEF FPC}{$MODE objfpc}{$H+}{$ENDIF}
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF mswindows}{$APPTYPE gui}{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
{$IFDEF FPC}{$IFDEF unix}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
msegui, mseforms, main;
|
||||
|
||||
begin
|
||||
application.createform(tmainfo, mainfo);
|
||||
application.run;
|
||||
end.
|
1278
bgrabitmap/test/test4ideu/fractal_tree/fractal_tree.prj
Normal file
1278
bgrabitmap/test/test4ideu/fractal_tree/fractal_tree.prj
Normal file
File diff suppressed because it is too large
Load Diff
31
bgrabitmap/test/test4ideu/fractal_tree/main.mfm
Normal file
31
bgrabitmap/test/test4ideu/fractal_tree/main.mfm
Normal file
@@ -0,0 +1,31 @@
|
||||
object mainfo: tmainfo
|
||||
bounds_x = 634
|
||||
bounds_y = 219
|
||||
bounds_cx = 420
|
||||
bounds_cy = 420
|
||||
bounds_cxmin = 120
|
||||
bounds_cymin = 120
|
||||
container.frame.localprops = []
|
||||
container.frame.localprops1 = []
|
||||
container.bounds = (
|
||||
0
|
||||
0
|
||||
420
|
||||
420
|
||||
)
|
||||
caption = 'Fractal Tree by Lainz'
|
||||
windowopacity = -Inf
|
||||
moduleclassname = 'tmainform'
|
||||
object tpaintbox1: tpaintbox
|
||||
optionswidget = [ow_mousefocus, ow_tabfocus, ow_arrowfocus, ow_mousewheel, ow_destroywidgets]
|
||||
color = -1610612712
|
||||
frame.localprops = []
|
||||
frame.localprops1 = []
|
||||
onpaint = tpaintbox1_onpaint
|
||||
bounds_x = 0
|
||||
bounds_y = 0
|
||||
bounds_cx = 420
|
||||
bounds_cy = 420
|
||||
anchors = []
|
||||
end
|
||||
end
|
95
bgrabitmap/test/test4ideu/fractal_tree/main.pas
Normal file
95
bgrabitmap/test/test4ideu/fractal_tree/main.pas
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
unit main;
|
||||
|
||||
{$IFDEF FPC}{$MODE objfpc}{$H+}{$ENDIF}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
mseglob, mseguiglob, mseguiintf, mseapplication, msestat, msemenus, msegui,
|
||||
msegraphics, msegraphutils, mseevent, mseclasses, mseforms, msesimplewidgets,
|
||||
msewidgets, math;
|
||||
|
||||
type
|
||||
tmainfo = class(tmainform)
|
||||
tpaintbox1: tpaintbox;
|
||||
procedure tpaintbox1_onpaint(const sender: twidget; const acanvas: tcanvas);
|
||||
end;
|
||||
|
||||
const
|
||||
deg_to_rad = pi / 180;
|
||||
|
||||
var
|
||||
mainfo: tmainfo;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
BGRABitmap, BGRABitmapTypes, BGRAGraphics, BGRAClasses, BGRAUTF8,
|
||||
BGRAGradientScanner, main_mfm;
|
||||
|
||||
procedure drawTree(x1, y1, angle, depth, multiplier: single; bgra : tbgrabitmap);
|
||||
var
|
||||
x2, y2: single;
|
||||
begin
|
||||
if (depth > 0) then
|
||||
begin
|
||||
x2 := x1 + (cos(angle * deg_to_rad) * depth * multiplier);
|
||||
y2 := y1 + (sin(angle * deg_to_rad) * depth * multiplier);
|
||||
|
||||
bgra.DrawLineAntialias(x1, y1, x2, y2, BGRABlack, depth, False);
|
||||
|
||||
// Use even values without randomness to get a 'real' fractal image
|
||||
|
||||
drawTree(x2, y2, angle - randomrange(15,50), depth - 1.44, multiplier, bgra);
|
||||
drawTree(x2, y2, angle + randomrange(10,25), depth - 0.72, multiplier, bgra);
|
||||
drawTree(x2, y2, angle - randomrange(10,25), depth - 3, multiplier, bgra);
|
||||
drawTree(x2, y2, angle + randomrange(15,50), depth - 4, multiplier, bgra);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure tmainfo.tpaintbox1_onpaint(const sender: twidget; const acanvas: tcanvas);
|
||||
const
|
||||
SampleText = 'HellÔ green tree';
|
||||
MarginX = 20;
|
||||
MarginY = 20;
|
||||
var
|
||||
bmp : tbgrabitmap;
|
||||
multiplier : single;
|
||||
grad: TBGRACustomGradient;
|
||||
scan: TBGRACustomScanner;
|
||||
textWidth: integer;
|
||||
begin
|
||||
bmp := tbgrabitmap.create(sender.bounds_cx, sender.bounds_cy);
|
||||
|
||||
multiplier := sender.bounds_cy / 50;
|
||||
|
||||
bmp.GradientFill(0, 0, bmp.Width, bmp.Height, cl_dkgreen, BGRA(0,125,0),
|
||||
gtLinear, PointF(0,0), PointF(0, bmp.Height), dmSet);
|
||||
|
||||
drawTree(bmp.Width div 2, bmp.Height, -91, 9, multiplier, bmp);
|
||||
|
||||
bmp.FontFullHeight := 30;
|
||||
textWidth := bmp.TextSize(SampleText).cx;
|
||||
bmp.TextOut(MarginX, MarginY, SampleText, BGRAWhite);
|
||||
bmp.HorizLine(MarginX, MarginY, MarginX + bmp.TextSize(SampleText).cx-1, BGRAWhite);
|
||||
bmp.HorizLine(MarginX, MarginY + bmp.FontFullHeight, MarginX + textWidth-1, BGRAWhite);
|
||||
|
||||
bmp.FontFullHeight := 40;
|
||||
bmp.FontStyle := [fsBold];
|
||||
textWidth := bmp.TextSize(SampleText).cx;
|
||||
grad := TBGRAHueGradient.Create(0,0,65535,40000,[hgoRepeat,hgoPositiveDirection,hgoLightnessCorrection]);
|
||||
scan := TBGRAGradientScanner.Create(grad, gtLinear, PointF(0, bmp.Height - MarginY), PointF(0, bmp.Height - MarginY - textWidth));
|
||||
bmp.TextOutAngle(bmp.Width - MarginX - bmp.FontFullHeight, bmp.Height - MarginY, 900, SampleText, scan);
|
||||
scan.Free;
|
||||
grad.Free;
|
||||
|
||||
bmp.Rectangle(0, 0, bmp.Width, bmp.Height, BGRABlack);
|
||||
|
||||
bmp.Rectangle(5, 5, bmp.Width - 5, bmp.Height - 5, BGRABlack);
|
||||
|
||||
bmp.draw(acanvas, 0, 0, false);
|
||||
bmp.free;
|
||||
end;
|
||||
|
||||
end.
|
43
bgrabitmap/test/test4ideu/fractal_tree/main_mfm.pas
Normal file
43
bgrabitmap/test/test4ideu/fractal_tree/main_mfm.pas
Normal file
@@ -0,0 +1,43 @@
|
||||
unit main_mfm;
|
||||
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
|
||||
|
||||
interface
|
||||
|
||||
implementation
|
||||
uses
|
||||
mseclasses,main;
|
||||
|
||||
const
|
||||
objdata: record size: integer; data: array[0..518] of byte end =
|
||||
(size: 519; data: (
|
||||
84,80,70,48,7,116,109,97,105,110,102,111,6,109,97,105,110,102,111,8,
|
||||
98,111,117,110,100,115,95,120,3,122,2,8,98,111,117,110,100,115,95,121,
|
||||
3,219,0,9,98,111,117,110,100,115,95,99,120,3,164,1,9,98,111,117,
|
||||
110,100,115,95,99,121,3,164,1,12,98,111,117,110,100,115,95,99,120,109,
|
||||
105,110,2,120,12,98,111,117,110,100,115,95,99,121,109,105,110,2,120,26,
|
||||
99,111,110,116,97,105,110,101,114,46,102,114,97,109,101,46,108,111,99,97,
|
||||
108,112,114,111,112,115,11,0,27,99,111,110,116,97,105,110,101,114,46,102,
|
||||
114,97,109,101,46,108,111,99,97,108,112,114,111,112,115,49,11,0,16,99,
|
||||
111,110,116,97,105,110,101,114,46,98,111,117,110,100,115,1,2,0,2,0,
|
||||
3,164,1,3,164,1,0,7,99,97,112,116,105,111,110,6,21,70,114,97,
|
||||
99,116,97,108,32,84,114,101,101,32,98,121,32,76,97,105,110,122,13,119,
|
||||
105,110,100,111,119,111,112,97,99,105,116,121,5,0,0,0,0,0,0,0,
|
||||
128,255,255,15,109,111,100,117,108,101,99,108,97,115,115,110,97,109,101,6,
|
||||
9,116,109,97,105,110,102,111,114,109,0,9,116,112,97,105,110,116,98,111,
|
||||
120,10,116,112,97,105,110,116,98,111,120,49,13,111,112,116,105,111,110,115,
|
||||
119,105,100,103,101,116,11,13,111,119,95,109,111,117,115,101,102,111,99,117,
|
||||
115,11,111,119,95,116,97,98,102,111,99,117,115,13,111,119,95,97,114,114,
|
||||
111,119,102,111,99,117,115,13,111,119,95,109,111,117,115,101,119,104,101,101,
|
||||
108,17,111,119,95,100,101,115,116,114,111,121,119,105,100,103,101,116,115,0,
|
||||
5,99,111,108,111,114,4,24,0,0,160,16,102,114,97,109,101,46,108,111,
|
||||
99,97,108,112,114,111,112,115,11,0,17,102,114,97,109,101,46,108,111,99,
|
||||
97,108,112,114,111,112,115,49,11,0,7,111,110,112,97,105,110,116,7,18,
|
||||
116,112,97,105,110,116,98,111,120,49,95,111,110,112,97,105,110,116,8,98,
|
||||
111,117,110,100,115,95,120,2,0,8,98,111,117,110,100,115,95,121,2,0,
|
||||
9,98,111,117,110,100,115,95,99,120,3,164,1,9,98,111,117,110,100,115,
|
||||
95,99,121,3,164,1,7,97,110,99,104,111,114,115,11,0,0,0,0)
|
||||
);
|
||||
|
||||
initialization
|
||||
registerobjectdata(@objdata,tmainfo,'');
|
||||
end.
|
Reference in New Issue
Block a user