Blending ellipse over a rectangle

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
Is it possible to draw two items (for example, a rectangle and an ellipse) and where the fill colours meet, create a blend rather than overlay :confused:

VB.NET:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim p As New Pen(Color.Black)
        With e.Graphics
            .FillRectangle(Brushes.LightGray, 50, 50, 200, 200)
            .DrawRectangle(p, 50, 50, 200, 200)

            .FillEllipse(Brushes.LightBlue, 150, 150, 150, 150)
            .DrawEllipse(p, 150, 150, 150, 150)
        End With
        p.Dispose()
    End Sub

I know I can show the outline through, by drawing the "fills" first and then the "strokes", but this doesnt help with the colour blend.
 
The graphics CompositingMode is already SourceOver so all you have to do is provide a semitransparent color:
VB.NET:
Dim b1 As New SolidBrush(Color.FromArgb(123, Color.LightGray))
The colors change with the transparency to lighter, but you can adjust to a darker color if needed.
 
Perfect - thanks John :D
 
Back
Top