Recent

Author Topic: Subject: How to implement "MidPoint color" concept in gradient in photoshop, Usi  (Read 3478 times)

Sanem

  • Full Member
  • ***
  • Posts: 168
HI
I wanna implement the midpoint concept in Photoshop gradient using BGRA gradinet, as you can see in Screenshots attached (Left one is Photoshop gradinet for midpoint in its default position which is 50% and right one is the midpoint in 20% of the left color), the concept of midpoint in Photoshop is that we can change the location of the midpoint by dragging the icon closer to one color or the other. For example, when I drag it towards the left so it's closer to green stop. Notice the effect it's had on the gradient. With the midpoint now closer to green, I've shortened the transition area between green and the midpoint, and lengthened the transition between the midpoint and red.
it is not something i can implement by adding a middle point (a new color and a new position) in BGRA gradinet method, any idea how to implement this concept using BGRA gradinet methods?? Any idea??
(This question was raised first time in the thread:
http://forum.lazarus.freepascal.org/index.php/topic,31536.msg209491.html#msg209491
and I wanted to continue it in a new topic for gaining more idea or help and to be seen as a new topic generally.)

Any help appreciated prior
Regards

Here is my code for drawing the gradinet:

Code: Pascal  [Select][+][-]
  1.  
  2. unit Unit1;
  3.  
  4. {$mode objfpc}{$H+}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
  10.   BGRABitmap, BGRABitmapTypes, BGRAGradients, BGRAGradientScanner, BGRAResample;
  11.  
  12. type
  13.  
  14.   { TForm1 }
  15.  
  16.   TForm1 = class(TForm)
  17.     procedure FormPaint(Sender: TObject);
  18.   private
  19.   public
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30. procedure TForm1.FormPaint(Sender: TObject);
  31. var
  32.   bmp: TBGRABitmap;
  33.   p1, p2: TPointF;
  34.   g: TBGRAMultiGradient;
  35.   gs: TBGRAGradientScanner;
  36. begin
  37.   bmp := TBGRABitmap.Create(Width, Height, clWhite);
  38.   p1 := PointF(0, Height / 2);
  39.   p2 := PointF(Width, Height / 2);
  40.   g := TBGRAMultiGradient.Create([BGRA(0, 0, 255), BGRA(0, 255, 0), BGRA(255, 0, 0)], [0, 0.5, 1], True, False);
  41.   g.InterpolationFunction := @g.CosineInterpolation;
  42.   gs := TBGRAGradientScanner.Create(g, gtLinear, p1, p2);
  43.   BGRASetGamma(1.45);
  44.   bmp.FillRectAntialias(0, 0, Width, Height, gs);
  45.   bmp.SaveToFile('Pics\BGRA_50%.png');
  46.   bmp.Draw(Canvas, 0, 0);
  47.   bmp.Free;
  48. end;
  49.  
  50. end.
  51.  
  52.  
« Last Edit: August 01, 2016, 10:23:00 am by simin_sh »
Lazarus trunk 2.1.0, FPC 3.3.1
Windows 10 64x, macOS Catalina 10.15, Linux Zorin 15.2 - Manjaro

lainz

  • Hero Member
  • *****
  • Posts: 3854
Seems that you're making a photoshop clone or something like that! :)

Sanem

  • Full Member
  • ***
  • Posts: 168
Seems that you're making a photoshop clone or something like that! :)


Not really, I just was working on graphic related concepts ;) 
Lazarus trunk 2.1.0, FPC 3.3.1
Windows 10 64x, macOS Catalina 10.15, Linux Zorin 15.2 - Manjaro

 

TinyPortal © 2005-2018