mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 00:36:20 +08:00
88 lines
2.2 KiB
HTML
88 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>KonvaJS Sandbox</title>
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0"
|
|
/>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
}
|
|
body {
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
|
|
.test {
|
|
position: absolute;
|
|
color: red;
|
|
font-size: 20px;
|
|
font-family: Arial;
|
|
border: 0;
|
|
background-color: transparent;
|
|
outline: none;
|
|
resize: none;
|
|
overflow: hidden;
|
|
line-height: 1;
|
|
padding: 0px;
|
|
letter-spacing: 20px;
|
|
width: 500px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
<!-- <script src="https://cdn.rawgit.com/hammerjs/touchemulator/master/touch-emulator.js"></script> -->
|
|
<script>
|
|
// TouchEmulator();
|
|
</script>
|
|
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.7/hammer.js"></script> -->
|
|
<!-- <script src="https://cdn.rawgit.com/hammerjs/touchemulator/master/touch-emulator.js"></script> -->
|
|
<!-- <script src="./hammer.js"></script> -->
|
|
<!-- <script src="https://unpkg.com/fabric@5.2.1/dist/fabric.js"></script> -->
|
|
</head>
|
|
|
|
<body>
|
|
<div id="container"></div>
|
|
<textarea class="test" id="text">Hello</textarea>
|
|
|
|
<script type="module">
|
|
import Konva from '../src/index.ts';
|
|
|
|
var stageWidth = window.innerWidth;
|
|
var stageHeight = window.innerHeight;
|
|
|
|
Konva._fixTextRendering = true;
|
|
|
|
var stage = new Konva.Stage({
|
|
container: 'container',
|
|
width: stageWidth,
|
|
height: stageHeight,
|
|
});
|
|
|
|
Konva._fixTextRendering = true;
|
|
|
|
const layer = new Konva.Layer();
|
|
stage.add(layer);
|
|
|
|
const shape = new Konva.Text({
|
|
x: 50,
|
|
y: 50,
|
|
text: 'Hello',
|
|
fontSize: 20,
|
|
fontFamily: 'Arial',
|
|
letterSpacing: 20,
|
|
align: 'center',
|
|
width: 500,
|
|
});
|
|
layer.add(shape);
|
|
|
|
text.style.top = shape.y() + 'px';
|
|
text.style.left = shape.x() + 'px';
|
|
</script>
|
|
</body>
|
|
</html>
|