Canvas Tutorial - Web APIs | MDN
Có thể bạn quan tâm
- References
- Web APIs
- Canvas API
- Canvas tutorial
- English (US)
- Remember language
- Deutsch
- Español
- Français
- 日本語
- 한국어
- Português (do Brasil)
- Русский
- 中文 (简体)
- 正體中文 (繁體)
- Before you start
- In this tutorial
- See also
- A note to contributors
- Canvas API
- Guides
- Manipulating video using canvas
- Tutorial
- Canvas tutorial
- Basic usage of canvas
- Drawing shapes with canvas
- Applying styles and colors
- Drawing text
- Using images
- Transformations
- Compositing and clipping
- Basic animations
- Advanced animations
- Pixel manipulation with canvas
- Optimizing canvas
- Finale
- Interfaces
- CanvasGradient
- CanvasPattern
- CanvasRenderingContext2D
- HTMLCanvasElement
- ImageBitmap
- ImageBitmapRenderingContext
- ImageData
- OffscreenCanvas
- OffscreenCanvasRenderingContext2D
- Path2D
- TextMetrics
- Methods
- Window.createImageBitmap()
- WorkerGlobalScope.createImageBitmap()
- Before you start
- In this tutorial
- See also
- A note to contributors
This tutorial describes how to use the <canvas> element to draw 2D graphics, starting with the basics. The examples provided should give you some clear ideas about what you can do with canvas, and will provide code snippets that may get you started in building your own content.
<canvas> is an HTML element which can be used to draw graphics via scripting (usually JavaScript). This can, for instance, be used to draw graphs, combine photos, or create simple animations.
First introduced in WebKit by Apple for the macOS Dashboard, <canvas> has since been implemented in browsers. Today, all major browsers support it.
Before you start
Using the <canvas> element is not very difficult, but you do need a basic understanding of HTML and JavaScript. The <canvas> element is not supported in some older browsers, but is supported in recent versions of all major browsers. The default size of the canvas is 300 pixels × 150 pixels (width × height). But custom sizes can be defined using the HTML height and width property. In order to draw graphics on the canvas we use a JavaScript context object, which creates graphics on the fly.
In this tutorial
- Basic usage
- Drawing shapes
- Applying styles and colors
- Drawing text
- Using images
- Transformations
- Compositing and clipping
- Basic animations
- Advanced animations
- Pixel manipulation
- Optimizing the canvas
- Finale
See also
- Canvas topic page
A note to contributors
Due to an unfortunate technical error that occurred the week of June 17, 2013, we lost the history of this tutorial, including attributions to all past contributors to its content. We apologize for this, and hope you'll forgive this unfortunate mishap.
- Next
Help improve MDN
Was this page helpful to you?YesNoLearn how to contribute.This page was last modified on Nov 15, 2024 by MDN contributors.
View this page on GitHub • Report a problem with this contentTừ khóa » Html Canvas
-
HTML Canvas Graphics - W3Schools
-
HTML Canvas Tutorial - W3Schools
-
Canvas API - MDN Web Docs
-
HTML Canvas - Javatpoint
-
HTML5 - Canvas - Tutorialspoint
-
25 Ridiculously Impressive HTML5 Canvas Experiments
-
How To Draw Graphics On HTML5 Canvas - Tutorial Republic
-
HTML5 Canvas Tutorial For Beginners | An Intro To Becoming A Pro
-
A Full Overview Of HTML Canvas - FreeCodeCamp
-
HTML
-
What Is The
-
JavaScript Canvas