Circular Canvas?

Hi everyone - I have a canvas which correctly loads in and displays a square jpg image.
I would like the canvas to be circular (basically mask the square canvas into a circle).

I have looked into the documentation but I cannot work out how to achieve that.
Any help would be very much appreciated.

Thank you all in advance.

Create your mask, do a picture.applyMask

Where did you look in the documentation?

What have you tried?

Dragged an image called Linuxbabies.png into the project (it is not square)

Added a canvas and

Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
  Dim pic As New Picture( Linuxbabies.Width, Linuxbabies.Height )
  Dim mask As New Picture( pic.Width, pic.height )
  mask.Graphics.ForeColor = Color.White // white areas will not be shown, is transparent
  mask.Graphics.FillRect( 0,0, mask.Width, mask.Height )
  mask.Graphics.ForeColor = Color.Black  // black areas will be shown
  mask.Graphics.FillOval( 50,50, mask.Width-50, mask.Height-50 )
  pic.Graphics.DrawPicture( Linuxbabies, 0,0, Linuxbabies.Width, Linuxbabies.Height )
  pic.ApplyMask( mask )
  g.DrawPicture( pic, 0,0, g.Width, g.Height )

End Sub


1 Like

Danke sehr Markus !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.