Фрактал вложенные квадраты

Фрактал вложенные квадраты

Демонстрация, построенная на известном фрактале "Вложенные квадраты". Эффект движения сделан за счет динамической смены цвета каждого вложенного квадрата.

Разместите на форме компонент Image1: TImage с вкладки Additional и компонент Timer1: TTimer с вкладки System. В инспекторе объектов (Object Inspector) выставьте начальные значения для компонентов.

Form1
  ClientWidth: 500
  ClientHeight: 500
 
Image1
  Align: alClient
 
Timer1
  Interval: 30

Переключитесь клавишей F12 в редактор кода и создайте в разделе Private класса Form1 процедуру Procedure RotateRect;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    Procedure RotateRect;
  public
    { Public declarations }
  end;

Нажмите CTRL+SHIFT+C, данная компбинация автоматически создаст заголовок процедуры в разделе implementation. Впишите в нее следующий код:

procedure TForm1.RotateRect;
Const N = 55;
      DT = 20;
      SD = 0;
Var Col        : TColor;
    RC, GC, BC : Integer; // Составляющие цвета
    Pnt        : Array [1..4] of TPoint;
    mx, my     : Integer;
    d          : ShortInt;
    i          : Integer;
begin
  With Image1 do begin
    Pnt[1].x := SD;
    Pnt[1].y := SD;
    Pnt[2].x := Width - SD;
    Pnt[2].y := SD;
    Pnt[3].x := Width - SD;
    Pnt[3].y := Height - SD;
    Pnt[4].x := SD;
    Pnt[4].y := Height - SD;
    GC :=0; RC := 0; BC := IC;
    d := id;
    Col := RGB( BC, GC, BC);
    Canvas.Pen.Color   := Col;
    Canvas.Brush.Color := Col;
    Canvas.Polygon( Pnt);
    For i:=1 to N do begin
      mx := Pnt[1].x;
      my := Pnt[1].y;
      Pnt[1].x := Pnt[1].x + (Pnt[2].x - Pnt[1].x) div DT;
      Pnt[1].y := Pnt[1].y + (Pnt[2].y - Pnt[1].y) div DT;
      Pnt[2].x := Pnt[2].x + (Pnt[3].x - Pnt[2].x) div DT;
      Pnt[2].y := Pnt[2].y + (Pnt[3].y - Pnt[2].y) div DT;
      Pnt[3].x := Pnt[3].x + (Pnt[4].x - Pnt[3].x) div DT;
      Pnt[3].y := Pnt[3].y + (Pnt[4].y - Pnt[3].y) div DT;
      Pnt[4].x := Pnt[4].x + (mx - Pnt[4].x) div DT;
      Pnt[4].y := Pnt[4].y + (my - Pnt[4].y) div DT;
      if BC >= 255 then d := -1;
      if BC <= 0   then d := 1;
      BC := BC + d * 5;
      Col := RGB( BC, GC, BC);
      Canvas.Pen.Color   := Col;
      Canvas.Brush.Color := Col;
      Canvas.Polygon( Pnt);
    end;
  if IC >= 255 then begin Id := 1; end;
  if IC <= 0 then begin Id := -1;  end;
  IC := IC - id * 5;
  end;
end;

Проинициализируйте в основном разделе Var две глобальные переменные

Var Form1: TForm;
    IC : Integer = 250;
    ID : ShortInt = -1;

Теперь вернитесь на форму (Клавиша F12) и сделайте двойной щелчок на компоненте Timer1 - это создаст в редакторе кода процедуру procedure TForm1.Timer1Timer(Sender: TObject); в которую необходимо вписать вызов процедуры RotateRect:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  RotateRect;
end;

Запустите программу. Run (F9).

Если Вы хотите, чтоб при перемещении окна, картинка не мерцала, задайте форме Form1 свойство DoubleBuffered := true. Сделать это лучше сразу при создании формы на событие OnCreate (вкладка Events в инспекторе объектов).

procedure TForm1.FormCreate(Sender: TObject);
begin
 DoubleBuffered := true;
end;

СКАЧАТЬ ПРОГРАММУРазмер
Move_Square.exe (356)393 кб

Отправил Ср, 09/13/2017 - 09:34

https://weightlossdiettopblog.wordpress.com/2017/09/02/best-contraceptive-pill-for-weight-loss-nz/
https://loseweightdiet753.wordpress.com/2017/08/29/lemon-and-bicarbonate-perfect-blend-to-lose-weight-and-quick-disinfect/
https://blogofweightloss.wordpress.com/2017/08/27/kefir-diet/
http://pagebin.com/EhJDJNRF
https://weightlossdiettopblog.wordpress.com/2017/09/01/losing-weight-with-walk-away-the-pounds/

Отправил Ср, 09/13/2017 - 06:19

https://sites.google.com/site/howtoweightlossdietplanbest/
http://weightlossdiet790.soup.io
https://weightlossdiettopblog.wordpress.com/?p=51
https://blogofweightloss.wordpress.com/2017/08/27/diet-by-blood-type/
https://weightlossdiettopblog.wordpress.com/2017/09/01/hypnotherapy-and-weight-loss-does-it-work/

Отправил Втр, 09/12/2017 - 09:01

https://sites.google.com/site/howtoweightlossdietplanbest/issues
https://weightlossdiettopblog.wordpress.com/2017/09/02/best-birth-control-pill-to-help-loss-weight/
http://pagebin.com/XRog5fsr
https://sites.google.com/site/howtoweightlossdietplanbest/wls1
https://weightlossdiettopblog.wordpress.com/2017/09/01/vegetarian-low-carb-diet-for-weight-loss/

Отправил Пнд, 09/11/2017 - 17:56

https://thebestweightloss567.wordpress.com/2017/08/29/get-involved-in-plastic-a-great-way-to-lose-weight/
https://blogofweightloss.wordpress.com/2017/08/27/diet-by-blood-type/
http://weightloserex.blogspot.com/2017/08/how-to-lose-weight-in-week.html
https://weightlossdiettopblog.wordpress.com/2017/09/01/how-effective-is-walking-on-a-treadmill-to-lose-weight/
https://weightlossdiettopblog.wordpress.com/2017/09/02/how-long-before-you-start-to-lose-weight/

Отправил Вс, 09/10/2017 - 19:36

http://pagebin.com/IqyG3ieT
https://thebestweightloss567.wordpress.com/2017/08/29/according-to-nutritionists-including-some-key-foods-on-the-menu-can-help-in-the-fight-against-the-scales/
https://weightlossdiettopblog.wordpress.com/2017/09/02/best-birth-control-pills-to-lose-weight/
https://sites.google.com/site/howtoweightlossdietplanbest/wl3
http://pagebin.com/Xd4WLxsc

Отправил Вс, 09/10/2017 - 15:04

https://weightlossdiettopblog.wordpress.com/2017/09/02/what-can-help-me-lose-weight-naturally/
http://pagebin.com/Iqt0U7xa
http://pagebin.com/mdF54bw1
https://weightlossdiettopblog.wordpress.com/?p=51
https://blogofweightloss.wordpress.com/2017/08/27/rice-diet/

Отправил Сб, 09/09/2017 - 11:04

http://weightlossnutra.soup.io
http://pagebin.com/EhJDJNRF
https://theloseweightdiet.wordpress.com/2017/08/30/7-day-weight-loss-diet-plan/
https://loseweightdiet753.wordpress.com/2017/08/29/lemon-and-bicarbonate-perfect-blend-to-lose-weight-and-quick-disinfect/
https://blogofweightloss.wordpress.com/2017/08/28/feng-shui-against-excess-weight/

Отправил Пт, 09/08/2017 - 12:23

https://blogofweightloss.wordpress.com/2017/08/27/remove-the-belly-in-2-weeks/
http://weightloserex.blogspot.com/2017/08/how-to-lose-weight-in-week.html
https://weightlossdiettopblog.wordpress.com/2017/09/02/how-to-lose-weight-diet-plan/
https://blogofweightloss.wordpress.com/2017/08/29/products-that-burn-fat-what-foods-burn-fat/
https://sites.google.com/site/siteabouttradingintheforex/

Отправил Чт, 09/07/2017 - 17:15

https://thebestweightloss567.wordpress.com/2017/08/29/get-involved-in-plastic-a-great-way-to-lose-weight/
https://weightlossdiettopblog.wordpress.com/2017/09/02/how-to-lose-weight-diet-plan/
https://sites.google.com/site/siteabouttradingintheforex/
https://weightlossdiettopblog.wordpress.com/2017/09/01/losing-weight-with-walk-away-the-pounds/
https://sites.google.com/site/howtoweightlossdietplanbest/documents

Отправил Чт, 09/07/2017 - 16:25

http://pagebin.com/EhJDJNRF
https://weightlossdiettopblog.wordpress.com/?p=51
http://pagebin.com/IqyG3ieT
https://weightlossdiettopblog.wordpress.com/2017/09/02/weight-loss-success-on-low-carb-diets/
http://pagebin.com/CeA7fuHD

Отправил Ср, 09/06/2017 - 01:50

https://weightlossdiettopblog.wordpress.com/2017/09/01/hypnotherapy-and-weight-loss-does-it-work/
https://blogofweightloss.wordpress.com/2017/08/28/products-with-a-negative-calorie-content/
https://weightlossdiettopblog.wordpress.com/?p=55
https://blogofweightloss.wordpress.com/2017/08/29/dietary-fish-recipes-of-dietary-fish-how-to-cook-a-dietary-fish/
https://blogofweightloss.wordpress.com/2017/08/27/how-to-lose-weight/

Отправил Ср, 09/06/2017 - 00:47

https://weightlossdiettopblog.wordpress.com/2017/09/02/best-birth-control-pill-to-help-loss-weight/
https://weightlossdiettopblog.wordpress.com/?p=64
https://blogofweightloss.wordpress.com/2017/08/29/plums-for-weight-loss/
http://pagebin.com/XRog5fsr
https://sites.google.com/site/siteabouttradingintheforex/

Отправил Пнд, 09/04/2017 - 22:13

https://blogofweightloss.wordpress.com/2017/08/27/slimming-baths-for-slimming/
https://blogofweightloss.wordpress.com/2017/08/28/how-to-lose-weight-with-activated-charcoal/
http://pagebin.com/bcF9XDJ5
https://weightlossdiettopblog.wordpress.com/2017/09/02/how-many-calories-do-you-need-to-lose-weight-while-breastfeeding/
https://blogofweightloss.wordpress.com/2017/08/28/how-to-lose-weight-with-food-film/

Отправил Пнд, 09/04/2017 - 22:13

https://weightlossdiettopblog.wordpress.com/?p=62
https://weightlossdiettopblog.wordpress.com/2017/09/02/how-to-lose-weight-fast-if-you-re-a-vegetarian/
https://weightlossdiettopblog.wordpress.com/?p=51
http://pagebin.com/Xd4WLxsc
https://weightlossdiettopblog.wordpress.com/2017/09/01/what-should-i-eat-per-day-to-lose-weight/

Отправил Сб, 09/02/2017 - 23:42

Bfhuwe fwbihfwei wbfeihfiw jbfiwfv iwefibwe 87ty439hgg

Отправил Сб, 09/02/2017 - 23:37

Uhwefwi ufhweifhw wnfjweof vbdnvweui wiefweh 47665yt34y

Отправил Втр, 08/29/2017 - 22:38

