Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Introduction to P5.js and the Canvas | Getting Started with P5.js
Generative Art with JavaScript and P5.js

bookIntroduction to P5.js and the Canvas

メニューを表示するにはスワイプしてください

P5.js is a JavaScript library designed to make creative coding accessible and fun for everyone. Its philosophy centers around lowering the barrier to entry for artists, designers, educators, and beginners who want to experiment with code as a medium for creative expression. In the context of creative coding, P5.js allows you to quickly visualize ideas by providing simple functions for drawing, animation, and interactivity. Using P5.js, you can create generative art, interactive sketches, and dynamic visualizations—all directly in your web browser.

index.html

index.html

copy

When you create a P5.js sketch, you typically define two main functions: setup() and draw(). The setup() function runs once when the sketch starts. It is where you initialize your canvas using createCanvas(width, height), set background colors, and configure other initial settings. The draw() function, if present, runs continuously in a loop after setup() finishes, allowing you to animate or update your sketch frame by frame. By placing createCanvas(400, 300) inside setup(), you ensure the canvas is only created once at the beginning, and the background color is set before anything else is drawn.

question mark

Which function in P5.js is responsible for creating the canvas and running once at the start of the sketch?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  1

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  1
some-alt