mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibWeb: Add CanvasRenderingContext2D.rotate()
This is pretty limited since we don't have wholesale mapping through the context transform, but we have to start somewhere. :^)
This commit is contained in:
parent
dc22e59a1a
commit
9d8565cf9a
5 changed files with 21 additions and 0 deletions
12
Base/res/html/misc/canvas-rotate.html
Normal file
12
Base/res/html/misc/canvas-rotate.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<html>
|
||||||
|
<canvas id=c width=200 height=200></canvas>
|
||||||
|
<script>
|
||||||
|
c = document.getElementById('c');
|
||||||
|
x = c.getContext('2d');
|
||||||
|
x.strokeStyle = 'black';
|
||||||
|
for (i = 0; i < 8; ++i) {
|
||||||
|
x.strokeRect(50, 50, 50, 50);
|
||||||
|
x.rotate(0.05);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
|
@ -28,6 +28,7 @@ span#ua {
|
||||||
<p>Your user agent is: <b><span id="ua"></span></b></p>
|
<p>Your user agent is: <b><span id="ua"></span></b></p>
|
||||||
<p>Some small test pages:</p>
|
<p>Some small test pages:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href="canvas-rotate.html">canvas rotate()</a></li>
|
||||||
<li><a href="margin-collapse-2.html">margin collapsing 2</a></li>
|
<li><a href="margin-collapse-2.html">margin collapsing 2</a></li>
|
||||||
<li><a href="margin-collapse-1.html">margin collapsing 1</a></li>
|
<li><a href="margin-collapse-1.html">margin collapsing 1</a></li>
|
||||||
<li><a href="position-absolute-from-edges.html">position: absolute, offset from edges</a></li>
|
<li><a href="position-absolute-from-edges.html">position: absolute, offset from edges</a></li>
|
||||||
|
|
|
@ -123,6 +123,12 @@ void CanvasRenderingContext2D::translate(float tx, float ty)
|
||||||
m_transform.translate(tx, ty);
|
m_transform.translate(tx, ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasRenderingContext2D::rotate(float radians)
|
||||||
|
{
|
||||||
|
dbg() << "CanvasRenderingContext2D::rotate(): " << radians;
|
||||||
|
m_transform.rotate_radians(radians);
|
||||||
|
}
|
||||||
|
|
||||||
void CanvasRenderingContext2D::did_draw(const Gfx::FloatRect&)
|
void CanvasRenderingContext2D::did_draw(const Gfx::FloatRect&)
|
||||||
{
|
{
|
||||||
// FIXME: Make use of the rect to reduce the invalidated area when possible.
|
// FIXME: Make use of the rect to reduce the invalidated area when possible.
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
|
|
||||||
void scale(float sx, float sy);
|
void scale(float sx, float sy);
|
||||||
void translate(float x, float y);
|
void translate(float x, float y);
|
||||||
|
void rotate(float degrees);
|
||||||
|
|
||||||
void set_line_width(float line_width) { m_line_width = line_width; }
|
void set_line_width(float line_width) { m_line_width = line_width; }
|
||||||
float line_width() const { return m_line_width; }
|
float line_width() const { return m_line_width; }
|
||||||
|
|
|
@ -5,6 +5,7 @@ interface CanvasRenderingContext2D {
|
||||||
|
|
||||||
void scale(double x, double y);
|
void scale(double x, double y);
|
||||||
void translate(double x, double y);
|
void translate(double x, double y);
|
||||||
|
void rotate(double radians);
|
||||||
|
|
||||||
void beginPath();
|
void beginPath();
|
||||||
void closePath();
|
void closePath();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue