Recent

Author Topic: Demo Scene BGRA Circle Demo  (Read 789 times)

Gigatron

  • Jr. Member
  • **
  • Posts: 78
  • Amiga Rulez !!
Demo Scene BGRA Circle Demo
« on: May 27, 2024, 08:40:46 pm »
Hi,

This is my fast coding from zero to 100 in less than 20 minutes ; Learning BGRA on progress;

State of the art is demo on Amiga made by Spaceballs there is a nice fx on begining with the circles ;
This code (60 lines ) reproduce this fx not yet perfect with math ;

https://www.youtube.com/watch?v=5aXsrYI3S6g&t=37s

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  17.     Timer1: TTimer;
  18.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  19.     procedure Timer1Timer(Sender: TObject);
  20.   private
  21.  
  22.   public
  23.  
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.   angle : single;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.Timer1Timer(Sender: TObject);
  37. begin
  38.       BGRAVirtualScreen1.RedrawBitmap;
  39. end;
  40.  
  41. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  42. var
  43.   i : integer;
  44. begin
  45.       i:=0;
  46.       for i:=0 to 29 do
  47.       begin
  48.         Bitmap.Ellipse(320+80*sin(-angle),220+40*cos(-angle),20+i*20, 20+i*20,BGRA($09,$7E,$00),10 ,dmSet);
  49.        end;
  50.  
  51.       for i:=0 to 33 do
  52.       begin
  53.         Bitmap.Ellipse(580,220+140*cos(angle*1.5),20+i*20, 20+i*20,BGRA($7d,$00,$4e),10 ,dmSet); // This is now correct !
  54.       end;
  55.      angle := angle + PI/180;        
  56. end;
  57. end.
  58.  
« Last Edit: May 27, 2024, 08:47:55 pm by Gigatron »
Sub Quantum Technology ! We are in a micro universe.

circular

  • Hero Member
  • *****
  • Posts: 4276
    • Personal webpage
Re: Demo Scene BGRA Circle Demo
« Reply #1 on: May 28, 2024, 05:52:21 pm »
You can try dmXor instead of dmSet to combine the colors when they intersect.
Conscience is the debugger of the mind

Gigatron

  • Jr. Member
  • **
  • Posts: 78
  • Amiga Rulez !!
Re: Demo Scene BGRA Circle Demo
« Reply #2 on: May 28, 2024, 06:45:42 pm »
You can try dmXor instead of dmSet to combine the colors when they intersect.
Nice , thank you Circular ;
Just added draw mode Xor and it's working well; you can now play with different parameters of circles ;

* Edit a bit optimized code V0.6 :

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  9.   Spin, BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  17.     ColorButton1: TColorButton;
  18.     ColorButton2: TColorButton;
  19.     ComboBox1: TComboBox;
  20.     GroupBox1: TGroupBox;
  21.     SpinEdit1: TSpinEdit;
  22.     SpinEdit2: TSpinEdit;
  23.     Timer1: TTimer;
  24.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  25.     procedure ComboBox1Change(Sender: TObject);
  26.     procedure FormCreate(Sender: TObject);
  27.     procedure Timer1Timer(Sender: TObject);
  28.   private
  29.   public
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.   angle : single;
  35.   space,wdt,dmode : integer;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. { TForm1 }
  42.  
  43. procedure TForm1.FormCreate(Sender: TObject);
  44. begin
  45.   space := 12;
  46.   wdt   := 24;
  47.   dmode :=  0;    // draw mode !
  48. end;
  49.  
  50. procedure TForm1.Timer1Timer(Sender: TObject);
  51. begin
  52.       angle := angle + PI/180;
  53.       space := SpinEdit1.Value;
  54.       wdt   := SpinEdit2.Value;
  55.       BGRAVirtualScreen1.RedrawBitmap;
  56. end;
  57.  
  58. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  59. var
  60.   i : integer;
  61.   drawMode: TDrawMode;
  62.   sinAngle, cosAngle, cosAngle2: single;
  63.   col1, col2: TColor;
  64. begin
  65.  
  66.       if dmode=0 then drawMode:=  dmSet
  67.       else
  68.       drawMode := dmXor;
  69.       sinAngle := sin(angle * 0.6);
  70.       cosAngle := cos(-angle * 2);
  71.       cosAngle2 := cos(angle * 1.5);
  72.       col1 := TColor(ColorButton2.ButtonColor);
  73.       col2 := TColor(ColorButton1.ButtonColor);
  74.       for i:=0 to 34 do
  75.       begin
  76.         Bitmap.Ellipse(320+300*sinAngle,220+120*cosAngle,1+i*wdt, 1+i*wdt,col1,space ,drawMode);
  77.       end;
  78.       for i:=0 to 34 do
  79.       begin
  80.         Bitmap.Ellipse(560,220+140*cosAngle2,1+i*wdt, 1+i*wdt,col2,space ,drawMode);
  81.       end;
  82. end;
  83.  
  84. procedure TForm1.ComboBox1Change(Sender: TObject);
  85. begin
  86.       dmode := ComboBox1.ItemIndex;
  87. end;
  88.  
  89. end.
  90.  
  91.  

« Last Edit: May 28, 2024, 09:01:44 pm by Gigatron »
Sub Quantum Technology ! We are in a micro universe.

circular

  • Hero Member
  • *****
  • Posts: 4276
    • Personal webpage
Re: Demo Scene BGRA Circle Demo
« Reply #3 on: May 28, 2024, 11:36:37 pm »
Love it  :)
Conscience is the debugger of the mind

Gigatron

  • Jr. Member
  • **
  • Posts: 78
  • Amiga Rulez !!
Re: Demo Scene BGRA Circle Demo
« Reply #4 on: May 29, 2024, 12:09:41 am »
Thank you,

All this is becoming reality thanks to your work on the BGRA component, and the Lazarus Fpc team;
Sub Quantum Technology ! We are in a micro universe.

 

TinyPortal © 2005-2018