[Gambas-user] Gradient smoothing?

Benoît Minisini gambas at ...1...
Wed Sep 3 17:43:59 CEST 2014


Le 03/09/2014 08:35, Татьяна Шаповалова a écrit :
>
> Dear Benot Minisini !
>
> I like your Gambas project, but shortage of documentation on some functions creates small problems.
>   For example the realized function (Fill.Gradient = Vertical) - works with Fill.Gradient remarkably, but there is no function
> smoothing of roughnesses (this function is realized in  Visual Basic Net,
> it is effective for development of user control).
> To my regret - I didn't find this function in "Gambas".
>
> Private  Sub  ShowPensAndSmoothingMode(ByVal  eAs  PaintEventArgs)
>
>      ' Set the SmoothingMode property to smooth the line.
>      e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
>
>      ' Create a new Pen object.
>      Dim  greenPenAs  New  Pen(Color.Green)
>
>      ' Set the width to 6.
>      greenPen.Width = 6.0F
>
>      ' Set the DashCap to round.
>      greenPen.DashCap = Drawing2D.DashCap.Round
>
>      ' Create a custom dash pattern.
>      greenPen.DashPattern =New  Single() {4.0F, 2.0F, 1.0F, 3.0F}
>
>      ' Draw a line.
>      e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F)
>
>      ' Change the SmoothingMode to none.
>      e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None
>
>      ' Draw another line.
>      e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F)
>
>      ' Dispose of the custom pen.
>      greenPen.Dispose()
> End  Sub
>
>
>
> http://msdn.microsoft.com/ru-ru/library/system.drawing.graphics.smoothingmode(v=vs.90).aspx
>
>
>
> Dmitry Klishin

Use Paint.AntiAlias for that.

Beware that it has no effect on drawing fonts, and that coordinates do 
not translate to the same pixel(s) in both mode.

With antialiasing on, (X,Y) points between pixels (four pixels are 
concerned), whereas with antialiasing off, it points directly inside the 
pixel (only one pixel is concerned).

If you are not aware of that, draw a single point and use a magnify 
program to see what that means (for example KMag).

Regards,

-- 
Benoît Minisini




More information about the User mailing list