Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses vcl, graphabc, system, ABCObjects;
- var Horizon:Point;
- var current:RegularPolygonABC;
- //СЕКЦИЯ ПАРАМЕТРОВ.
- //Горизонт
- const HORIZON_LOCK = true;//Блокировка на горизонт
- const PARALLAX_SIZE_DECAY = 0.8;//Коэффициент послойного уменьшения размера
- const PARALLAX_COLOR_DECAY = 0.7;
- //Елка
- //ВОТ ЭТИ 2 ПАРАМЕТРА ЧЕТКО ПОДОБРАНЫ, но в принципе можешь поиграться
- const SPRUCE_DECAY_AMOUNT = 0.7; //Коэффицент падения ширины треугльников
- const SPRUCE_LAYER_COVER = 0.6; //Наложение треугольников
- const SPRUCE_SECTIONS_RANDOM = false; //Случайное количество треугольников
- const SPRUCE_SECTIONS = 3; //Количество треугольников
- const MIN_SPRUCE_SECTIONS = 3; //Минимальное количество треугольников
- const MAX_SPRUCE_SECTIONS = 5; //Максимальное количество треугольников
- //Основание
- const SPRUCE_BASE_HEIGHT_RELATION = 0.4;
- const SPRUCE_BASE_WIDTH_RELATION = 0.1;
- const BASEMENT_COLOR = Color.Brown;
- procedure drawTriangle(x:integer; y:integer; side:integer; color: System.Drawing.Color);
- begin
- //LockDrawing;
- setPenColor(color);
- MoveTo(x,y);
- LineTo(x+side, y);
- LineTo(x+side div 2, round(y - side * sin(3.14/3)));
- LineTo(x,y);
- FloodFill(x + side div 2, round(y - side * sin(3.14/3)) + 1 ,color);
- //Redraw;
- end;
- procedure drawSpruce(x:integer; y: integer; size:integer; color:system.Drawing.Color);
- var baseHeight:integer = round(size * SPRUCE_BASE_HEIGHT_RELATION);
- baseWidth: integer = round(size * SPRUCE_BASE_WIDTH_RELATION);
- initialX:integer = x;
- initialY: integer = y;
- initialSize: integer = size;
- sections:integer;
- i:integer;
- begin
- //Рисование ствола
- setPenColor(BASEMENT_COLOR);
- Rectangle(x + size div 2 - baseWidth div 2, y+1, x + size div 2 + baseWidth div 2, y + baseHeight);
- FloodFill(x + size div 2, y + 2,BASEMENT_COLOR);
- //if (SPRUCE_SECTIONS_RANDOM) then
- // sections:= random(MIN_SPRUCE_SECTIONS,MAX_SPRUCE_SECTIONS)
- //else
- sections:=3;
- for i:= 1 to sections do begin
- drawTriangle(initialX, initialY, initialSize, color);
- initialX:=initialX + round(initialSize * (1 - SPRUCE_DECAY_AMOUNT)) div 2;
- initialY:=round(initialY - initialSize * SPRUCE_LAYER_COVER);
- initialSize:=round(initialSize * SPRUCE_DECAY_AMOUNT);
- end;
- end;
- begin
- randomize;
- setSmoothingOff;
- if(HORIZON_LOCK) then
- Horizon := window.Center();
- //drawTriangle(100,100,30,clGreen);
- drawSpruce(100,300,70,clGreen);
- //current := new RegularPolygonABC(200,200,50,3,clRed);
- //current.BorderColor := clred;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement