Merry Xmas and a Happy New Year ! lazarus / 8-Other ---------------------------------------------------------------------- jc99 · 2015-12-24 00:47 I just wanted to wish everybody: A merry Xmas and a happy, successful and peaceful New Year ! Try That: Code: [Select]unit frm_XmasMain; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls; type   { TfrmXmasMain }   TfrmXmasMain = class(TForm)     procedure FormCreate(Sender: TObject);   end; var   frmXmasMain: TfrmXmasMain; implementation {$R *.lfm} { TfrmXmasMain } procedure TfrmXmasMain.FormCreate(Sender: TObject); var   I, J, R: integer;   image1: TImage; begin   image1 := TImage.Create(self);   image1.Parent := self;   image1.Height := 50;   image1.Width := 80;   for I := 0 to 49 do     for J := 0 to 79 do     begin       r := 1 + (i - (i div 10) * 7) - (i div 40) * (i - 30);       if (I > 7) and (i < 36) and (abs(50 - j - sin(int(i / 4) * 2.4) * int(i / 4) * 2) <=         1.5 + sin(i * 0.5 * pi)) then         image1.Canvas.Pixels[j, i] := clyellow       else if (I > 7) and (i < 36) and         (abs(50 - j - cos(int(i / 4) * 2.4) * int(i / 4) * 2) <= 1.5 + sin(i * 0.5 * pi)) then         image1.Canvas.Pixels[j, i] := clred       else if (I > 11) and (i < 40) and         (abs(50 - j - sin(int(i / 4) * 2.4 - 2.4) * (int(i / 4) * 2 - 2)) <= 1) then         image1.Canvas.Pixels[j, i] := clOlive       else if abs(50 - j) > r then         image1.Canvas.Pixels[j, i] :=           RGBToColor((1 - (i div 25)) * abs(i - 25) * 5, (i div 25) * (128 + abs(i - 25) * 5),           (1 - (i div 25)) * 180 + abs(i - 25) * 3)       else         image1.Canvas.Pixels[j, i] :=           RGBToColor((i div 40) * 128, trunc(((50 + r - j) / r) * 127), 0);     end;   image1.canvas.Font.Size := 7;   image1.Canvas.Brush.Style := bsClear;   image1.canvas.TextOut(2, 25, 'Merry');   image1.canvas.TextOut(15, 38, 'Xmas'); end; end. ---------------------------------------------------------------------- taazz · 2015-12-24 03:06 Merry Xmas and happy new year to you too. All my best wishes to you and the rest of the forum. ---------------------------------------------------------------------- LacaK · 2015-12-24 08:19 Quote from: taazz on December 24, 2015, 04:06:40 amMerry Xmas and happy new year to you too. All my best wishes to you and the rest of the forum. +1 ---------------------------------------------------------------------- Jurassic Pork · 2015-12-24 10:27 ____    {} _  \       |__ \      /_____\      \o o)\)_______      (<  ) /#######\    __{'~` }#########|   /  {   _}_/########|  /   {  / _|#/ )####| /   \_~/ /_ \  |####| \______\/  \ | |####|  \__________\|/#####|   |__[X]_____/ \###/   /___________\    |    |/    |    |___/ |___/   _|   /_|   /  (___,_(___,_) Merry Christmas  !!! ---------------------------------------------------------------------- jc99 · 2015-12-24 10:33 Thanks to you all, Xmas GFX V.2: (incl. some comments) Code: [Select]unit frm_XmasMain; {$mode objfpc}{$H+} interface uses   Classes, Forms, Graphics, ExtCtrls; type   { TfrmXmasMain }   TfrmXmasMain = class(TForm)     procedure FormCreate(Sender: TObject);   end; var   frmXmasMain: TfrmXmasMain; implementation {$R *.lfm} { TfrmXmasMain } procedure TfrmXmasMain.FormCreate(Sender: TObject); var   I, J, R, f, c, a: extended;   x, y, s: integer;   image1: TImage;   cc: TColor; begin   // Set Form Size ...   Height := 400;   Width := 640;   // Create display-image   image1 := TImage.Create(self);   image1.Parent := self;   image1.Height := 400;   image1.Width := 640;   // Render grafics   for Y := 0 to image1.Height - 1 do     for X := 0 to image1.Width - 1 do     begin       // Calc virtual coordinates       i := (y / image1.Height) * 50;       j := (x / image1.Width) * 80;       // Tree-radius       r := 0.1 + (i - int(i / 10) * 7) - int(i / 40) * (i - 31);       // flame-data       f := 50 - j - sin(int(i / 4) * 2.4) * int(i / 4) * 2;       s := 1;       if sin(int(i / 4) * 4.9) < 0 then         s := -1;       // candle-data       c := 50 - j - sin(int(i / 4) * 2.4 - 2.4) * (int(i / 4) * 2 - 2);       // apple-data       a := 50 - j - cos(int(i / 5) * 2.6) * int(i / 5) * 2.5;       // Compute color-data       if (I >= 8) and (i < 36) and (f * s < 0.8 - sin(i * 0.5 * pi) * 1.4) and         (f * s > -0.8 - abs(sin(i * 0.25 * pi) * 1.7)) then         cc := clyellow       else if (I >= 12) and (i < 40) and (abs(c) <= 1) then         cc := RGBToColor(trunc((c + 1) * 100), trunc((c + 1) * 100), 0)       else if (I >= 5) and (i < 45) and (abs(a) <= 0.1 +         sqrt(1 - sqr(i / 2.5 - int(i / 5) * 2 - 1)) * 2.5) then         cc := RGBToColor(trunc((a - i + int(i / 5) * 5 - 1.2) * 35), 0, 0)       else if abs(50 - j) > r then         cc := RGBToColor(trunc((1 - int(i / 25)) * abs(i - 25) * 5), trunc(           int(i / 25) * (128 + abs(i - 25) * 5)), trunc(           (1 - int(i / 25)) * 180 + abs(i - 25) * 3))       else         cc := RGBToColor(trunc(int(i / 40) * 128), trunc(((50 + r - j) / r) * 127), 0);       // draw pixel       image1.Canvas.Pixels[x, y] := cc;     end;   // Write Merry Xmas   image1.canvas.Font.Size := image1.Height div 8;   image1.Canvas.Brush.Style := bsClear;   image1.canvas.TextOut(image1.Height div 25, image1.Height div 2, 'Merry');   image1.canvas.TextOut(image1.Height div 3, (image1.Height * 4) div 5, 'Xmas'); end; end. ---------------------------------------------------------------------- BeniBela · 2015-12-24 12:37 ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎄 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎁 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎅 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 ☃ 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 🎄 ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆ and this is why you need proper Unicode support and not ucs-2 ---------------------------------------------------------------------- taazz · 2015-12-24 12:46 So we are doing ascii art now? ok here it is      ,;``',     ;      |     ;;. ;;,'      `"-'7'.                              _  /          |' >.                         .'` |\  -          | /  >.                   _\ /   /  |  -          '/  / ,`.  __..----.       .'  .'  /  _          ;  / /_.-'          \     /_.-`_.-'  \           ;' .'  '`           |  - `-.-'           |_/                .'   /   \_\_           _|  |_    .____.-'`         / __)`\          ( `  /\`'-...__.'  \        | '\(_.'|           `-\   \ `-'-'-'|   `.      -.  \(_./              \   \.-.-.  \     \___ /  >-'\_\               \   \  \ \  `/\  |_  '` /            _./\    \  ' | /    /_\ .-`          .' _.\'.   '.__.'    /`\`'   .-.---'\_/   `.`'-..____   ;   \  / / .--. |,     `'-._   /`'.|    |  `| /-' / / \         `.'    \   _/   '-'  '-' \ `-._            _,-' |             \    `'''----''''    /              >                _.'             / /`'-.._____..--'\ \            < \                / /             \ `.           .'  |___ mx           ___\_ `.        /__.-'   ``--..    ..--''`     `-.\      (___/`'--.._____)   (_____...--'`\___) ---------------------------------------------------------------------- Bart · 2015-12-24 14:35 Hint: frm_XmasMain.pas: unit FileUtil not used (Line 7)    Merry XMas and Happy Coding New Year. Bart ---------------------------------------------------------------------- jc99 · 2015-12-24 17:07 Quote from: Bart on December 24, 2015, 03:35:37 pmHint: frm_XmasMain.pas: unit FileUtil not used (Line 7)    Thanks, removed in 2nd version. Hope you enjoyed it a little. If someone has a good idea about the candle-flames, please step forward...   maybe also a better background . ---------------------------------------------------------------------- jwdietrich · 2015-12-24 17:33 This is the Mac-compatible version (OS X draws in onPaint events only): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit frm_XmasMain;{$mode objfpc}{$H+}interfaceuses  Classes, Forms, Graphics, ExtCtrls;type  { TfrmXmasMain }  TfrmXmasMain = class(TForm)    Image1: TImage;    procedure FormCreate(Sender: TObject);    procedure FormPaint(Sender: TObject);  end;var  frmXmasMain: TfrmXmasMain;implementation{$R *.lfm} { TfrmXmasMain } procedure TfrmXmasMain.FormPaint(Sender: TObject);var  I, J, R, f, c, a: extended;  x, y, s: integer;  cc: TColor;begin  // Create display-image  if not assigned(image1) then    begin      image1 := TImage.Create(self);      image1.Parent := self;      image1.Height := 400;      image1.Width := 640;    end;  // Render grafics  for Y := 0 to image1.Height - 1 do    for X := 0 to image1.Width - 1 do    begin      // Calc virtual coordinates      i := (y / image1.Height) * 50;    j := (x / image1.Width) * 80;      // Tree-radius      r := 0.1 + (i - int(i / 10) * 7) - int(i / 40) * (i - 31);      // flame-data      f := 50 - j - sin(int(i / 4) * 2.4) * int(i / 4) * 2;      s := 1;      if sin(int(i / 4) * 4.9) < 0 then        s := -1;      // candle-data      c := 50 - j - sin(int(i / 4) * 2.4 - 2.4) * (int(i / 4) * 2 - 2);      // apple-data      a := 50 - j - cos(int(i / 5) * 2.6) * int(i / 5) * 2.5;      // Compute color-data      if (I >= 8) and (i < 36) and (f * s < 0.8 - sin(i * 0.5 * pi) * 1.4) and        (f * s > -0.8 - abs(sin(i * 0.25 * pi) * 1.7)) then        cc := clyellow      else if (I >= 12) and (i < 40) and (abs(c) <= 1) then        cc := RGBToColor(trunc((c + 1) * 100), trunc((c + 1) * 100), 0)      else if (I >= 5) and (i < 45) and (abs(a) <= 0.1 +        sqrt(1 - sqr(i / 2.5 - int(i / 5) * 2 - 1)) * 2.5) then        cc := RGBToColor(trunc((a - i + int(i / 5) * 5 - 1.2) * 35), 0, 0)      else if abs(50 - j) > r then        cc := RGBToColor(trunc((1 - int(i / 25)) * abs(i - 25) * 5), trunc(          int(i / 25) * (128 + abs(i - 25) * 5)), trunc(        (1 - int(i / 25)) * 180 + abs(i - 25) * 3))      else        cc := RGBToColor(trunc(int(i / 40) * 128), trunc(((50 + r - j) / r) * 127), 0);      // draw pixel      image1.Canvas.Pixels[x, y] := cc;  end;  // Write Merry Xmas  image1.canvas.Font.Size := image1.Height div 8;  image1.Canvas.Brush.Style := bsClear;  image1.canvas.TextOut(image1.Height div 25, image1.Height div 2, 'Merry');  image1.canvas.TextOut(image1.Height div 3, (image1.Height * 4) div 5, 'Xmas');end; procedure TfrmXmasMain.FormCreate(Sender: TObject);begin  // Set Form Size ...  Height := 400;  Width := 640;  FormPaint(Sender);end; end.  Merry christmas and happy new year! Happy coding! ---------------------------------------------------------------------- Deepaak · 2015-12-24 18:57 Merry Christmas, and may this new year bring joy and laughter in everyone's life. To be happy is the greatest wish in life. Merry Christmas and Successful Coding New Year. Thank you all for everyone's support and love received in this forum. ---------------------------------------------------------------------- jc99 · 2015-12-25 05:37 Here comes rev. 4 With Better flames ... ( Formpaint now is called by the image1.onPaint event, hope it's still OS X compatible ) @jwdietrich: Thank you for your addition. Code: [Select]unit frm_XmasMain; {$mode objfpc}{$H+} interface uses   Classes, Forms, Graphics, ExtCtrls; type   { TfrmXmasMain }   TfrmXmasMain = class(TForm)     Image1: TImage;     procedure FormCreate(Sender: TObject);     procedure FormPaint(Sender: TObject);   end; var   frmXmasMain: TfrmXmasMain; implementation {$R *.lfm} { TfrmXmasMain } procedure TfrmXmasMain.FormPaint(Sender: TObject); var   I, J, R, f, fl, fh, c, a, gc, o: extended;   x, y, s: integer;   cc: TColor; begin   // Create display-image   if not assigned(image1) then   begin     image1 := TImage.Create(self);     image1.Parent := self;     image1.Height := 400;     image1.Width := 640;     image1.OnPaint := @FormPaint;   end;   // Render grafics   gc := sqrt(1.25) - 0.5;   o := sqrt(2);   for Y := 0 to image1.Height - 1 do     for X := 0 to image1.Width - 1 do     begin       // Calc virtual coordinates       i := (y / image1.Height) * 50;       j := (x / image1.Width) * 80;       // Tree-radius       r := 0.1 + (i - int(i / 10) * 7) - int(i / 40) * (i - 31);       // flame-data       f := gc * 80 - j - sin(int(i / 4) * gc * pi + o) * int(i / 4) * 2;       fh := 0.2 - sin(i * 0.5 * pi) * 1.1;       fl := -0.2 - abs(sin(i * 0.25 * pi) * 2.3);       s := 1;       if sin(int(i / 4) * 4.9) < 0 then         s := -1;       // candle-data       c := gc * 80 - j - sin(int(i / 4) * gc * pi - gc * pi + o) * (int(i / 4) * 2 - 2);       // apple-data       a := gc * 80 - j - cos(int(i / 5) * gc * pi + o) * int(i / 5) * 2.5;       // Compute color-data       if (I >= 8) and (i < 36) and (f * s < fh) and (f * s > fl) then         cc := RGBToColor(255, trunc((1 - (fh * 0.2 - fl * 0.2 - abs(f * s * 2 - fl - fh) * 0.2)) * 255), 0)       else if (I >= 12) and (i < 40) and (abs(c) <= 1) then         cc := RGBToColor(trunc((c + 1) * 100), trunc((c + 1) * 100), 0)       else if (I >= 5) and (i < 45) and (abs(a) <= 0.1 +         sqrt(1 - sqr(i / 2.5 - int(i / 5) * 2 - 1)) * 2.5) then         cc := RGBToColor(trunc((a - i + int(i / 5) * 5 + 6.2) * 35), 0, 0)       else if abs(gc * 80 - j) > r then         cc := RGBToColor(trunc((1 - int(i / (gc * 50))) *           abs(i - gc * 50) * 3), trunc(int(i / (gc * 50)) *           (128 + abs(i - gc * 50) * 5)), trunc(           (1 - int(i / (gc * 50))) * 160 + abs(i - gc * 50) * 3))       else         cc := RGBToColor(trunc(int(i / 40) * 128), trunc(           ((gc * 80 + r - j) / r) * 127), 0);       // draw pixel       image1.Canvas.Pixels[x, y] := cc;     end;   // Write Merry Xmas   image1.canvas.Font.Size := image1.Height div 8;   image1.Canvas.Brush.Style := bsClear;   image1.canvas.TextOut(image1.Height div 25, trunc(image1.Height * gc), 'Merry');   image1.canvas.TextOut(image1.Height div 3, (image1.Height * 7) div 9, 'Xmas'); end; procedure TfrmXmasMain.FormCreate(Sender: TObject); begin   // Set Form Size ...   Height := 400;   Width := 640;   FormPaint(Sender); end; end. ---------------------------------------------------------------------- jwdietrich · 2015-12-26 01:03 Thanks, it runs like a charm on Mac OS X. BTW, you should define the method FormPaint as handler of the onPaint event of the frmXmasMain form. ---------------------------------------------------------------------- jc99 · 2015-12-28 01:05 Quote from: jwdietrich on December 26, 2015, 02:03:34 amThanks, it runs like a charm on Mac OS X. BTW, you should define the method FormPaint as handler of the onPaint event of the frmXmasMain form. Then on WinDose-Systems the App stops to be responsive at all, because it triggers so many onPaint events. ---------------------------------------------------------------------- Ñuño_Martínez · 2015-12-28 11:22 Thanks, and Merry Christmas and that to you too! ---------------------------------------------------------------------- jwdietrich · 2015-12-28 23:56 Quote from: jc99 on December 28, 2015, 02:05:53 amQuote from: jwdietrich on December 26, 2015, 02:03:34 amThanks, it runs like a charm on Mac OS X. BTW, you should define the method FormPaint as handler of the onPaint event of the frmXmasMain form. Then on WinDose-Systems the App stops to be responsive at all, because it triggers so many onPaint events. Perhaps you could remove the onPaint handler from the Object Inspector again and insert in the lpr file after Application.CreateForm(TfrmXmasMain, frmXmasMain) and before Application.Run the following lines: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   {$IFDEF LCLcarbon}  frmXmasMain.OnPaint := @frmXmasMain.FormPaint;  {$ENDIF}