This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11739 - <canvas>: clearPath() that clears pixels the way clearRect() does, but using a path
Summary: <canvas>: clearPath() that clears pixels the way clearRect() does, but using ...
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P3 enhancement
Target Milestone: Needs Impl Interest
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
Depends on: 9236
  Show dependency treegraph
Reported: 2011-01-11 22:51 UTC by contributor
Modified: 2014-09-26 21:31 UTC (History)
6 users (show)

See Also:


Description contributor 2011-01-11 22:51:44 UTC

I would like to see a clearPath or clearStroke functions similar to clearRect
but to clear lines, not just full rectangles

Posted from:
Comment 1 Tab Atkins Jr. 2011-01-11 23:00:52 UTC
This can be achieved currently by making a path, calling clip(), *then* calling clearRect with a bounding rectangle specified.

That technique is fairly unintuitive, though.  A clear() method that clears out a path would be nice.
Comment 2 Ian 'Hixie' Hickson 2011-02-11 01:27:04 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:

Status: Partially Accepted
Change Description: see diff given below
Rationale: That might make sense, but in a future version.
Comment 3 Ian 'Hixie' Hickson 2011-02-11 01:33:19 UTC
> Change Description: see diff given below

That should read "none yet", my apologies.
Comment 4 Michael[tm] Smith 2011-08-04 05:03:35 UTC
mass-move component to LC1
Comment 5 Ian 'Hixie' Hickson 2012-02-29 22:11:36 UTC
What's the use case for this, exactly? Having played with canvas quite a bit recently I've never found myself needing anything but clearRect() applied to the entire canvas...
Comment 6 Tab Atkins Jr. 2012-02-29 22:16:00 UTC
I've used the technique I outlined in Comment #1 for a Worms-like game before.  When your gun hit, I did a clearRect() (clipped to a path) to remove pixels from the "level" canvas.
Comment 7 Ian 'Hixie' Hickson 2012-02-29 22:45:06 UTC
I guess that makes sense.

So basically this is just a shorthand for:

   .clearRect(entire canvas)

Comment 8 Tab Atkins Jr. 2012-02-29 22:46:39 UTC
Comment 9 Ian 'Hixie' Hickson 2012-02-29 22:54:52 UTC
I'm going to punt on this for now, and review it at a later date to see how much demand there has been for it. So far it seems like it would be little more than a convenience method and I haven't heard much demand for it.
Comment 10 Michael[tm] Smith 2013-01-24 07:38:04 UTC
This bug was cloned to create HTML WG bug 19026.
Comment 11 Ian 'Hixie' Hickson 2013-03-19 22:56:28 UTC
Any implementation interest on this? How compelling a use case is it? If it's not needed by many people, since it's only a convenience API essentially, maybe it's not worth doing?
Comment 12 Ian 'Hixie' Hickson 2014-09-26 21:31:31 UTC
Marking WONTFIX since it's gotten no vendor interest and it's equivalent to five lines of simple code anyway.