Help us understand the problem. What is going on with this article?

canvasのサイズをjQueryで変更する

More than 1 year has passed since last update.

jQueryでcanvasのサイズを設定する。
cssでサイズ設定していると、初期サイズ(幅300px、高さ150px)からの拡大・縮小となる。

index.html
    <canvas id="idCanvas"></canvas>
main.js
   $('#idCanvas').attr('width' , 500);
   $('#idCanvas').attr('height', 500);
main.css
  /* 初期サイズからの拡大・縮小 */
  #idCanvas {
    width  : 200px;
    height : 200px;
  }

追記
cssでのサイズ指定は、canvasを拡大・縮小するものであり、サイズを直接変えるものではありません(画像が縮んだり伸びたりします)。
サイズを直接変える場合は、下記を使用します。

main.js
    //canvas
    canvas = document.getElementById('idCanvas');

    //サイズ指定
    canvas.width  = 500;
    canvas.height = 500;
qiiChan
紆余曲折合って、福岡でフリープログラマーやってます^^ ツイッター:https://twitter.com/hrlArZUXxmd0Zo7
http://ryutai.ninja-web.net/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした