Forum > Graphics

Demoscene Square dot flag fx

(1/3) > >>

Gigatron:
Hi nice ladies and gentlements

I would like to share a nice fx from Amiga demoscene , dot flag fx from skid row cracktro ;

BGRA component used of course;
https://www.youtube.com/watch?v=h7XvL-wNjNY

Amiga Skid row:
https://www.youtube.com/watch?v=ajAlW2pMVHw

pascal code :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,  ComCtrls, StdCtrls, BGLVirtualScreen, BGRAOpenGL, BGRABitmap, BGRABitmapTypes,  uplaysound;  type   { TForm1 }     TForm1 = class(TForm)    BGLVirtualScreen1: TBGLVirtualScreen;    Button1: TButton;    Label1: TLabel;    playsound1: Tplaysound;    Timer1: TTimer;    TrackBar1: TTrackBar;    TrackBar2: TTrackBar;    TrackBar3: TTrackBar;    procedure BGLVirtualScreen1Redraw(Sender: TObject; BGLContext: TBGLContext);    procedure Button1Click(Sender: TObject);    procedure FormShow(Sender: TObject);    procedure Timer1Timer(Sender: TObject);      private     plasma : IBGLTexture;     public    var    ct, tval: integer;   end; var  Form1: TForm1;  implementation {$R *.lfm}  { TForm1 } procedure TForm1.FormShow(Sender: TObject);begin // plasma := BGLTexture('plasma9.jpg');end; procedure TForm1.BGLVirtualScreen1Redraw(Sender: TObject;   BGLContext: TBGLContext);var   i,j,p,r,x,y :integer;   rs,sx,sy : double;   col: TColor; begin   p := 0;  r := 0;   for i := 0 to 30 do     begin         r:=r +1;    for j:=0 to 20 do       begin        p:= p + TrackBar2.Position;        x:= i * 16  ;        y:= j * 16  ;         rs := sin((p+r+ct*(PI/180)*TrackBar3.Position)); // speed        sx :=   (TrackBar1.Position*rs);        sy :=   (TrackBar1.Position*rs);         sx := abs(sx);        sy := abs(sy);         x:=   round(x +  (110-sx)/2);        y:=   round(y +  (60-sy)/2);        col := RGBToColor( TrackBar2.Position div 2, TrackBar2.Position div 3,TrackBar2.Position div 4);        BGLContext.Canvas.fillrect(x,y,x+sx,y+sy, col);      //  BGLContext.Canvas.fillrect(x,y,x+sx-2 ,y+sy-2, RGBToColor(160,160,160));         end;  end; end; procedure TForm1.Button1Click(Sender: TObject);begin  playsound1.Execute;end; procedure TForm1.Timer1Timer(Sender: TObject);begin    ct := ct +1;    Label1.caption := IntToStr(TrackBar2.Position);    BGLVirtualScreen1.Repaint;end; end.  Enjoy and play !

TRon:
Nice, Gigatron !!

One of those routines that can be shaped and molded to do many things. I really should dust of some of my old stuff.

Do note that it took a lot less time with the copper and blitter to realize then what is shown in code here  :P

I took the liberty to get things going with ptcpas and toyed with it (only) a little.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program squaring; {$mode objfpc}{$h+} {.$define draw_tile_as_rectangle}{$define draw_tile_as_circle} uses  {$ifdef linux}  cthreads,  {$endif}  classes,  sysutils, fptimer,  ptccrt, ptcgraph; {$if sizeof(colortype) = 4}  {$define FPC_GRAPH_SUPPORTS_TRUECOLOR}{$endif}  type  TEvents = object    procedure DoTimer(Sender: TObject);  end; const  FPS_TO_AIM_FOR   = 50; // 25; const  TILES_SPEED      =   4;                   // 0..16  TILES_SQUARESIZE =  32;  TILES_SKIPDELAY  = 100; // 7;             // 5..255  TILES_COLCOUNT   =  40;  TILES_ROWCOUNT   =  10;  TILES_AMP        = TILES_SQUARESIZE - 2;  // 10..20   // dirty dimensions  XOFS   = 20;  YOFS   = 20;  WIDTH  = TILES_COLCOUNT * TILES_SQUARESIZE;  HEIGHT = TILES_ROWCOUNT * TILES_SQUARESIZE;  var  Events     : TEvents;  Timer      : TFPTimer;  framecount : integer = 0;  procedure Render;var  i,j,p,r,x,y : integer;  rs,sx,sy : double;  col : Colortype;  cc : byte;begin  p := 0;  r := 0;   for i := 0 to TILES_COLCOUNT-1 do  begin    r := r + 1;     for j := 0 to TILES_ROWCOUNT-1 do    begin      p := p + TILES_SKIPDELAY;      x := i * TILES_SQUARESIZE;      y := j * TILES_SQUARESIZE;       rs := sin((p+r+framecount*(PI/180)*TILES_SPEED)); // speed      sx := TILES_AMP*rs;      sy := TILES_AMP*rs;       sx := abs(sx);      sy := abs(sy);       x := XOFS + round(x + (TILES_AMP-sx)/2);      y := YOFS + round(y + (TILES_AMP-sy)/2);       {$ifdef FPC_GRAPH_SUPPORTS_TRUECOLOR}      cc  := round(sy * 255 / TILES_AMP);      col := cc shl 16 + cc shl 8 + cc shl 0;      {$else}      // TODO:      // col := index to palette      {$endif}       {$if defined(draw_tile_as_rectangle)}      SetColor(col);      Rectangle(x,y,round(x+sx),round(y+sy));      {$elseif defined(draw_tile_as_circle)}      SetColor(col);      Circle(x + TILES_AMP shr 1, y + TILES_AMP shr 1, round(sx/2));      {$else}      SetFillStyle(SolidFill, col);      Bar(x,y,round(x+sx),round(y+sy));      {$endif}    end;  end;end;  procedure TEvents.DoTimer(Sender: TObject);const  ActivePage : integer = 1;begin  inc(framecount);   // Swap buffers  ActivePage := 1 - ActivePage;  SetActivePage(ActivePage);   // Clear buffer and render view  ClearDevice;  Render;   // Update view  SetVisualPage(ActivePage);end;  procedure CheckGraphResult;var  ErrorCode: Integer;begin  ErrorCode := GraphResult;  if ErrorCode <> grOk then  begin    CloseGraph;    Writeln(ErrorCode, ': ', GraphErrorMsg(ErrorCode));    Readln;    Halt(1);  end;end;  procedure GfxModeInfo;var  n     : smallint;  color : RGBRec;begin  writeln('BGColor      = ', GetBkColor);  writeln('FGColor      = ', GetColor);  writeln('PaletteSize  = ', GetPaletteSize);  writeln('DirectVideo  = ', GetDirectVideo);  writeln('DriverName   = ', GetDriverName);  writeln('maxColor     = ', GetMaxColor);  writeln('GraphMode    = ', GetGraphMode);  writeln('ModeName     = ', GetModeName(GetGraphMode));   // info on some random colors  for n := 0 to 9 do  begin    GetRGBPalette(n, color.Red, color.Green, color.Blue);    writeln('$', color.Red.ToHexString, '.', color.Green.ToHexString, '.', color.Blue.ToHexString);  end;end;  var  gd, gm: smallint;begin  gd := detect;  gm := 0;   InitGraph(gd,gm,'');  CheckGraphResult;   {$ifndef FPC_GRAPH_SUPPORTS_TRUECOLOR}  // TODO: set palette  SetRGBPalette(1, $FF, $0, $0);  CheckGraphResult;  {$endif}  GfxModeInfo;   writeln('Effect:');  writeln('PixelWidth  = ', WIDTH);  writeln('PixelHeight = ', HEIGHT);  writeln;   Timer := TFPTimer.Create(nil);  Timer.Enabled        := false;  Timer.UseTimerThread := true;  Timer.Interval       := round(1000 / FPS_TO_AIM_FOR);  Timer.OnTimer        := @Events.DoTimer;  Timer.Enabled        := true;   // let Timer do its job and wait for user intervention  repeat    delay(10);  until keypressed;   Timer.Free;   CloseGraph;end. 

