A | B | C | D | E | F | G | H | CH | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
HTML |
---|
Comparisons |
The canvas element is part of HTML5 and allows for dynamic, scriptable rendering of 2D shapes and bitmap images. It is a low level, procedural model that updates a bitmap. HTML5 Canvas also helps in making 2D games.
While the HTML5 canvas offers its own 2D drawing API, it also supports the WebGL API to allow 3D rendering with OpenGL ES.
History
Canvas was initially introduced by Apple for use in their own Mac OS X WebKit component in 2004,[1] powering applications like Dashboard widgets and the Safari browser. Later, in 2005, it was adopted in version 1.8 of Gecko browsers,[2] and Opera in 2006,[3] and standardized by the Web Hypertext Application Technology Working Group (WHATWG) on new proposed specifications for next generation web technologies.[citation needed]
Usage
A canvas
consists of a drawable region defined in HTML code with height and width attributes. JavaScript code may access the area through a full set of drawing functions similar to those of other common 2D APIs, thus allowing for dynamically generated graphics. Some anticipated uses of canvas include building graphs, animations, games, and image composition.
Interacting with the canvas involves obtaining the canvas' rendering context, which determines whether to use the canvas API, WebGL, or WebGL2 rendering context.
Example
The following code creates a Canvas element in an HTML page:
<canvas id="example" width="200" height="200">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
Using JavaScript, you can draw on the canvas:
var example = document.getElementById('example');
var context = example.getContext('2d');
context.fillStyle = 'red';
context.fillRect(30, 30, 50, 50);
This code draws a red rectangle on the screen.
The Canvas API also provides save()
and restore()
, for saving and restoring all the canvas context's attributes.
Canvas element size versus drawing surface size
A canvas actually has two sizes: the size of the element itself and the size of the element's drawing surface. Setting the element's width and height attributes sets both of these sizes; CSS attributes affect only the element's size and not the drawing surface.
By default, both the canvas element's size and the size of its drawing surface is 300 screen pixels wide and 150 screen pixels high. In the listing shown in the example, which uses CSS to set the canvas element's size, the size of the element is 600 pixels wide and 300 pixels high, but the size of the drawing surface remains unchanged at the default value of 300 pixels × 150 pixels. When a canvas element's size does not match the size of its drawing surface, the browser scales the drawing surface to fit the element (which may result in surprising and unwanted effects).
Example setting element size and drawing surface size to different values:
<!DOCTYPE html>
<html>
<head>
<title>Canvas element size: 600 x 300,
Canvas drawing surface size: 300 x 150</title>
<style>
body {
background: #dddddd;
}
#canvas {
margin: 20px;
padding: 20px;
background: #ffffff;
border: thin inset #aaaaaa;
width: 600px;
height: 300px;
}
</style>
</head>
<body>
<canvas id="canvas">
Canvas not supported
</canvas>
</body>
</html>
Canvas versus Scalable Vector Graphics (SVG)
SVG is an alternative approach to drawing shapes in browsers.[4] Unlike canvas, which is raster-based, SVG is vector-based, so that each drawn shape is remembered as an object in a scene graph or Document Object Model, which is subsequently rendered to a bitmap. This means that if attributes of an SVG object are changed, the browser can automatically re-render the scene.
Canvas objects, on the other hand, are drawn in immediate mode. In the canvas example above, the rectangle draw operation modifies the canvas, and its representation as a rectangle is forgotten by the system. If the rectangle's position were to be changed, the canvas would need to be redrawn, including any objects that might have been covered by the rectangle. In the equivalent SVG case, one could simply change the position attributes of the rectangle and the browser would determine how to repaint it. There are additional JavaScript libraries that abstract the canvas model to have svg-like scene capabilities within the canvas element. Multiple canvas layers can also be used, meaning that only specific layers need to be recreated when changes are required.
SVG images are represented in XML, and complex scenes can be created and maintained with XML editing tools.
The SVG scene graph enables event handlers to be associated with objects, so a rectangle may respond to an onClick
event. To get the same functionality with canvas, one must manually match the coordinates of the mouse click with the coordinates of the drawn rectangle to determine whether it was clicked.
Conceptually, canvas is a lower-level API upon which higher-level interfaces might be built (for example, SVG support). There are JavaScript libraries that provide partial SVG implementations using canvas for browsers that do not provide SVG but support canvas, such as the browsers in Android 2.x. However, this is not normally the case—they are independent standards. The situation is complicated because there are scene graph libraries for canvas, and SVG has some bitmap manipulation functionality.
Reactions
At the time of its introduction, the canvas element was met with mixed reactions from the web standards community. There have been arguments against Apple's decision to create a new proprietary element instead of supporting the SVG standard. There are other concerns about syntax, such as the absence of a namespace.[5]
Intellectual property over canvas
On March 14, 2007, WebKit developer Dave Hyatt forwarded an email from Apple's Senior Patent Counsel, Helene Plotka Workman,[6] which stated that Apple reserved all intellectual property rights relative to WHATWG's Web Applications 1.0 Working Draft, dated March 24, 2005, Section 10.1, entitled “Graphics: The bitmap canvas”,[7] but left the door open to licensing the patents should the specification be transferred to a standards body with a formal patent policy. This caused considerable discussion among web developers and raised questions concerning the WHATWG's lack of a policy on patents in comparison to the World Wide Web Consortium (W3C)'s explicit favoring of royalty-free licenses. Apple later disclosed the patents under the W3C's royalty-free patent licensing terms.[8] The disclosure means that Apple is required to provide royalty-free licensing for the patent whenever the Canvas element becomes part of a future W3C recommendation created by the HTML working group.[9]
Privacy concerns
Canvas fingerprinting is one of a number of browser fingerprinting techniques for tracking online users that allow websites to identify and track visitors using HTML5 canvas element. The technique received wide media coverage in 2014,[10][11][12][13] after researchers from Princeton University and KU Leuven University described it in their paper The Web never forgets.[14] The privacy concerns regarding canvas fingerprinting center around the fact that even deleting cookies and clearing the cache will not be sufficient for users to avoid online tracking.
Browser support
The element is supported by the current versions of Mozilla Firefox, Google Chrome, Internet Explorer, Safari, Konqueror, Opera[15] and Microsoft Edge.[16]
See also
- Anti-Grain Geometry (AGG)
- Cairo (graphics)
- Display PostScript
- Graphics Device Interface (GDI+)
- Quartz 2D
- WebGL
References
- ^ Ian Hixie (2004-07-12). "Extending HTML". Retrieved 2011-06-13.
- ^ Mozilla Developer Connection. "HTMLCanvasElement". Archived from the original on 2011-06-04. Retrieved 2011-06-13.
- ^ "Opera 9.0 changelog". Archived from the original on 2012-09-10. Retrieved 2006-06-20.
- ^ "Scalable Vector Graphics | CorelDRAW". www.coreldraw.com. Retrieved 2022-09-23.
- ^ Ian Hickson remarks regarding canvas and other Apple extensions to HTML
- ^ "[whatwg] Web Applications 1.0 Draft, David Hyatt, Wed Mar 14 14:31:53 PDT 2007". Archived from the original on 2007-05-02. Retrieved 2007-05-01.
- ^ Web Applications 1.0 Early Working Draft - Dynamic graphics: The bitmap canvas
- ^ HTML Working Group Patent Policy Status – Known Disclosures
- ^ W3C patent policy in use by HTML working group
- ^ Knibbs, Kate (July 21, 2014). "What You Need to Know About the Sneakiest New Online Tracking Tool". Gizmodo. Retrieved July 21, 2014.
- ^ Joseph Steinberg (July 23, 2014). "You Are Being Tracked Online By A Sneaky New Technology -- Here's What You Need To Know". Forbes. Retrieved November 15, 2014.
- ^ Angwin, Julia (July 21, 2014). "Meet the Online Tracking Device That is Virtually Impossible to Block". ProPublica. Retrieved July 21, 2014.
- ^ Kirk, Jeremy (July 21, 2014). "Stealthy Web tracking tools pose increasing privacy risks to users". PC World. Retrieved July 21, 2014.
- ^ Acar, Gunes; Eubank, Christian; Englehardt, Steven; Juarez, Marc; Narayanan, Arvind; Diaz, Claudia (July 24, 2014). "The Web never forgets: Persistent tracking mechanisms in the wild". Retrieved July 24, 2014.
- ^ Sucan, Mihai (4 Feb 2010). "SVG or Canvas? Сhoosing between the two". Opera Software. Archived from the original on 23 June 2010. Retrieved 3 May 2010.
- ^ "Canvas, Microsoft Edge documentation".
External links
- The
canvas
element, W3C, 2014-10-28, retrieved 2015-01-09 - HTML Canvas 2D Context, W3C, 2014-08-21, retrieved 2015-01-09
- Canvas description in WHATWG Web Applications draft specifications
- Canvas reference page in Apple Developers Connection
- Basic Canvas Tutorial on Opera Developer Community
- Canvas tutorial and introductory page on Mozilla Developer center Archived 2012-08-03 at the Wayback Machine
Text je dostupný za podmienok Creative Commons Attribution/Share-Alike License 3.0 Unported; prípadne za ďalších podmienok. Podrobnejšie informácie nájdete na stránke Podmienky použitia.
Číňané
Časová osa ruské invaze na Ukrajinu (2022)
Černá Hora
Česká terminologická databáze knihovnictví a informační vědy
Česká verze Wikipedie
Česká Wikipedie
České vysoké učení technické v Praze
Československá armáda
Československá národní rada
Československo
Ču Jou-sung
Říše Čching
Říše Ming
Řím
Šablona:Citation
Šablona:Cite web
1. duben
1. květen
1. září
10. duben
10. prosinec
11. duben
12. duben
12. květen
13. červen
13. duben
14. duben
14. srpen
1488
15. červen
15. duben
15. květen
15. září
1523
1555
1584
1585
16. duben
16. leden
1619
1651
1652
1661
1671
1673
1674
1677
17. březen
17. duben
1706
1711
1717
1719
1729
1730
1735
1742
1752
1757
1763
1767
1774
1776
1782
1783
1784
1785
1790
1796
18. únor
18. duben
18. leden
1805
1811
1814
1816
1818
1822
1828
1829
1837
1838
1849
1852
1855
1862
1864
1868
1870
1871
1876
1878
1880
1882
1885
1886
1891
1892
1893
1895
19. duben
19. listopad
1900
1904
1906
1907
1910
1912
1913
1917
1918
1919
1920
1921
1922
1924
1926
1929
1930
1933
1935
1936
1940
1942
1945
1946
1947
1949
1950
1952
1953
1958
1960
1965
1973
1976
1977
1985
1987
1989
1990
1992
1995
2. červen
2. duben
2. květen
20. duben
2000
2001
2002
2003
2005
2008
2010
2012
2015
2017
2019
2020
2023
21. červen
21. červenec
21. březen
22. duben
23. duben
24. březen
24. duben
24. listopad
24. prosinec
25. duben
25. prosinec
26. duben
27. duben
28. duben
29. únor
29. březen
29. duben
29. srpen
3. únor
3. duben
30. duben
31. červenec
31. březen
31. prosinec
4. říjen
4. duben
4. květen
43 př. n. l.
5. říjen
5. březen
5. duben
5. květen
6. duben
7. duben
753 př. n. l.
8. duben
8. listopad
9. říjen
9. duben
9. září
Aš
ActiveX
Alžběta II.
Alžběta Vilemína Württemberská
Alexandra
Alt attribute
Amálie Vilemína Brunšvicko-Lüneburská
Andie MacDowell
Anthony Quinn
Antonín Kammel
Antonín Novák (houslista)
API
Apple
Apple II
Armáda Spojených států amerických
Article element
Autoritní kontrola
Azovstal
Bedřich Beneš Buchlovan
Benutzer:Kurt Jansson/Vortrag auf dem 19C3
Benutzer:Kurt Jansson/Vortrag auf dem 19C3
BiggestWiki
Bitva o Madagaskar
Bitva o Mariupol
Bitva u Liberce
Bitva u Mutiny
Bitva u Puebly
Blink element
Bořivoj Lůžek
Bob Hurikán
Bologna
Bracket#Angle brackets
Brasília
Brazílie
Britská armáda
Browser engine
Browser Object Model
Bzenecká lípa
Cache (computing)
CamelCase
Canvas element
Cascading Style Sheets
Character encodings in HTML
Charles-Joseph de Flahaut
Charles Darwin
Charlotte Brontëová
Chu Čeng-jen
Commons:Featured pictures/cs
Comparison of browser engines
Comparison of document markup languages
Comparison of stylesheet languages
CSS
CSS#Sources
CSS animations
CSS box model
CSS Flexible Box Layout
CSS grid layout
CSS image replacement
CSS Zen Garden
Diff
Digital container format
Div and span
Document file format
Document Object Model
Document Style Semantics and Specification Language
DokuWiki
Doněcké akademické oblastní činoherní divadlo
Druhá světová válka
Duben
Dynamic HTML
Dynastie Jižní Ming
Edita Štaubertová
Ekonomické důsledky ruské invaze na Ukrajinu (2022)
Emilia Galotti
Emmanuel Macron
Encyclopædia Britannica
Encyklopedie
Encyklopedie Navajo
Evoluce
Fantasy
Fault-tolerant system
Ferdinand Peroutka
Fieldset
File:HTML5 logo and wordmark.svg
File:Question book-new.svg
File:Wikibooks-logo.svg
Filename extension
Filmová promítačka
First-person shooter
Font family (HTML)
Formatting Output Specification Instance
Frame (World Wide Web)
François Athanase de Charette de la Contrie
Francie
Francouzská armáda
Francouzská intervence v Mexiku
Francouzská národní knihovna
František Ferdinand Šamberk
František Suchý Pražský
Fredrik Bajer
Friedrich Fröbel
Gemeinsame Normdatei
Georg Joseph Kamel
Glen Hansard
Gotthold Ephraim Lessing
Gregoriánský kalendář
Guy Lafleur
Hannibal Goodwin
Havajština
Help:HTML in wikitext
Help:Maintenance template removal
Help:Referencing for beginners
Hippolyte Taine
Hlavní strana
Hnutí Svoboda (Slovinsko)
Holy grail (web design)
Honolulu
Hospodářský růst
HTML
HTML5
HTML5 audio
HTML5 video
HTML attribute
HTML editor
HTML element
HTML element#Images and objects
HTML elements
HTM (disambiguation)
Humphry Repton
Hyperlink
Hypertext
HyperText Markup Language
Iggy Pop
Ignacio Zaragoza
Ignatius Krahl
Ingenuity
International Standard Book Number
Internetová diskuse
Internetový bot
Internet Explorer
IP adresa
Isaac Asimov
Itálie
Ivan Petrovič Kulibin
Janez Janša
Jan Štrobl
Jan Kostrhun
Jan Pavel II.
Jan van Riebeeck
Jarmila Stojčevská
Jaroslav Hýbl
Jaroslav Hutka
Jaroslav Kvapil (skladatel)
JavaScript
JavaScript Style Sheets
Jean-Baptiste Biot
Jiří Čepelák
Jiří Hrubeš
Jiřina Šedinová
Johann Christian Ferdinand Höfer
John Law
Josef I. Habsburský
Joseph Vaz
Jozef Herda
Judita Čeřovská
Kaligrafie
Kapské Město
Karel Balling (chemik)
Karel Pippich
Karlštejn
Kategorie:Čas
Kategorie:Články podle témat
Kategorie:Život
Kategorie:Dorozumívání
Kategorie:Geografie
Kategorie:Historie
Kategorie:Hlavní kategorie
Kategorie:Informace
Kategorie:Kultura
Kategorie:Lidé
Kategorie:Matematika
Kategorie:Příroda
Kategorie:Politika
Kategorie:Právo
Kategorie:Rekordy
Kategorie:Seznamy
Kategorie:Společnost
Kategorie:Sport
Kategorie:Technika
Kategorie:Umění
Kategorie:Věda
Kategorie:Vojenství
Kategorie:Vzdělávání
Kategorie:Zdravotnictví
Klaus Schulze
Kuo-c’-ťien
Květen
Ladislav Koubek
Ladislav Pavelka
Language code
Lee de Forest
Leopold Antonín Podstatský
Less (stylesheet language)
Less (style sheet language)
Library of Congress Control Number
Lidé a země
Listopad
List of style sheet languages
List of XML and HTML character entity references
Lodovico Carracci
Louis-Auguste Bisson
Lynx (browser)
Madagaskar
Maia Sanduová
Manuel Estiarte
Marcus Antonius
Maria Anna Sala
Mariupol
Markup (computer programming)
Markup language
Marquee element
Meda Mládková
MediaWiki
Media type
Metapedie
Meta element
Mezinárodní měnový fond
Michel Rolle
Miloš Zeman
Mittelbau-Dora
Moldavsko
Mozilla Firefox
Mwai Kibaki
Nápověda:Úvod
Nápověda:Úvod pro nováčky
Národní knihovna České republiky
Národní knihovna Izraele
Návrhový vzor
Nadace Wikimedia
Nanking
Necyklopedie
Nikola Buranská
Norbert Frýd
Nosticovo divadlo
Nupedia
Odbory
Olbram Zoubek
Open file format
Opera (web browser)
Osecký klášter
Otevřený software
Oxford English Dictionary
Pandemie covidu-19
Pandemie covidu-19 v Česku
Partyzán
Paul Karrer
Pavel Zářecký
Pavol Mešťan
Pečeť
Perseverance
Petr Nečas
Petr Pokorný (teolog)
Petr Rak
Plnotext
Plugin
Podněstří
Polsko
Portál:Aktuality
Portál:Doprava
Portál:Geografie
Portál:Historie
Portál:Kultura
Portál:Lidé
Portál:Náboženství
Portál:Obsah
Portál:Příroda
Portál:Sport
PostCSS
Praha
Pravda (noviny)
Prezident
Programovací jazyk
Q171#identifiers
Q171#identifiers|Editovat na Wikidatech
Qt (software)
Quirks mode
Radim Uzel
Refreshable Braille display
Responsive web design
Rio de Janeiro
Robert Fico
Robert Golob
Robert Kaliňák
Robert Saudek
Robert Smith (hudebník)
Ruská invaze na Ukrajinu (2022)
Rusko
Sýrie
Safari (web browser)
Sass (stylesheet language)
Sass (style sheet language)
Scripting language
Sedmiletá válka
Semantics
Semantic Web
Separation of concerns
Separation of content and presentation
Seznam českých wiki encyklopedií
Slávka Budínová
Slovenska demokratska stranka
Slovensko
Slovinsko
SMIL Timesheets
Sociální software
Software
Software release life cycle
Soubor:Andie MacDowell Cannes.jpg
Soubor:Anthony Quinn signed.JPG
Soubor:Apple-II.jpg
Soubor:Flag of Mars.svg
Soubor:GlenHansard.jpg
Soubor:HNL Wiki Wiki Bus.jpg
Soubor:Hutka.simecek.jpg
Soubor:IggyChesterRocks.jpg
Soubor:Manel Estiarte (Diada de Sant Jordi 2009).jpg
Soubor:Olbram-Zoubek.jpg
Soubor:Paul Karrer.jpg
Soubor:Persimmon and Three Yellow Tangerines.jpg
Soubor:Queen Elizabeth II March 2015.jpg
Soubor:Robert Smith of The Cure live in Singapore 1 August 2007.jpg
Speciální:Kategorie
Speciální:Nové stránky
Speciální:Statistika
Speciální:Zdroje knih/0-201-71499-X
Speciální:Zdroje knih/2-9520514-4-5
Speciální:Zdroje knih/9781448855575
Spojené státy americké
Standard Generalized Markup Language
Strojový překlad
Structured document
Stuttgart
Style sheet (desktop publishing)
Style sheet (web development)
Style sheet language
Stylish
Stylus (browser extension)
Stylus (stylesheet language)
Stylus (style sheet language)
Světová ekonomika
Třída T 47
Tableless web design
Template:CSS
Template:HTML
Template:Stylesheet languages
Template talk:CSS
Template talk:HTML
Template talk:Stylesheet languages
Teroristické útoky na Srí Lance 21. dubna 2019
Theodor Kašpárek
Tiskař
Turecko
TWiki
Type code
Ukrajina
Ulrich von Hutten
Unicode and HTML
Uniform Type Identifier
UseModWiki
User agent
User interface style sheet language
Václav Cigler
Vídeň
Věra Nerušilová
V-2
Vannevar Bush
Vichistická Francie
Viktor Janiš
Viktor Zvjahincev
Vláda Černé Hory
Vladimír Hulpach
Vlasta Prachatická
Vojtěch Říhovský
Volby prezidenta Francie 2022
Vzdušný prostor
W3C Markup Validation Service
Ward Cunningham
Web3D
WebCL
WebGL
WebGPU
Webový prohlížeč
Webpage
WebXR
Web browser
Web colors
Web content
Web design
Web page
Web server
Web storage
WHATWG
Wiki
Wikicitáty:Hlavní strana
Wikidata:Hlavní strana
Wikiknihy:Hlavní strana
Wikimedia Česká republika
Wikimedia Commons
Wikipedia:Verifiability
Wikipedie
Wikipedie:Údržba
Wikipedie:Časté chyby
Wikipedie:Často kladené otázky
Wikipedie:Článek týdne
Wikipedie:Článek týdne/2022
Wikipedie:Citování Wikipedie
Wikipedie:Dobré články
Wikipedie:Dobré články#Portály
Wikipedie:Kontakt
Wikipedie:Nejlepší články
Wikipedie:Obrázek týdne
Wikipedie:Obrázek týdne/2022
Wikipedie:Požadované články
Wikipedie:Pod lípou
Wikipedie:Portál Wikipedie
Wikipedie:Potřebuji pomoc
Wikipedie:Průvodce
Wikipedie:Seznam jazyků Wikipedie
Wikipedie:Velvyslanectví
Wikipedie:Vybraná výročí dne/květen
Wikipedie:WikiProjekt Kvalita/Články k rozšíření
Wikipedie:Zajímavosti
Wikipedie:Zajímavosti/2022
Wikipedie:Zdroje informací
WikiSkripta
Wikislovník:Hlavní strana
Wikiverzita:Hlavní strana
Wikizdroje:Hlavní strana
Wikizprávy:Hlavní strana
Wiki (rozcestník)
Wiki Wiki Shuttle
Wolfenstein 3D
World Wide Web
World Wide Web Consortium
WYSIWYG
XHTML
XHTML Basic
XHTML Mobile Profile
XSL
XSLT
Zdeněk Fiala
Značkovací jazyk
Zvukový film
Text je dostupný za podmienok Creative
Commons Attribution/Share-Alike License 3.0 Unported; prípadne za ďalších
podmienok.
Podrobnejšie informácie nájdete na stránke Podmienky
použitia.
www.astronomia.sk | www.biologia.sk | www.botanika.sk | www.dejiny.sk | www.economy.sk | www.elektrotechnika.sk | www.estetika.sk | www.farmakologia.sk | www.filozofia.sk | Fyzika | www.futurologia.sk | www.genetika.sk | www.chemia.sk | www.lingvistika.sk | www.politologia.sk | www.psychologia.sk | www.sexuologia.sk | www.sociologia.sk | www.veda.sk I www.zoologia.sk