How to draw a gradient outline facing outwards?

Viewed 68

Using the system.drawing library in .net-core, is it possible given path: enter image description here

    var bitmap = new Bitmap(1024, 512);
    var graphics = Graphics.FromImage(bitmap);

    var curve = new[] { new PointF(0f, 0f), new PointF(32f, 31.794779f), new PointF(64f, 62.367702f), new PointF(96f, 90.54387f), new PointF(128f, 115.24048f), new PointF(160f, 135.50848f), new PointF(192f, 150.56894f), new PointF(223.99998f, 159.84314f), new PointF(255.99998f, 162.97466f), new PointF(287.99997f, 159.84315f), new PointF(319.99997f, 150.56895f), new PointF(351.99997f, 135.50848f), new PointF(384f, 115.24048f), new PointF(416f, 90.54386f), new PointF(448f, 62.367676f), new PointF(480.00003f, 31.794739f), new PointF(512.00006f, -5.3103886E-05f), new PointF(544.00006f, -31.794844f), new PointF(576.00006f, -62.36777f), new PointF(608.00006f, -90.543945f), new PointF(640.00006f, -115.24056f), new PointF(672.00006f, -135.50854f), new PointF(704.0001f, -150.569f), new PointF(736.0001f, -159.84317f), new PointF(768.0001f, -162.97466f), new PointF(800.0001f, -159.84311f), new PointF(832.0001f, -150.56888f), new PointF(864.0002f, -135.50836f), new PointF(896.0002f, -115.24033f), new PointF(928.0002f, -90.543686f), new PointF(960.0002f, -62.36748f), new PointF(992.0002f, -31.794533f), new PointF(1024f, 2.8495393E-05f) };

    var path = new GraphicsPath();
    path.AddCurve(curve);

    graphics.TranslateTransform(0, 256);
    graphics.DrawPath(new Pen(Color.Black, 16), path);
    graphics.ResetTransform();

    graphics.Dispose();
    bitmap.Save("outline.png", ImageFormat.Png);

To use an arbitary gradient: enter image description here

To draw a gradient outline that starts at the outer edges of the shape and progresses outwards to look like this? enter image description here (Example was created via photopea.com layer style stroke, with a "Shape Burst" style gradient)

0 Answers
Related