Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses vcl, graphabc, system, ABCObjects, System.Drawing.Drawing2D;
- var Horizon:Point;
- var sky: RectangleABC;
- var current:RegularPolygonABC;
- var i:integer;
- var r:Random;
- var SKY_COLOR:Color = System.Drawing.Color.FromArgb(1, 1, 16);
- var SKY_COLOR_TWO:Color = Color.FromArgb(70,60,122);
- //var SKY_COLOR_THREE:Color = Color.FromArgb(255, 205, 154);
- //СЕКЦИЯ ПАРАМЕТРОВ.
- //Горизонт
- const HORIZON_LOCK = true;//Блокировка на горизонт
- const HORIZON_Y = 300;
- 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 = 4; //Количество треугольников
- const MIN_SPRUCE_SECTIONS = 3; //Минимальное количество треугольников
- const MAX_SPRUCE_SECTIONS = 5; //Максимальное количество треугольников
- //Основание
- const SPRUCE_BASE_HEIGHT_RELATION = 0.4;
- const SPRUCE_BASE_WIDTH_RELATION = 0.1;
- //Цвета
- var BASEMENT_COLOR:Color = Color.FromArgb(43, 29, 15);
- procedure drawTriangle(x:integer; y:integer; side:integer; color: System.Drawing.Color);
- var R: integer = round((2/3)*side * sin(3.14/3));
- xc: integer = x + side div 2;
- yc: integer = round(y - (1/3) * side * sin(3.14/3));
- triangle:RegularPolygonABC = new RegularPolygonABC(xc,yc,R,3,color);
- begin
- triangle.BorderColor := color;
- triangle.ToFront();
- 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
- //Основание треугольника
- var base: RectangleABC = new RectangleABC(x + size div 2 - baseWidth div 2,y,baseWidth, baseHeight, BASEMENT_COLOR);
- base.BorderColor := BASEMENT_COLOR;
- sections:=SPRUCE_SECTIONS;
- 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
- window.Width:=720;
- window.Height:=480;
- r := new Random();
- setSmoothingOff;
- //Установка горизонта
- if(HORIZON_LOCK) then
- Horizon := window.Center()
- else
- Horizon:= new Point(0, HORIZON_Y);
- //Небо
- setBrushColor(SKY_COLOR);
- SetBrushStyle(BrushStyleType.bsGradient);
- (Brush.NETBrush as LinearGradientBrush).LinearColors := new Color[2](SKY_COLOR,SKY_COLOR_TWO);
- FillRect(0,0,window.Width,Horizon.Y);
- //Земля
- setBrushColor(clBlack);
- setBrushStyle(BrushStyleType.bsSolid);
- FillRect(0,Horizon.Y-1, window.Width, window.Height);
- //Звезды
- for i:=1 to 300 do begin
- var x:integer:= round(window.Width * r.NextDouble());
- var y:integer:= round(Horizon.Y * r.NextDouble());
- putPixel(x,y,clWhite);
- end;
- var xPos:integer = 0;
- var shifter:integer = 0;
- var dh:double = 0;
- var colorgrade:double = 0.3;
- while (shifter<35) do begin
- xPos:=-round(r.NextDouble()*20);
- for i:=0 to 80-shifter*2 do begin
- dh := r.NextDouble();
- //dh:=1;
- var ran:double = r.NextDouble();
- drawSpruce(xPos,Horizon.Y + round(shifter * dh),15+shifter, Color.FromArgb(14+round(shifter*ran*3*colorgrade), 22+round(shifter*ran*3*colorgrade), 2+round(shifter*ran*3*colorgrade)));
- xPos += round(r.NextDouble()* (20 + 2*shifter));
- end;
- shifter+=5;
- colorgrade+=0.001;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement