Konva.js 专门对canvas的一个插件

Konva.js - 2d html5 canvas library for desktop and mobile applications.


 
   
<html>
<head>
<script src="https://cdn.rawgit.com/konvajs/konva/1.6.3/konva.min.js"> script>
<meta charset="utf-8">
<title>Konva Rect Demo title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #F0F0F0;
}
style>
head>
<body>
<div id="container"> div>
<script>
var width = window.innerWidth;
var height = window.innerHeight;
var stage = new Konva.Stage({
container: 'container',
width: width,
height: height
});
var layer = new Konva.Layer();
var rect = new Konva.Rect({
x: 50,
y: 50,
width: 100,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 4
});
// add the shape to the layer
layer.add(rect);
// add the layer to the stage
stage.add(layer);
script>
body>
html>
网站上有详细的代码编写,主要的步骤是new一个stage 然后new一个layer 然后网layer中add()绘制的图形;

你可能感兴趣的:(Konva.js 专门对canvas的一个插件)