LoginSignup
0
0

More than 1 year has passed since last update.

Canvasについて

Posted at

Canvasの扱い方。

⓪canvasタグを使いオブジェクトを生成
<canvas id = "myCanvas" width = "150" height = "150"></canvas>

①getElementByIdでキャンバスオブジェクトを取得
const canvas = document.getElementById("myCanvas");

②キャンバスのプロパティを操作できるように設定
const ctx = canvas.getContext('2d');

③ctx.〇〇 = ** でプロパティの値を編集

ctx.fillStyle = 'rgb(200, 0, 0)';
ctx.fillRect(10, 10, 50, 50);
ctx.fillStyle = 'rgba(0, 0, 200, 0.5)';
ctx.fillRect(30, 30, 50, 50);

オブジェクト生成

オブジェクト取得

オブジェクトのプロパティ設定

オブジェクトのプロパティ操作

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0