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 19026 - I would like to see a clearPath or clearStroke functions similar to clearRect but to clear lines, not just full rectangles
Summary: I would like to see a clearPath or clearStroke functions similar to clearRect...
Status: RESOLVED LATER
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML Canvas 2D Context (show other bugs)
Version: unspecified
Hardware: All All
: P3 enhancement
Target Milestone: ---
Assignee: Jay Munro
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-25 21:55 UTC by contributor
Modified: 2013-02-22 18:44 UTC (History)
6 users (show)

See Also:


Attachments

Description contributor 2012-09-25 21:55:34 UTC
This was was cloned from bug 11739 as part of operation LATER convergence.
Originally filed: 2011-01-11 22:51:00 +0000

================================================================================
 #0   contributor@whatwg.org                          2011-01-11 22:51:44 +0000 
--------------------------------------------------------------------------------
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html
Section: http://www.whatwg.org/specs/web-apps/current-work/complete.html#complex-shapes-(paths)

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

Posted from: 71.9.39.98
================================================================================
 #1   Tab Atkins Jr.                                  2011-01-11 23:00:52 +0000 
--------------------------------------------------------------------------------
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.
================================================================================
 #2   Ian 'Hixie' Hickson                             2011-02-11 01:27:04 +0000 
--------------------------------------------------------------------------------
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:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

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

That should read "none yet", my apologies.
================================================================================
 #5   Ian 'Hixie' Hickson                             2012-02-29 22:11:36 +0000 
--------------------------------------------------------------------------------
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...
================================================================================
 #6   Tab Atkins Jr.                                  2012-02-29 22:16:00 +0000 
--------------------------------------------------------------------------------
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.
================================================================================
 #7   Ian 'Hixie' Hickson                             2012-02-29 22:45:06 +0000 
--------------------------------------------------------------------------------
I guess that makes sense.

So basically this is just a shorthand for:

   .save();
   .clip();
   .setTranform(identity)
   .clearRect(entire canvas)
   .restore();

...?
================================================================================
 #8   Tab Atkins Jr.                                  2012-02-29 22:46:39 +0000 
--------------------------------------------------------------------------------
Yup.
================================================================================
 #9   Ian 'Hixie' Hickson                             2012-02-29 22:54:52 +0000 
--------------------------------------------------------------------------------
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.
================================================================================