http://forum-ravon.ru/viewtopic.php?f=5&t=185510
http://paniqo.org/viewtopic.php?f=97&t=104186
http://www.forum.sampsonmordan.com/viewtopic.php?f=6&t=16625
http://fallenfrontiers.com/forum/viewtopic.php?f=10&t=2089
https://www.xivra.com/forums/index.php?topic=2237346.new#new
http://horoshevo.moscow/forum/index.php?topic=3273.new#new
http://prorm.com/foro/viewtopic.php?f=5&t=341662
http://forum.maarch.org/viewtopic.php?f=24&t=3519
http://www.baysidegolf.net/index.php/forum/ideal-forum/152-forex-brokers-review-all#552
http://paniqo.org/viewtopic.php?f=67&t=69362
http://help.dominanta.vpoloni.com/viewtopic.php?f=3&t=38323
http://fnatikx.com/viewtopic.php?f=34&t=7834
http://www.alcoforum.com/viewtopic.php?f=11&t=4813
http://jwch.info/viewtopic.php?f=17&t=120274
http://imdbcommunity.com/community/viewtopic.php?f=36&t=269353

Отправил Втр, 08/29/2017 - 07:03

http://lastcallpug.com/viewtopic.php?f=7&t=166206
http://forum.29k2.ru/viewtopic.php?f=8&t=12402
http://www.barmyarmy.com/forum/viewtopic.php?f=48&t=105400
http://umnikizdes.ru/topic550552.html
http://paniqo.org/viewtopic.php?f=58&t=90819
http://www.trinkwasserforum.at/viewtopic.php?f=9&t=13704
http://busanhr.com/forum.php?mod=forumdisplay&fid=2
http://forum.technicaldiving.ie/index.php/topic,139040.new.html#new
http://www.barmyarmy.com/forum/viewtopic.php?f=5&t=103391
http://mail.girey.ru/forum/20--/12030-usa-online-casino-no-deposit-codes-casinos-online-que-si-pagan-casino-online-hd-subtitrat#12030
http://forum.shtylm.com/index.php/topic,124053.new.html#new
http://haveallmotor.com/chat/forum.php?mod=forumdisplay&fid=36
http://leslapins-gamer.fr/forum/viewtopic.php?f=19&t=159662
http://www.darklordrp.com/forums/showthread.php?tid=60631
http://theshotokanway.com/tswforum/phpBB2/viewtopic.php?f=6&t=4370

Отправил Сб, 07/15/2017 - 03:24

We sell the sale of iPhones 7 directly from Apple warehouses unofficially for 30% of the market value. Always available and in large quantities:
1. New Apple iPhone 7 Plus 256 GB (Jet Black) (FACTORY UNLOCKED) International Version no warrants - $ 303
2. New Apple iPhone 7 Plus 256GB Factory Unlocked CDMA / GSM Smartphone - Black (Certified Refurbished) - $ 307
3. New Apple iPhone 7 PLUS (5.5-inch) A1661 128GB Unlocked Smartphone for GSM + CDMA Carriers - Rose Gold - $ 303
We work all over the world and only on an advance payment, we accept only bitcoin. Attention!!! We do not work with Russia and the CIS countries. When ordering from 10 pcs. The price is 20% of the market value. We have a priority in wholesale customers. If you do not trust us, or you do not like something, you pass by, we will not respond to stupid reports. To receive the details for payment, please write to the e-mail: apple@apple-cheap-iphone.xyz

Отправил Ср, 07/05/2017 - 18:22

Открылся новый магазин все по 50 рублей, например определенный товар стоит 5000 рублей или 7000 рублей то у нас вы можете найти его всего за 50 рублей: http://shop-50-rubley.xyz
магазин ежедневно пополняется, к концу недели будет очень богатый ассортимент.

Отправил Пнд, 04/27/2015 - 22:12

комментариев к программе не хватает
в строке кода

Отправил Вс, 11/15/2015 - 12:10

Красивая программа. У меня на VB6 попроще.

Последние комментарии

Счетчики