HTML5 JavaScript modifies the size of the canvas

Source: Internet
Author: User

Method 1: Set a fixed value, which is no different from setting the canvas's value in HTML:

function () {    = +;     = Thefunction() {    = +;      = $;}

Method 2: Modify the size with fixed, this way is similar to the first one, need to pass parameters, which is nothing;

function (width, height) {    = height;     = width;}

Method 3: The most wanted to record a way to set the size of the canvas according to a picture size:

var image = document.getElementById ("image"== image.height;

Method 4: Take the size of the image loaded in JavaScript, can not directly take image size is because when the execution of IMAGE.SRC, the picture loading is relatively delayed, that is, the size of the image at this time is still 0*0.

var New  function() {    = "Some/location/name.jpg";      function(){        = image.width;         = image.height;    }}

In particular, the above method 4, is their own understanding, do not know whether ....

HTML5 JavaScript modifies the size of the canvas

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.