Recent

Author Topic: FX Glow  (Read 10859 times)

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: FX Glow
« Reply #15 on: January 08, 2016, 08:40:18 am »
Very good User137.
More than answer it is interesting to me that you without knowing BGRA attempt to solving this problem and kind of done it.
Thanks.
you should see some of his game demo's very cool
Where?  :-\

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: FX Glow
« Reply #16 on: January 08, 2016, 09:09:19 am »
How did this stray to me?  :)

This is my youtube playlist for programming content https://www.youtube.com/playlist?list=PLraemX84dJwUgp9IcXUS0U4lvdwLFumA7

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: FX Glow
« Reply #17 on: January 08, 2016, 09:38:44 am »
How did this stray to me?  :)

This is my youtube playlist for programming content https://www.youtube.com/playlist?list=PLraemX84dJwUgp9IcXUS0U4lvdwLFumA7
Aha nxPascal! I remember working with it. User137 helped me a lot in networking and for the record nxPascal has a good network unit and example.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: FX Glow
« Reply #18 on: February 04, 2016, 08:39:54 am »
Can we have this glow effect officially in BGRABitmap?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: FX Glow
« Reply #19 on: February 04, 2016, 08:22:31 pm »
Hmmm.. I am not sure where to start. I would not want to make something to restrictive, and at the same time, I am not sure how to forsee all cases.
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: FX Glow
« Reply #20 on: February 05, 2016, 10:00:21 pm »
I understand but PS version can be a good point for start but what your call.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: FX Glow
« Reply #21 on: February 05, 2016, 10:02:40 pm »
Well it seems PS glow has a lot of options!
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: FX Glow
« Reply #22 on: February 05, 2016, 11:34:02 pm »
 :D You are right  but if it was on me I choose Outer glow with structure options for know  :P

Sanem

  • Full Member
  • ***
  • Posts: 173
Re: FX Glow
« Reply #23 on: February 09, 2016, 03:04:47 pm »
Hi
I wrote 2 different methods to make outer glow like Photoshop in BGRABitmap, now i wanna apply glow around any shape(colorful pixels) in a bgrabitmap, any idea?!
thanks alot.

Quote
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   BGRABitmap, BGRABitmapTypes, Math, LCLIntf;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Button2: TButton;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure Button2Click(Sender: TObject);
  20.     procedure FormCreate(Sender: TObject);
  21.   private
  22.     { private declarations }
  23.   public
  24.     { public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.Button1Click(Sender: TObject);
  37. var
  38.   x, y, midLine, t1, t2: integer;
  39.   C, N, dx, dy: single;
  40.   cb: byte;
  41.   sky: TBGRABitmap;
  42. begin
  43.   sky := TBGRABitmap.Create(Width, Height, BGRA(0, 0, 0));
  44.   t1 := GetTickCount;
  45.   midLine := 512 div 2;
  46.   N := 4;
  47.   for y := 0 to midLine do
  48.   begin
  49.     for X := 0 to midLine do
  50.     begin
  51.       dx := X / (midLine);
  52.       dy := Y / (midLine);
  53.       C := 1 - sqrt(dx * dx + dy * dy);
  54.       if C < 0 then
  55.         C := 0;
  56.       C := power(C, N);
  57.       cb := round(C * 255);
  58.       if cb > 0 then
  59.       begin
  60.         sky.SetPixel(midLine - x, midLine - y, BGRA(cb, cb, cb));
  61.         sky.SetPixel(midLine + x + 1, midLine - y, BGRA(cb, cb, cb));
  62.         sky.SetPixel(midLine - x, midLine + y + 1, BGRA(cb, cb, cb));
  63.         sky.SetPixel(midLine + x + 1, midLine + y + 1, BGRA(cb, cb, cb));
  64.       end;
  65.     end;
  66.   end;
  67.   t2 := GetTickCount;
  68.   Form1.Caption := IntToStr(t2 - t1);
  69.   sky.Draw(Canvas, 0, 0, False);
  70.   sky.Free;
  71. end;
  72.  
  73. procedure TForm1.Button2Click(Sender: TObject);
  74. var
  75.   bmp: TBGRABitmap;
  76.   tt: integer;
  77.  
  78.   procedure Glow(AR, AX, AY: integer;AColor:TBGRAPixel);
  79.   var
  80.     x, y: integer;
  81.     dx, dy, dc: single;
  82.     p: PBGRAPixel;
  83.     a:byte;
  84.   begin
  85.     for y := MAX(AY - AR,0) to MIN(AY + AR,bmp.Height) - 1 do
  86.     begin
  87.       p := bmp.Scanline[y];
  88.       dy := abs(AR - y) / AR;
  89.       for x := MAX(AX - AR,0) to MIN(AX + AR,bmp.Height) - 1 do
  90.       begin
  91.         dx := abs(AR - x) / AR;
  92.         dc := power(1 - sqrt(dx * dx + dy * dy), 4);
  93.         a := round(dc * 255);
  94.         p^:=AColor;
  95.         p^.alpha := a;
  96.         Inc(p);
  97.       end;
  98.     end;
  99.     bmp.InvalidateBitmap;
  100.   end;
  101.  
  102. begin
  103.   bmp := TBGRABitmap.Create(Width, Height, BGRABlack);
  104.   tt := GetTickCount;
  105.   Glow(256, 256, 256,BGRA(255, 255, 190));
  106.   Caption := IntToStr(GetTickCount - tt);
  107.   bmp.Draw(Canvas, 0, 0,False);
  108.   bmp.Free;
  109. end;
  110.  
  111. procedure TForm1.FormCreate(Sender: TObject);
  112. begin
  113.  
  114. end;
  115.  
  116. end.
  117.  

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: FX Glow
« Reply #24 on: February 09, 2016, 04:08:01 pm »
What is your purpose with it, making a drawing program? Special effects like these are very slow to draw, so they should be pre-drawn into picture files if possible.

Is this kind of glow more what you are after? First draw the objects in a temporary image and apply strong blur to it (in gimp i use gaussian blur). Then draw the blurred image in main screen and the sharp object on top.

Sanem

  • Full Member
  • ***
  • Posts: 173
Re: FX Glow
« Reply #25 on: February 15, 2016, 09:15:29 am »
Thank you for your response
I want do this with glow, because i tested blur and the result was different, i think its possible with considering  the difference between color of the pixels to apply glow around any colorful shape in a bgrabitmap. any idea?!

 

TinyPortal © 2005-2018