Draw super Mary using JavaScript

Source: Internet
Author: User

In the previous article, I mentioned that there was a Japanese who made a very powerful JS canvas library and could convert Javascript into Silverlight.
This time he needs to use his function library, address in http://www.cnblogs.com/libinqq/archive/2009/01/08/1371676.html

Next I will talk about how to plot. It is very simple. We just need to create a JS array and a user-friendly output interface (as shown below ).

Code
Function boot (){
Draw (document. getelementbyid ( ' Canvas ' ));
Draw (document. getelementbyid ( ' Vmlcanvas ' ));
}
Function draw (e ){
VaR dot =
" 11111 " +
" 111111111 " +
" 2223323 " +
" 2323332333 " +
" 23223332333 " +
" 2233332222 " +
" 3333333 " +
" 221222 " +
" 2221221222 " +
" 222211112222 " +
" 332131131233 " +
" 331111111133 " +
" 111 111 " +
" 222 222 " +
" 2222 2222 " ;
VaR ary = Dot. Split ( "" );
VaR data = [];
VaR I, iz;
For (I =   0 , Iz = Ary. length; I < Iz; ++ I ){
Switch (Parseint (ary [I]) |   0 ){
Case   0 : Data. Push ( "" ); Break ;
Case   1 : Data. Push ( " # Ff3900 " ); Break ;
Case   2 : Data. Push ( " # Ad7b00 " ); Break ;
Case   3 : Data. Push ( " # Ffa542 " ); Break ;
}
}
UU. Draw (e). Scale ( 5 , 5 ). Icon ( 5 , 25 , 12 , 15 , Data );
}

 

The aboveCodeWe can draw a drawing array and split the output directly below.
Note the following. Icon (X axis, Y axis, array width, array height)

(I painted it myself)

 
We can access our view array as an object to call or make animations multiple times.

 

There is no need to worry about browser compatibility, because this library is highly compatible. in IE, it will convert JS Code into Silverlight. If the client does not install
Silverlight,ProgramIt will be resolved to VML, and Firefox and Google will be more compatible because they support Canvas elements.

If the game is the first choice, because the Silverlight speed is quite good, and both are expressed in the X and Y axes, as long as we define the canvas, we do not need HTML Div.
Because the canvas is a whole area or control.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.