Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Pascal Lesson 8 Graphics.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
110.08 Кб
Скачать

Inc(Grow);

Ellipse(GetMaxX Div 2,

GetMaxY Div 2, 0, 360,

GetMaxX Div 2, Radius + Grow);

Delay(1);

End;

ClearViewPort;

SetTextJustify(230, GetMaxY Div 2);

OutTextXY(230,GetMaxY Div 2,'Now what?'); Delay(1000);

ClearViewPort;

{Here's another graphics invention of mine! Similar

to the first one, but using two circles positioned

on both edges of the screen,

continously increasing in size}

For Radius := 1 to 600 do

Begin

Circle(GetMaxX Div 2, 0, Radius);

Circle(GetMaxX Div 2, GetMaxY, Radius);

Delay(2);

End;

Delay(1000);

ClearViewPort;

SetTextJustify(230, GetMaxY Div 2);

OutTextXY(230,GetMaxY Div 2,'What are you lookin'' at?');

Delay(1000);

ClearViewPort;

Grow := 0;

{Below is a simple rectangle loop,

which inreases its size by 1

(increment x1,y1 and decrement x2,y2)}

For Radius := 1 to 600 do

Begin

Inc(Grow);

Rectangle(((GetMaxX Div 2) - Radius) - Grow,

((GetMaxY Div 2) - Radius)- Grow,

((GetMaxX Div 2) + Radius) + Grow,

((GetMaxY Div 2) + Radius) + Grow);

Delay(2);

End;

ClearDevice;

SetTextJustify(230, GetMaxY Div 2);

OutTextXY(230,GetMaxY Div 2,

'Rotor of a helicopter thorn apart..');

Delay(2000);

ClearDevice;

{The demonstration below shows 4 rotating sectors,

moving horizontally,

and 4 other sectors in the opposite direction}

IncP := 0; IncQ := 0;

For Radius := 1 to 320 do

Begin

Inc(IncQ, 1);

Inc(IncP, (IncQ Div 2));

PieSlice(GetMaxX Div 2 + IncP,

GetMaxY Div 2, 0 + IncP, 2 + IncP, 240);

PieSlice(GetMaxX Div 2 + IncP,

GetMaxY Div 2, 180 + IncP, 182 + IncP, 240);

PieSlice(GetMaxX Div 2 + IncP,

GetMaxY Div 2, 88 + IncP, 90 + IncP, 240);

PieSlice(GetMaxX Div 2 + IncP,

GetMaxY Div 2, 268 + IncP, 270 + IncP, 240);

PieSlice(GetMaxX Div 2 - IncP,

GetMaxY Div 2, 45 + IncP, 47 + IncP, 240);

PieSlice(GetMaxX Div 2 - IncP,

GetMaxY Div 2, 135 + IncP, 137 + IncP, 240);

PieSlice(GetMaxX Div 2 - IncP,

GetMaxY Div 2, 225 + IncP, 227 + IncP, 240);

PieSlice(GetMaxX Div 2 - IncP,

GetMaxY Div 2, 315 + IncP, 317 + IncP, 240);

Delay(10);

ClearDevice;

If IncP >= 220 then

Dec(IncQ, 4);

End;

ClearViewPort;

SetTextJustify(230, GetMaxY Div 2);

OutTextXY(230,GetMaxY Div 2,'Ah, now it is repaired..');

Delay(2000);

ClearDevice;

{The next demonstration shows a fantastic

rotor-like movement animation}

{Do not be amazed by the coding below - it's very simple}

{To make such animation, all you

have to do is to make a sector rotating

by simply increasing its degrees and clear the old one}

IncP := 0; IncQ := 0;

For Radius := 1 to 320 do

Begin

Inc(IncQ, 1);

Inc(IncP, (IncQ Div 4));

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 0 + IncP, 2 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 180 + IncP, 182 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 90 + IncP, 92 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 270 + IncP, 272 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 45 + IncP, 47 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 135 + IncP, 137 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 225 + IncP, 227 + IncP, 240);

PieSlice(GetMaxX Div 2,

GetMaxY Div 2, 315 + IncP, 317 + IncP, 240);

Delay(10);

ClearDevice;

End;

SetTextJustify(230, GetMaxY Div 2);

OutTextXY(220,GetMaxY Div 2,'The chop is on its way!');

Delay(1000);

ClearDevice;

Randomize;

IncP := Random(GetMaxX) + 1;

IncQ := 0;

DecrP := False;

DecrQ := False;

For Radius := 1 to MaxInt do

Begin

If not(DecrP) then Inc(IncP,3) Else

If DecrP then Dec(IncP,3);

If not(DecrQ) then Inc(IncQ,3) Else

If DecrQ then Dec(IncQ,3);

SetColor(LightCyan);

{Now FillCircle! - same radii (20)}

FillEllipse(IncP,IncQ, 20, 20);

Circle(IncP, IncQ, 40);

PieSlice(IncP, IncQ, 0 + (IncP * 80),

6 + (IncP * 80), 100);

PieSlice(IncP, IncQ, 180 + (IncP * 80),

186 + (IncP * 80), 100);

PieSlice(IncP, IncQ, 90 + (IncP * 80),

96 + (IncP * 80), 100);

PieSlice(IncP, IncQ, 270 + (IncP * 80),

276 + (IncP * 80), 100);

If IncP > GetmaxX then DecrP := True Else

If IncP < 0 then DecrP := False;

If IncQ > GetmaxY then DecrQ := True Else

If IncQ < 0 then DecrQ := False;

Delay(10);

ClearDevice; {Try to remove this :-)}

If KeyPressed then Break;

End;

ReadKey;

SetTextStyle(SansSerifFont,HorizDir,1);

SetUserCharSize(2,1,5,1);

OutTextXy(12,20,'Was it fun? Ehh???');

SetUserCharSize(1,1,2,1);

SetColor(LightCyan);

OutTextXY(35,190,'Now you can try to do it yourself.');

OutTextXY(20,240,'If you have any comments then send');

OutTextXY(180,300,'me an e-mail to');

OutTextXY(120,400,'victorsaliba@hotmail.com');

Readln;

CloseGraph;

End.

Have you successfully ran the program above? How's it? There are many different animations! I used some statements which you are'nt still familiar with. But, sooner or later, you will get to know how to use them and know their function.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]