Recent

Author Topic: Spiral with BGRA  (Read 5085 times)

BobDog

  • Sr. Member
  • ****
  • Posts: 394
Re: Spiral with BGRA
« Reply #15 on: October 16, 2020, 09:28:02 pm »

Back to the console in Win 10.
Code: Pascal  [Select][+][-]
  1.  
  2.  
  3. program spiralrainbow;
  4.  
  5. uses
  6.  Windows,crt;
  7.  
  8.     const
  9.     DC_BRUSH=18;
  10.     const
  11.     DC_PEN=19;
  12.     const
  13.     pi=3.141592653589793;
  14.     var
  15.     m:array[1 .. 7] of ansistring =('Robin','of   ','York ','goes ','back ','in   ','vain ');
  16.      p:hwnd;
  17.      h:hdc;
  18.  
  19.   function SetDCBrushColor(p:hdc;colour:COLORREF): COLORREF; stdcall external 'gdi32.dll' name 'SetDCBrushColor';
  20.   function SetDCPenColor(p:hdc;colour:COLORREF): COLORREF; stdcall external 'gdi32.dll' name 'SetDCPenColor';
  21.   function Printf(mask : pchar):integer; cdecl; varargs; external 'msvcrt.dll' name 'printf';
  22.  
  23.    function rgb(r:word;g:word;b:word) :longword;
  24.    begin
  25.    exit(((b Shl 16) Or ((g) Shl 8) Or (r) Or $FF000000)- $FF000000)
  26.    end;
  27.  
  28.    function rainbow( x:single ):longword ;
  29.     var
  30.     r,g,b:word;
  31.   begin
  32.    r := trunc(sin( (pi/180)*(x) ) * 127 + 128)  ;
  33.    g := trunc(sin( (pi/180)*(x -120) ) * 127 + 128)  ;
  34.    b := trunc(sin( (pi/180)*(x + 120) ) * 127 + 128) ;
  35.   exit (rgb( r and 255 , g and 255 , b and 255 ));
  36.   end;
  37.  
  38.  procedure hidecursor();
  39.  var
  40.     consoleHandle:handle;
  41.      info:CONSOLE_CURSOR_INFO ;
  42.      begin
  43.      consolehandle := GetStdHandle(STD_OUTPUT_HANDLE);
  44.      info.dwSize := 100;
  45.      info.bVisible := FALSE ;
  46.      SetConsoleCursorInfo(consoleHandle, @info);
  47.      End;
  48.  
  49. procedure spiral(h:hdc;col:longword;col2:longword);
  50. label
  51. start;
  52. var
  53. z,rad,x,y,dd,slug,lastslug:single;
  54. i:integer;
  55. begin
  56. SelectObject(h,GetStockObject(DC_BRUSH));
  57. SelectObject(h,GetStockObject(DC_PEN));
  58. rad:=0.0;
  59. dd:=2.0;
  60. z:=0.0;
  61. slug:=0;
  62. lastslug:=0;
  63. i:=6;
  64.  start:
  65.  if lastslug>2*pi then lastslug:=0;
  66.  if lastslug = 0  then
  67.  begin
  68.  if i=7 then i:=0;
  69.  i+=1;
  70.  gotoxy(21,6);
  71.  printf('%s',pchar(m[i]));
  72.  end;
  73. rad:=0;
  74. z:=slug;
  75. repeat
  76. SetDCpenColor(h,rainbow(z*8));
  77. SetDCBrushColor(h,rainbow(z*8));
  78. z+=0.01;
  79. rad+=0.05;
  80. x:=400+rad*cos(z);
  81. y:=270-rad*sin(z);
  82. ellipse(h,trunc(x-dd),trunc(y-dd),trunc(x+dd),trunc(y+dd));
  83. until z>15*pi+slug ;
  84. slug:=slug+0.2;
  85. lastslug:=lastslug+0.2;
  86. goto start;
  87. end;
  88.  
  89.     begin
  90.     p := GetConsoleWindow();
  91.     setwindowpos(p, HWND_TOPMOST, 100, 100, 800, 600, SWP_SHOWWINDOW);
  92.     hidecursor;
  93.     h:=GetDC(p);
  94.     spiral(h,rgb(10,10,200),rgb(200,40,10));
  95.     end.
  96.  
  97.  

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Spiral with BGRA
« Reply #16 on: October 16, 2020, 09:32:39 pm »
Hi!

Do you have a version for the  Linux console?

I have not  got Win10.
And I don't want it.

Winni

BobDog

  • Sr. Member
  • ****
  • Posts: 394
Re: Spiral with BGRA
« Reply #17 on: October 16, 2020, 09:57:05 pm »

I don't have Linux, sorry.

Fred vS

  • Hero Member
  • *****
  • Posts: 3945
    • StrumPract is the musicians best friend
Re: Spiral with BGRA
« Reply #18 on: October 16, 2020, 10:04:48 pm »
Hi!

Do you have a version for the  Linux console?

I have not  got Win10.
And I don't want it.

Winni

If you have wine installed it works.
Included in attachment the binary executable.

To run it:
Code: Pascal  [Select][+][-]
  1. $ wine conspiral.exe


To stop it:
Code: Pascal  [Select][+][-]
  1. $ killall conspiral.exe


@BobDog: Hyper WOW, I did not know that it was possible with a so litle exe :  45 k !

« Last Edit: October 16, 2020, 10:08:09 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

anyone

  • Guest
Re: Spiral with BGRA
« Reply #19 on: October 17, 2020, 02:41:28 am »

Back to the console in Win 10.

Looks fun... I call it spiralcui (character user interface).



winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Spiral with BGRA
« Reply #20 on: October 17, 2020, 11:21:59 am »
Hi!

I started the conspiral.exe with wine.
Wine has some different ideas how to handle it:

* It is not started in a console but on the desktop
* Whatever you do: It stays on top of all other apps
* It stays on top of all of my 4 virtual desktops.

A little bit annoying is that you can't move the spiral.
And  that you have to kill the process.

But anyway: nice.

Screenshot attached.

Winni

Fred vS

  • Hero Member
  • *****
  • Posts: 3945
    • StrumPract is the musicians best friend
Re: Spiral with BGRA
« Reply #21 on: October 17, 2020, 12:52:18 pm »
Hi!

I started the conspiral.exe with wine.
Wine has some different ideas how to handle it:

* It is not started in a console but on the desktop
* Whatever you do: It stays on top of all other apps
* It stays on top of all of my 4 virtual desktops.

A little bit annoying is that you can't move the spiral.
And  that you have to kill the process.

But anyway: nice.

Screenshot attached.

Winni

Hello.

Yes, it seems that wine translated the exe into direct X11 access, without using the window manager.
I dont have a real Windows machine to test it, maybe under Windows it uses the Windows-window-manager.

The result is great but I dont see how to use it in real life.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

anyone

  • Guest
Re: Spiral with BGRA
« Reply #22 on: October 17, 2020, 01:50:43 pm »

I dont have a real Windows machine to test it, maybe under Windows it uses the Windows-window-manager.


Yes, it runs under my Windows 10 as a new command-prompt window (console window with black background), not on the desktop GUI itself.

 

TinyPortal © 2005-2018