Skip to content

Commit

Permalink
Correct reset the rendering context
Browse files Browse the repository at this point in the history
6efd0e6 addressed #5771 incorrectly. The current default path should not be part of the drawing state, but should be cleared when resetting the rendering context.

(Also remove some older ideas from the source.)

Closes #5618 and fixes #5771.
  • Loading branch information
annevk committed May 6, 2021
1 parent 79e39f6 commit 7a8e97a
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -60864,7 +60864,6 @@ context.fillRect(100,0,50,50); // only this square remains</code></pre>
<ul class="brief">
<li>The current <span data-x="dom-context-2d-transformation">transformation matrix</span>.</li>
<li>The current <span>clipping region</span>.</li>
<li>The <span>current default path</span>.</li>
<li>The current values of the following attributes: <code
data-x="dom-context-2d-strokeStyle">strokeStyle</code>, <code
data-x="dom-context-2d-fillStyle">fillStyle</code>, <code
Expand Down Expand Up @@ -60922,27 +60921,18 @@ context.fillRect(100,0,50,50); // only this square remains</code></pre>
<p>The <dfn method for="CanvasState"><code data-x="dom-context-2d-reset">reset()</code></dfn>
method steps are to <span>reset the rendering context to its default state</span>.</p>

<p>When the user agent is to <dfn>reset the rendering context to its default state</dfn>, it must
clear the bitmap to <span>transparent black</span>, clear the drawing state stack, and reset
everything that <span>drawing state</span> consists of to initial values.</p>

<!-- v7
idea from Mihai:
> 5. Drawing states should be saveable with IDs, and for easier restoring.
>
> save(id)
> restore(id)
>
> If id is not provided, then save() works as defined now. The same for
> restore().
>
> Currently, it's not trivial to save and restore a specific state.
...and from Philip:
> I think a more convenient syntax would be:
> var state = ctx.save();
> ctx.restore(state);
> But how would it interact with normal calls to ctx.restore()?
-->
<p>To <dfn>reset the rendering context to its default state</dfn>, run these steps:</p>

<ol>
<li><p>Clear canvas's bitmap to <span>transparent black</span>.</p></li>

<li><p>Empty the list of subpaths in context's <span>current default path</span>.</p></li>

<li><p>Clear the context's drawing state stack.</p></li>

<li><p>Reset everything that <span>drawing state</span> consists of to their initial
values.</p></li>
</ol>

</div>

Expand Down

0 comments on commit 7a8e97a

Please sign in to comment.