Why does the LinearGradientBrush.WrapMode to Clamp parameter not work with ArgumentException (parameter is not valid)?

Here is an example:

public MainForm()
    {
        InitializeComponent();

          LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0,0,100,100),Color.Blue, Color.White,angle:0);
          brush.WrapMode = WrapMode.Tile; // OK
          brush.WrapMode = WrapMode.Clamp; // Causes Unhandled exception alert, offering break
    }

In the VS2008 output window, this shows:

The first exception of type "System.ArgumentException" has appeared in System.Drawing.dll Additional information: The parameter is not valid.

(pic http://i.imgur.com/nM2oNm1.png )

This is on Windows 7.

The documentation is here https://msdn.microsoft.com/en-us/library/vstudio/system.drawing.drawing2d.lineargradientbrush.wrapmode(v=vs.90).aspx

confirms that LinearGradientBrush.WrapMode accepts WrapMode

"Gets or sets the WrapMode enumeration that indicates the wrapping mode for this LinearGradientBrush."

https://msdn.microsoft.com/en-us/library/vstudio/system.drawing.drawing2d.wrapmode(v=vs.90).aspx

, WrapMode.Clamp :

" ."

+4
1

VS2015 Windows 8.1.

, Clamp .. , , .

InterpolationColors, .

. espcially InterpolationColors

: Lars : LinearGradientBrush, TextureBrush..

+1

Source: https://habr.com/ru/post/1612338/


All Articles