Gigatron:
Thank you Tron for the code which gives infinite ideas and possibilities.
I'm just giving the code which is similar to the Skid Row cracktro, of course the program is not optimized and made as simply as possible in order to help anyone who would like to code effects :)


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,  ComCtrls, StdCtrls, BGLVirtualScreen, BGRAOpenGL, BGRABitmap, BGRABitmapTypes,  uplaysound;  type   { TForm1 }     TForm1 = class(TForm)    BGLVirtualScreen1: TBGLVirtualScreen;    Button1: TButton;    Label1: TLabel;    playsound1: Tplaysound;    circle_radio: TRadioButton;    sq_radio: TRadioButton;    Timer1: TTimer;    TrackBar1: TTrackBar;    TrackBar2: TTrackBar;    TrackBar3: TTrackBar;    procedure BGLVirtualScreen1Redraw(Sender: TObject; BGLContext: TBGLContext);    procedure Button1Click(Sender: TObject);    procedure Timer1Timer(Sender: TObject);      private     public    var    ct, tval: integer;    shape_type: integer;   end; var  Form1: TForm1;  implementation {$R *.lfm}  { TForm1 } procedure TForm1.BGLVirtualScreen1Redraw(Sender: TObject;   BGLContext: TBGLContext);var   i,j,p,r,x,y :integer;   rs,sx,sy : double;  begin   p := 0;  r := 0;   for i := 0 to 14 do  begin        r:=r +1;    for j:=0 to 11 do       begin        p:= p + TrackBar2.Position;        x:= i * 32  ;        y:= j * 32  ;         rs := sin((p+r+ct*(PI/180)*TrackBar3.Position)); // speed        sx :=   (TrackBar1.Position*rs);        sy :=   (TrackBar1.Position*rs);         sx := abs(sx);        sy := abs(sy);         x:=   round(x +  (120-sx)/2);        y:=   round(y +  (54-sy)/2);         if(shape_type=1) then begin          BGLContext.Canvas.fillrect(x,y,x+sx,y+sy, RGBToColor(0,220,255 ));          BGLContext.Canvas.fillrect(x+2,y+2,x+sx-2,y+sy-2, RGBToColor(0,110,255 ));        end;         if(shape_type=2) then begin         BGLContext.Canvas.Arc(x,y,sx / 3,sy/ 3,0,360, RGBToColor(0,180,255 ),true,RGBToColor(0,110,255 ));        end;         end;  end; end; procedure TForm1.Button1Click(Sender: TObject);begin  playsound1.Execute;end; procedure TForm1.Timer1Timer(Sender: TObject);begin    ct := ct +1;    Label1.caption := IntToStr(TrackBar2.Position);    BGLVirtualScreen1.Repaint;    if(sq_radio.Checked) then shape_type := 1;    if(circle_radio.Checked) then shape_type := 2; end; end.  

circular:
Hi Gigatron,

In the Skid Row demo, it seems to me that it is a gradient.

You can do something similar like this (not tested):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses BGRAGradientScanner; procedure TForm1.BGLVirtualScreen1Redraw(Sender: TObject;   BGLContext: TBGLContext);var   i,j,p,r,x,y :integer;   rs,sx,sy : double;   grad: TBGRACustomGradient; begin   p := 0;  r := 0;  grad := TBGRAMultiGradient.Create([CSSDodgerBlue, CSSBlue, CSSLightGray],       [0, 0.4, 1], grPad);   for i := 0 to 14 do  begin        r:=r +1;    for j:=0 to 11 do       begin        p:= p + TrackBar2.Position;        x:= i * 32  ;        y:= j * 32  ;         rs := sin((p+r+ct*(PI/180)*TrackBar3.Position)); // speed        sx :=   (TrackBar1.Position*rs);        sy :=   (TrackBar1.Position*rs);         sx := abs(sx);        sy := abs(sy);         x:=   round(x +  (120-sx)/2);        y:=   round(y +  (54-sy)/2);         if(shape_type=1) then begin          BGLContext.Canvas.fillrect(x,y,x+sx,y+sy, grad.GetColorAtF((i+j)/(14+11)));        end;         if(shape_type=2) then begin         BGLContext.Canvas.Arc(x,y,sx / 3,sy/ 3,0,360, RGBToColor(0,180,255 ),true,RGBToColor(0,110,255 ));        end;         end;  end;  grad.Free; end;

TRon:

--- Quote from: circular on April 15, 2024, 09:00:28 am ---In the Skid Row demo, it seems to me that it is a gradient.

--- End quote ---
That is indeed correct.

Seems they used the copper for that (hence why the squares have a certain width) to draw the squares from dark (left top) to light (bottom right) though the effect seem to "overlap" a little (seem to be static but could be made to animate as well for extra wow factor).

Navigation

[0] Message Index

[#] Next page

Go to full version