Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 04:20:47 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Canvas & Context - filling in the outermost interior of polygons?
Pages: [1]
Print
Author Topic: Canvas & Context - filling in the outermost interior of polygons?  (Read 617 times)
quantumpotato
Quantum Potato
Level 10
*****



View Profile WWW
« on: December 06, 2015, 03:26:38 PM »

http://stackoverflow.com/questions/34124108/fill-in-outer-area-of-an-interior-polygon

I'm drawing a ship with 4 points in a shipVertexes array. Inside the ship, I'm drawing the same shape smaller with the stunVertexes.

Stroking the context yields the attached image. You can see how there's a small ship inside the larger one. (Red ship)

I want to fill in the space between the outer ship & the inner ship, leaving an empty (black) space in the middle.

When I run context.fill(), the entire space is filled solid (see Yellow ship).

How do I fill in just the outside of the interior space?

Logged

zleub
Level 0
**


View Profile WWW
« Reply #1 on: December 07, 2015, 01:50:42 PM »

I didn't get why context.fill() should not fill the inner space but in that position, i usually choose to fill the larger space before filling the little one with alpha or whatever.

PS: this is a way too big picture.
Logged
evercalm
Level 0
*



View Profile
« Reply #2 on: December 22, 2015, 03:18:59 AM »

http://stackoverflow.com/questions/34124108/fill-in-outer-area-of-an-interior-polygon

I'm drawing a ship with 4 points in a shipVertexes array. Inside the ship, I'm drawing the same shape smaller with the stunVertexes.

Stroking the context yields the attached image. You can see how there's a small ship inside the larger one. (Red ship)

I want to fill in the space between the outer ship & the inner ship, leaving an empty (black) space in the middle.

When I run context.fill(), the entire space is filled solid (see Yellow ship).

How do I fill in just the outside of the interior space?



First draw the outer shape and fill it with desired color, then draw the smaller inner shape on top of outer shape with black color. It should give you the desired effect. If you need alpha for inner shape, then use clipping mask.
Logged
quantumpotato
Quantum Potato
Level 10
*****



View Profile WWW
« Reply #3 on: January 29, 2016, 07:54:20 PM »

Thank you!
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic