Otherwise, to equally space three colors, you'd set that parameter to an array with the values 0, 0.5, and 1. The array of float values is set to null. The PaintSurface handler creates the SKShader object from all that information, and uses it to color the entire canvas. Paint.Shader = SKShader.CreateLinearGradient(touchPoints.Center, (SKShaderTileMode)(tileModePicker.SelectedIndex = -1 ? Paint.Shader = SKShader.CreateLinearGradient( Create linear gradient from upper-left to lower-right SKRect rect = new SKRect(x, y, x + 300, y + 300) Create 300-pixel square centered rectangle Void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) SKCanvasView canvasView = new SKCanvasView() ĬanvasView.PaintSurface += OnCanvasViewPaintSurface The PaintSurface handler creates an SKPaint object in a using statement and then defines a 300-pixel square rectangle centered in the canvas: public class CornerToCornerGradientPage : ContentPage The Corner-to-Corner Gradient page creates an SKCanvasView in its constructor. The diagonal linear gradient is demonstrated in the first page in the SkiaSharp Shaders and Other Effects section of the SkiaSharpFormsDemos sample. If the start point is the upper-left corner of the rectangle, the gradient can extend: Often a linear gradient extends from one corner of a rectangle to another. Other techniques are available for displaying bitmaps with gradient transparencies: These are described in the articles SkiaSharp circular gradients and SkiaSharp compositing and blend modes. You can use the Color property of SKPaint to set a transparency level for displaying a bitmap (as described in the article Displaying SkiaSharp bitmaps), but you can't use the Shader property for displaying a bitmap with a gradient transparency. The Shader property is ignored when you include an SKPaint object in a DrawBitmap call.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |