Web888.vn
  • Shop
  • Blog
Đăng nhập
  • Đăng nhập / Đăng ký

Please enter key search to display results.

Home
  • HTML programming
  • Technology News
What is HTML5 Canvas?

What is HTML5 Canvas?

  • 24-07-2022
  • Trung Minh
  • 0 Comments

In this article, we will learn an HTML5 tag used to build Graphic graphics that is the Canvas tag.

For example, if you want to draw a geometric diagram, we must use an image file. But with Canvas, you can completely draw yourself.

1. What is HTML5 Canvas?

Canvas is an HTML5 tag similar to other HTML tags, but the most obvious difference is that the content of Canvas is built from Javascript. To use Canvas, you must place the <canvas></canvas> tag at the position you want to display, then use the APIs that HTML5 provides to manipulate the objects inside the Canvas (line, circle, . ..).

When using Canvas you must understand the difference between the elements of the Canvas and its content. The Canvas element is just an ordinary HTML tag, but its content is a collection of objects that make up a Graphic.

When displayed in the browser, the Canvas will display as a png image.

 <canvas id="myCanvas" width="578" height="200"></canvas> <script> // Lấy thẻ HTML Canvas var canvas = document.getElementById('myCanvas'); // Vẽ ở mô hình 2D var context = canvas.getContext('2d'); // Thiết lập font chữ và màu context.font = '40pt Calibri'; context.fillStyle = 'blue'; // vẽ một đoạn text tại vị trí 150px 100px context.fillText('Hello World!', 150, 100); </script>

Run up you will see a text " Hello World! ", try to black it out, okay? Absolutely not because it is an Object displayed as an image, so you can only save it as a png file, not a text anymore.

2. Conclusion

Because this is the first article to start a series of learning about Canvas tags in HTML5, I don't go into how to handle it, but only introduce the concept of what Canvas is and some notes when using Canvas. In the next articles we will learn how to use HTML5 Canvas API to manipulate objects in Canvas.

Bài viết liên quan:

Installing PHP and introducing PHP basics
Instructions for using the plugin wp bakery builder (visual composer) to make a landing page
Instructions for installing and activating Office 2013
15 pocket tips in daily life you should know
What is WordPress and why should learn about wordpress?
Install composer use for Xampp on Windows
Guide to debug (debug) when programming C/C++ with Dev C++
Binary integer representation and binary operations
Create Gmail STMP and install for WordPress, Laravel, php…
Install and enable fileinfo extension in PHP 7 linux (centos,ubuntu)
The thing that limits your growth is the relationship you have
10 groups of customers that business people often encounter and how to behave professionally

THÊM BÌNH LUẬN Cancel reply

Dịch vụ thiết kế Wesbite

NỘI DUNG MỚI CẬP NHẬT

Step-by-step guide to installing Microsoft SQL Server and connecting to the database for beginners

Reasons Why People Are Increasingly Inexperienced in Life

PHP Data Types

Table (table) in SQL Server

Basic data types in C

Giới thiệu

web888.vn là chuyên trang chia sẻ và cập nhật tin tức công nghệ, chia sẻ kiến thức, kỹ năng. Chúng tôi rất cảm ơn và mong muốn nhận được nhiều phản hồi để có thể phục vụ quý bạn đọc tốt hơn !

Liên hệ quảng cáo: [email protected]

Kết nối với web888

© web888.vn - Tech888 Co .Ltd since 2019

Đăng nhập

Trở thành một phần của cộng đồng của chúng tôi!
Registration complete. Please check your email.
Đăng nhập bằng google
Đăng kýBạn quên mật khẩu?

Create an account

Welcome! Register for an account
The user name or email address is not correct.

Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our privacy policy.

Registration confirmation will be emailed to you.
Log in Lost your password?

Reset password

Recover your password
Password reset email has been sent.
The email could not be sent. Possible reason: your host may have disabled the mail function.
A password will be e-mailed to you.
Log in Register
×