JCanvas Introduction 简介 - caleb531/jcanvas-docs GitHub Wiki

Introduction 简介

The <canvas> element is a new element apart of HTML5. It allows you to draw shapes, paths, images, and other drawings on a blank element called the canvas.
Canvas元素是HTML5独立的新元素,它允许你在调用了画布的空元素上,画形状、路径、图像和其它绘制功能。

Creating a canvas 创建画布

Before you can draw on the canvas, you need to create one.
在画布上绘制之前,你需要创建一个画布。

<canvas width='300' height='150'></canvas>

Of course, the canvas can be any width/height you want. You may also wish to give the canvas an ID (for future reference).
当然,画布可以是任意你想要的宽高,你也可以给画布设置一个ID(用于未来引用它)。
As a side note, you cannot accurately set a canvas's width and height via CSS; you can only do so through the canvas element's width and height attributes.
作为侧面说明,你无法通过CSS来精确的设置画布的宽高,你只能通过画布元素的宽高属性来这么做(设置宽高)。

Importing jCanvas 引入jCanvas

You also need to add jCanvas to your page somehow (usually a <script> element will do).
你也需要将jCanvas用某种方法加到你的页面上(通常用script元素就可以了)。

<script src='jcanvas.min.js'></script>

Drawing 绘制

HTML5 provides a native JavaScript API for drawing on the canvas. However, we will be using jCanvas instead.
HTML5提供了一个本地JS接口,用来在画布上绘图。但我们要使用jCanvas代替。
Using jCanvas requires basic knowledge of using jQuery.
使用jCanvas需要掌握使用jQuery的基本知识。

⚠️ **GitHub.com Fallback** ⚠️