Skip to content

Commit 129e00b

Browse files
committed
v2
- Added favicon - Added RectAsset.rotation in docs - Redesigned examples - Redesigned docs' sidebar - Added Scene.dataURL
1 parent 595c5fc commit 129e00b

File tree

14 files changed

+85
-8
lines changed

14 files changed

+85
-8
lines changed

Canvas2d.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Canvas2d.Scene = class {
5353
asset.draw();
5454
});
5555
}
56+
get dataURL() {
57+
return this.canvas.toDataURL();
58+
}
5659
};
5760
Canvas2d.Asset = class {
5861
constructor() {

docs/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ <h2>assets<span>: Array</span></h2>
120120
<p>All the <a href="#Canvas2d.Asset">assets</a> added in the canvas. Used internally by this class.</p>
121121
<h2>background<span>: String</span></h2>
122122
<p>A CSS value used for the canvas background. Default is <code>"white"</code>.</p>
123+
<h2>dataURL<span>: String</span></h2>
124+
<p>The canvas drawing into a data URL.</p>
123125
<h2>add <span>(asset: Canvas2d.Asset): undefined</span></h2>
124126
<p>Adds a new <a href="#Canvas2d.Asset">asset</a> in the canvas.<br>If the asset is present in another scene, it'll be removed from that one.<br><span>asset:</span> The asset to be added.</p>
125127
<h2>remove <span>(asset: Canvas2d.Asset): undefined</span></h2>
@@ -198,7 +200,7 @@ <h2>color<span>: String</span></h2>
198200
<p>The rectangle CSS color. Initialized in <a href="#Canvas2d.RectAsset.constructor">the constructor</a>.</p>
199201
<h2>stroke<span>: Boolean</span></h2>
200202
<p>If true, the rectangle will be stroked instead of filled. Defaults to <code>false</code>.</p>
201-
<h2>stroke<span>: Boolean</span></h2>
203+
<h2>rotation<span>: Number</span></h2>
202204
<p>The rectangle clockwise rotation (pivot point is image center) in degrees.</p>
203205
<h2>draw <span>(): undefined</span></h2>
204206
<p>Draws the rectangle on the canvas. Called from <a href="#Canvas2d.Scene.draw">Canvas2d.Scene.draw</a>.</p>

examples/index.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
<link rel="icon" type="image/png" sizes="16x16" href="../favicon/favicon-16x16.png">
1010
<link rel="manifest" href="../favicon/site.webmanifest">
1111
<link rel="stylesheet" type="text/css" href="../style/uni.css">
12-
<link rel="stylesheet" type="text/css" href="../style/home.css">
12+
<link rel="stylesheet" type="text/css" href="../style/examples.css">
13+
<script type="text/javascript" src="index.js"></script>
1314
</head>
1415
<body>
15-
<div id="title">Examples</div>
16-
<ul id="contents">
17-
<li><a href="..">Back</a></li>
18-
<li><a href="hi.html">Docs first example</a></li>
19-
<li><a href="thesun.html">The Sun</a></li>
20-
</ul>
16+
<div id="sidebar">
17+
<div id="title">Examples</div>
18+
<ul id="contents">
19+
<li><a href="..">Back</a></li>
20+
<li><a href="#hi">Docs first example</a></li>
21+
<li><a href="#thesun">The Sun</a></li>
22+
</ul>
23+
</div>
24+
<iframe id="main"></iframe>
2125
</body>
2226
</html>

examples/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
onload = () => {
2+
var url = "";
3+
setInterval(() => {
4+
if (url != document.URL) {
5+
if (!document.URL.includes("#")) {
6+
location.replace(document.querySelectorAll("#contents li a")[1].href);
7+
}
8+
url = document.URL;
9+
document.getElementById("main").src = url.substring(url.indexOf("#") + 1) + ".html";
10+
if (document.querySelector("#contents li.selected"))
11+
document.querySelector("#contents li.selected").removeAttribute("class");
12+
document.querySelector(`#contents li a[href='${url.substring(url.indexOf("#"))}']`).parentElement.classList.add("selected");
13+
}
14+
}, 50);
15+
}

favicon/about.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This favicon was generated using the following font:
2+
3+
- Font Title: Montserrat Subrayada
4+
- Font Author: Copyright (c) 2011-2012, Julieta Ulanovsky ([email protected]), with Reserved Font Names 'Montserrat'
5+
- Font Source: http://fonts.gstatic.com/s/montserratsubrayada/v15/U9MD6c-o9H7PgjlTHThBnNHGVUORwteQQE8LYuceqGT-.ttf
6+
- Font License: SIL Open Font License, 1.1 (http://scripts.sil.org/OFL))

favicon/android-chrome-192x192.png

6.21 KB
Loading

favicon/android-chrome-512x512.png

18.2 KB
Loading

favicon/apple-touch-icon.png

5.57 KB
Loading

favicon/favicon-16x16.png

420 Bytes
Loading

favicon/favicon-32x32.png

807 Bytes
Loading

0 commit comments

Comments
 (0)