Draw hole in a canvas

Peer support for Air Manager desktop users

Moderators: Ralph, russ

Message
Author
User avatar
Sling
Posts: 4440
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Draw hole in a canvas

#21 Post by Sling » Thu Apr 29, 2021 3:15 am

Keith Baxter wrote:
Wed Apr 28, 2021 2:13 pm
Hi,

A bit more code but _arc() ,_quad_to() ,_ellipse(), _bezier_to() can be used to create shaped viewports.

Code: Select all

img_cover=canvas_add(0,0,800,400)
  
canvas_draw(img_cover, function()
   _move_to(200,50)
   _line_to(600,50)
   _line_to(600,350)
   _line_to(200,350)
   _line_to(200,0)   
   _line_to(0,0)
   _line_to(0,400)
   _line_to(800,400)
   _line_to(800,0)
   _line_to(199,0)
   _line_to(199,50)
   _line_to(200,50)   
  _fill("red")   
end)
Note how the last three line in the draw overlap. This is to ensure an overlap. In you version there are transparencies where the rectangles join/meet. I suggest you make them overlap a px or two. But you got the idea.

Keith
Be careful calling it a viewport because it’s not a viewport in the AM sense. Just think it may confuse someone reading this at a later date.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests