In computer science and visualization, a canvas is a
container
A container is any receptacle or enclosure for holding a product used in storage, packaging, and transportation, including shipping.
Things kept inside of a container are protected on several sides by being inside of its structure. The term ...
that holds various drawing elements (lines, shapes, text, frames containing others elements, etc.). It takes its name from the
canvas
Canvas is an extremely durable Plain weave, plain-woven Cloth, fabric used for making sails, tents, Tent#Marquees and larger tents, marquees, backpacks, Shelter (building), shelters, as a Support (art), support for oil painting and for other ite ...
used in visual arts. It is sometimes called a
scene graph
A scene graph is a general data structure commonly used by vector-based graphics editing applications and modern computer games, which arranges the logical and often spatial representation of a graphical scene. It is a collection of nodes in a g ...
because it arranges the logical representation of a user interface or graphical scene. Some implementations also define the spatial representation and allow the user to interact with the elements via a
graphical user interface
A graphical user interface, or GUI, is a form of user interface that allows user (computing), users to human–computer interaction, interact with electronic devices through Graphics, graphical icon (computing), icons and visual indicators such ...
.
Library support
Various
free and open-source
Free and open-source software (FOSS) is software available under a Software license, license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term ...
canvas or scene-graph
libraries
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
allow developers to construct a user interface and/or user-interface elements for their computer programs.
Examples of free and open-source scene-graph canvas options include:
* in
CEvas (in EFL)from the
Enlightenment
Enlightenment or enlighten may refer to:
Age of Enlightenment
* Age of Enlightenment, period in Western intellectual history from the late 17th to late 18th century, centered in France but also encompassing (alphabetically by country or culture): ...
project
* in
C, Clutter, associated with the
GNOME
A gnome () is a mythological creature and diminutive spirit in Renaissance magic and alchemy, introduced by Paracelsus in the 16th century and widely adopted by authors, including those of modern fantasy literature. They are typically depict ...
project
* in
C,
GTK Scene Graph Kit
GTK Scene Graph Kit (GSK) is the rendering and scene graph API for GTK introduced with version 3.90. GSK lies between the graphical control elements (widgets) and the rendering.
Like GDK, GSK is part of GTK and licensed under the GNU Lesser G ...
(GSK)
* in
C++ or optionally in
Qt's own markup language
QML
QML (Qt Meta-object Language) is a user interface markup language. It is a declarative language (similar to CSS and JSON) for designing user interface–centric applications. Inline JavaScript code handles imperative aspects. It is associate ...
:
Qt Quick
Qt Quick is a free software application framework developed and maintained by the Qt Project within the Qt framework. It provides a way of building custom, highly dynamic graphical user interfaces with fluid transitions and effects, which are ...
, provides
scenegraph associated with the Qt project
* in
C++,
OpenSceneGraph, a 3D graphics API using
OpenGL
OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
* in
C++, the
OGRE
An ogre (feminine: ogress) is a legendary monster depicted as a large, hideous, man-like being that eats ordinary human beings, especially infants and children. Ogres frequently feature in mythology, folklore, and fiction throughout the world ...
engine, based on a scene graph, supports multiple scene managers
* in
C++,
OpenSG, a scene-graph system for real-time graphics, with clustering support and multi-thread safety
* in
C++, the
FlightGear Flight Simulator uses a custom Canvas system (
LGPL
The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
'ed via SimGear) that is hardware-accelerated using
OpenSceneGraph/
OpenGL
OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
, OpenVG/ShivaVG
The FlightGear Canvas system* in
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, the
Java FX scene graph with 2D and 3D functionality
* in
Tcl
TCL or Tcl or TCLs may refer to:
Business
* TCL Technology, a Chinese consumer electronics and appliance company
** TCL Electronics, a subsidiary of TCL Technology
* Texas Collegiate League, a collegiate baseball league
* Trade Centre Limited ...
and other languages such as
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
,
Python (
Tkinter
Tkinter is a binding to the Tk GUI toolkit for Python. It is the standard Python interface to the Tk GUI toolkit, and is Python's ''de facto'' standard GUI. Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Pyth ...
), and
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
, the
Tk toolkit provides a
canvas
widget for 2D graphics
* in
Tcl
TCL or Tcl or TCLs may refer to:
Business
* TCL Technology, a Chinese consumer electronics and appliance company
** TCL Electronics, a subsidiary of TCL Technology
* Texas Collegiate League, a collegiate baseball league
* Trade Centre Limited ...
and other languages such as
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
and
Python,
TkZinc is an extended replacement for the Tk canvas, which adds support for hierarchical grouping, clipping, affine transformations, anti-aliasing, and specific items for air traffic control.
Some canvas modules within various libraries do not provide the power of a full scene-graph - they operate at a lower level which requires programmers to provide code such as mapping mouse-clicks to objects in the canvas. Examples of libraries which include such a canvas module include:
* in
C++,
KDE Plasma Workspaces
KDE Plasma is a graphical shell developed by the KDE community for Unix-like operating systems. It serves as the interface layer between the user and the operating system, providing a graphical user interface (GUI) and workspace environment for ...
br>
Coronacanvas
* the
Canvas element
The HTML canvas element allows for dynamic, scriptable rendering of 2D shapes and bitmap images. Introduced in HTML5, it is a low level, procedural model that updates a bitmap. The element also helps in making 2D games.
While the element ...
in
HTML5
HTML5 (Hypertext Markup Language 5) is a markup language used for structuring and presenting hypertext documents on the World Wide Web. It was the fifth and final major HTML version that is now a retired World Wide Web Consortium (W3C) recommend ...
* for
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, the
AWT librar
Canvas* for
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, the
Java FX librar
Canvas* for
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, the
Swing librar
Canvas* for
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, the
SWT librar
Canvas associated with
Eclipse
An eclipse is an astronomical event which occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ...
* for
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
-like
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
, the
GWT librar
Canvas* in
C++, th
papyrus Canvas librarywhich renders using the
Cairo (graphics)
Cairo (stylized as cairo) is an Open-source software, open-source graphics library that provides a vector graphics-based, device-independent Application programming interface, API for software developers. It provides primitives for Plane (mathe ...
library
* in
Ccrcanvas a
GTK
GTK (formerly GIMP ToolKit and GTK+) is a free software cross-platform widget toolkit for creating graphical user interfaces (GUIs). It is licensed under the terms of the GNU Lesser General Public License, allowing both Free software, free and ...
canvas
widget which renders using the
Cairo (graphics)
Cairo (stylized as cairo) is an Open-source software, open-source graphics library that provides a vector graphics-based, device-independent Application programming interface, API for software developers. It provides primitives for Plane (mathe ...
library
* in
CGooCanvas a
GTK
GTK (formerly GIMP ToolKit and GTK+) is a free software cross-platform widget toolkit for creating graphical user interfaces (GUIs). It is licensed under the terms of the GNU Lesser General Public License, allowing both Free software, free and ...
canvas
widget which renders using the
Cairo (graphics)
Cairo (stylized as cairo) is an Open-source software, open-source graphics library that provides a vector graphics-based, device-independent Application programming interface, API for software developers. It provides primitives for Plane (mathe ...
library
Proprietary canvas libraries include, for example:
* the
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
Win32
The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running. Programs can acces ...
br>
Canvas
References
{{Reflist
Graphical user interface elements