GenerativeArt でかっこいいアートを作ってみたい。私の夢です。
p5.js とか TouchDesigner が有名ですが、Canvas はぜひマスターしたいと思ってます。
Canvas 基本
CanvasAPI のチュートリアルをみて作ってみました。
グレーの背景に赤い四角がある単純なものです。
↓canvas.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canvas = document.getElementById('canvas'); | |
const ctx = canvas.getContext('2d'); | |
ctx.width = 600; | |
ctx.height = 400; | |
// background | |
ctx.fillStyle = 'gray'; | |
ctx.fillRect(0, 0, ctx.width, ctx.height); | |
// rect | |
ctx.fillStyle = 'green'; | |
ctx.fillRect(30, 30, 100, 100); | |
<!-- HTMLはこちら | |
<canvas id="canvas" width="600" height="500"></canvas> | |
<script src="./canvas.js"></script> | |
--> |
Canvasってp5.jsと違って、もろJavaScriptなので勉強になっていい感じですね。