1<! DOCTYPE html>234<title>insert you title</title>5<meta name= ' description ' content= ' This is my page ' >6<meta name= ' keywords ' content= ' keyword1,keyword2,keyword3 ' >7<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<link rel= ' stylesheet ' type= ' text/css ' href= './css/index.css '/>9<script type= ' text/javascript ' src= './js/jquery-1.12.1.min.js ' ></script>Ten<script type= "Text/javascript" src= "Js/jcanvascript.1.5.18.min.js" ></script> One<style type= ' text/css ' > A Html,body,img,canvas { -margin:0; padding:0; - } the - HTML { -height:100%; - } + - Body { +Background: #000; A } at - #can { -Background: #FFF; Display:block; MARGIN:25PX Auto; border-radius:2px; - } -</style> -<script type= ' Text/javascript ' > in$(function(){ - varcan = $ (' #can '). Get (0 ); to varOcan = Can.getcontext (' 2d ' ); + varStrcolor =Getrandomcolor (); - /* JS Plug-in application: 35 Address: HTTP://JCSCRIPT.COM/36 role: Using an object-oriented approach to simplify canvas drawing operations 37 Usage: Refer to website demo - */ theJc.start (' can ');/*Start drawing parameters: Idcanvas*/ + /* A The format of the transfer of parameters: the rect (float x, float y, float width, float height) + rect (float x, float y, float width, float height, bool fill) - rect (float x, float y, float width, float height, string color) $ rect (float x, float y, float width, float height, string color, bool fill) $ rect (object parameters) - */ - Jc.rect ({ the' X ': 100 , -' Y ': 50 ,Wuyi' Width ': 100 , the' Height ': 100 , -' Color ': Strcolor, Wu' Fill ': 1/* Parameter 0 is false not filled just outline figure parameter 1 is true fill */ - } ); AboutJc.start (' can ');/*End Drawing*/ $ functionGetrandomcolor () { - varnum = ' 0xFFFFFF '; - varLen = Math.ceil (Math.random () * parseint (num, +)). ToString (16 ); - if(Length < 6 ){ A for(vari = 0; i < 6-len.length; i++ ){ +Len + = ' 0 '; the } - } $ return' # ' +Len; the } the } ); the</script> the -<body> in<canvas id= ' can ' width= ' height= ' > detects that your browser version is too low, please upgrade your browser to get a better experience ...</canvas> the</body> the
[JavaScript Canvas plugin demo] Canvas plugin Demo