forked from WICG/html-in-canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplex-text.html
More file actions
34 lines (32 loc) · 915 Bytes
/
complex-text.html
File metadata and controls
34 lines (32 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!doctype html>
<style>
canvas {
border: 1px solid blue;
}
img {
width: 40px;
height: auto;
}
</style>
<canvas id="canvas" layoutsubtree="true" width=500 height=500>
<div id=drawElement style="width: 300px; height: 300px;" id="d">
Hello world!<br>I'm multi-line, <b>formatted</b>,
rotated text with emoji (😀), RTL text
<span dir=rtl>من فارسی صحبت میکنم</span>,
vertical text,
<p style="writing-mode: vertical-rl;">
这是垂直文本
</p>
and an inline image:
<img src="https://upload.wikimedia.org/wikipedia/commons/9/9b/Gustav_chocolate.jpg">
</div>
</canvas>
<script>
onload = () => {
const ctx = document.getElementById("canvas").getContext("2d");
const el = document.getElementById("drawElement");
ctx.rotate((45 * Math.PI) / 180);
ctx.translate(200, -125);
ctx.drawElement(el, 30, 0);
}
</script>