2D computer graphics: Difference between revisions

Content deleted Content added
m replaced uncommon white space characters in {{Short description}} with common spaces
m Fixed a reference. Please see Category:CS1 maint: numeric names: authors list.
 
(14 intermediate revisions by 8 users not shown)
Line 13:
2D computer graphics started in the 1950s, based on [[vector graphics|vector graphics devices]]. These were largely supplanted by [[raster graphics|raster-based devices]] in the following decades. The [[PostScript]] language and the [[X Window System]] protocol were landmark developments in the field.
 
==Techniques==
2D graphics models may combine [[2D geometric model|geometric model]]s (also called [[vector graphics]]), digital images (also called [[raster graphics]]), text to be [[typesetting|typeset]] (defined by content, [[Typeface|font]] style and size, color, position, and orientation), mathematical [[function (mathematics)|function]]s and [[equation]]s, and more. These components can be modified and manipulated by two-dimensional [[Transformation (geometry)|geometric transformation]]s such as [[translation (geometry)|translation]], [[rotation]], and [[Scaling (geometry)|scaling]].
In [[object-oriented graphics]], the image is described indirectly by an [[object (computer science)|object]] endowed with a self-[[rendering (computer graphics)|rendering]] [[method (computer science)|method]]—a procedure that assigns colors to the image [[pixel]]s by an arbitrary algorithm. Complex models can be built by combining simpler objects, in the [[paradigms]] of [[object-oriented programming]].
 
==Background (geometry)==
===Geometry===
{{Duplication|date=May 2022|section=y|dupe=Translation (geometry)|dupe2=Rotation (geometry)|discuss=Talk:2D computer graphics#Duplication}}
{{further|Rotations and reflections in two dimensions}}
 
<!-- content from article translation (physics) has been merged with this article {{Merge from|Translation (physics)|date=December 2010}}-->
<!-- added references {{refimprove|date=December 2007}}-->
[[File:Traslazione OK.svg|right|thumb|A translation moves every point of a figure or a space by the same amount in a given direction.]]
[[File:Simx2=transl OK.svg|right|thumb|A [[reflection (mathematics)|reflection]] against an axis followed by a reflection against a second axis parallel to the first one results in a total motion which is a translation.]]
 
In [[Euclidean geometry]], a ''[[translation (geometry)]]'' moves every point a constant distance in a specified direction. A translation can be described as a [[Euclidean group|rigid motion]]: other rigid motions include rotations and reflections. A translation can also be interpreted as the addition of a constant [[vector space|vector]] to every point, or as shifting the [[origin (mathematics)|origin]] of the [[coordinate system]]. A ''[[shift operator|translation operator]]'' is an [[operator (mathematics)|operator]] <math>T_\mathbf{\delta}</math> such that <math>T_\mathbf{\delta} f(\mathbf{v}) = f(\mathbf{v}+\mathbf{\delta}).</math>
Line 34 ⟶ 32:
:''E''(''n'' ) ''/ T'' ≅ ''O''(''n'' ).
 
====Translation====<!-- This section is linked from [[affine transformation]]. -->
 
Since a translation is an [[affine transformation]] but not a [[linear transformation]], [[homogeneous coordinates]] are normally used to represent the translation operator by a [[matrix (mathematics)|matrix]] and thus to make it linear. Thus we write the 3-dimensional vector '''w''' = (''w''<sub>''x''</sub>, ''w''<sub>''y''</sub>, ''w''<sub>''z''</sub>) using 4 homogeneous coordinates as '''w''' = (''w''<sub>''x''</sub>, ''w''<sub>''y''</sub>, ''w''<sub>''z''</sub>, 1).<ref>Richard Paul, 1981, [https://books.google.com/books?id=UzZ3LAYqvRkC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false Robot manipulators: mathematics, programming, and control : the computer control of robot manipulators], MIT Press, Cambridge, MA</ref>
 
To translate an object by a [[vector (geometry)|vector]] '''v''', each homogeneous vector '''p''' (written in homogeneous coordinates) would need to be multiplied by this '''translation matrix''':
Line 72 ⟶ 70:
Because addition of vectors is [[commutative]], multiplication of translation matrices is therefore also commutative (unlike multiplication of arbitrary matrices).
 
====Rotation====
 
In [[linear algebra]], a ''[[rotation matrix]]'' is a [[matrix (mathematics)|matrix]] that is used to perform a [[rotation (mathematics)|rotation]] in [[Euclidean space]].
Line 93 ⟶ 91:
The [[set (mathematics)|set]] of all such matrices of size ''n'' forms a [[group (mathematics)|group]], known as the [[special orthogonal group]] {{math|SO(''n'')}}.
 
=====In two dimensions=====
[[File:Counterclockwise rotation SVG.svg|thumb|A counterclockwise rotation of a vector through angle ''θ''. The vector is initially aligned with the x-axis.]]
In two dimensions every rotation matrix has the following form:
Line 130 ⟶ 128:
\end{bmatrix}\,</math>.
 
=====Non-standard orientation of the coordinate system=====
 
[[File:Clockwise rotation SVG.svg|thumb|A rotation through angle ''θ'' with non-standard axes]]
If a standard [[Orientation (space)|right-handed]] [[Cartesian coordinate system]] is used, with the ''x'' axis to the right and the ''y'' axis up, the rotation R(''θ'') is counterclockwise. If a left-handed Cartesian coordinate system is used, with ''x'' directed to the right but ''y'' directed down, R(''θ'') is clockwise. Such non-standard orientations are rarely used in mathematics but are common in 2D computer graphics, which often have the origin in the top left corner and the ''y''-axis down the screen or page.<ref>{{Citation|url=http://www.w3.org/TR/SVG/coords.html#InitialCoordinateSystem|title=Scalable Vector Graphics -- the initial coordinate system|authorwebsite=W3C recommendationw3.org|year=2003}}</ref>
 
See [[Rotation matrix#Ambiguities|below]] for other alternative conventions which may change the sense of the rotation produced by a [[rotation matrix]].
 
=====Common rotations=====
 
Particularly useful are the matrices for 90° and 180° rotations:
Line 154 ⟶ 152:
\end{bmatrix}</math> (270° counterclockwise rotation, the same as a 90° clockwise rotation)
 
===GeometryScaling===
{{Refimprove|date=April 2008}}
In [[Euclidean geometry]], '''uniform scaling''' ('''[[isotropic]] scaling''',<ref>{{cite web|format=PowerPoint|last1=Durand|last2=Cutler|url=http://groups.csail.mit.edu/graphics/classes/6.837/F03/lectures/04_transformations.ppt |title=Transformations|publisher=Massachusetts Institute of Technology|access-date =12 September 2008}}</ref> '''homogeneous dilation''', [[Homothetic transformation|homothety]]) is a [[linear transformation]] that enlarges (increases) or shrinks (diminishes) objects by a [[scale factor]] that is the same in all directions. The result of uniform scaling is [[Similarity (geometry)|similar]] (in the geometric sense) to the original. A scale factor of 1 is normally allowed, so that congruent shapes are also classed as similar. (Some school text books specifically exclude this possibility, just as some exclude squares from being rectangles or circles from being ellipses.)
Line 159 ⟶ 158:
More general is '''scaling''' with a separate scale factor for each axis direction. '''Non-uniform scaling''' ('''[[anisotropic]] scaling''', '''inhomogeneous dilation''') is obtained when at least one of the scaling factors is different from the others; a special case is '''directional scaling''' or '''stretching''' (in one direction). Non-uniform scaling changes the [[shape]] of the object; e.g. a square may change into a rectangle, or into a parallelogram if the sides of the square are not parallel to the scaling axes (the angles between lines parallel to the axes are preserved, but not all angles).
 
====Scaling====
A scaling can be represented by a scaling matrix. To scale an object by a [[Vector (geometric)|vector]] ''v'' = (''v<sub>x</sub>, v<sub>y</sub>, v<sub>z</sub>''), each point ''p'' = (''p<sub>x</sub>, p<sub>y</sub>, p<sub>z</sub>'') would need to be multiplied with this [[scaling matrix]]:
:<math> S_v =
Line 194 ⟶ 192:
Scaling in the most general sense is any [[affine transformation]] with a [[diagonalizable matrix]]. It includes the case that the three directions of scaling are not perpendicular. It includes also the case that one or more scale factors are equal to zero ([[Projection (linear algebra)|projection]]), and the case of one or more negative scale factors. The latter corresponds to a combination of scaling proper and a kind of reflection: along lines in a particular direction we take the reflection in the point of intersection with a plane that need not be perpendicular; therefore it is more general than ordinary reflection in the plane.
 
====Using homogeneous coordinates====
In [[projective geometry]], often used in [[computer graphics]], points are represented using [[homogeneous coordinates]]. To scale an object by a [[Vector (geometric)|vector]] ''v'' = (''v<sub>x</sub>, v<sub>y</sub>, v<sub>z</sub>''), each homogeneous coordinate vector ''p'' = (''p<sub>x</sub>, p<sub>y</sub>, p<sub>z</sub>'', 1) would need to be multiplied with this [[projective transformation]] matrix:
 
Line 257 ⟶ 255:
\end{bmatrix}.
</math>
 
==Techniques==
 
===Direct painting===
Line 307:
*[[Ricoh]]'s [[Picture Processing Unit|PPU]] and [[Super Nintendo Entertainment System technical specifications|S-PPU]]
*[[Sega]]'s [[Video display controller|VDP]], [[Sega Super Scaler|Super Scaler]], [[Sega System 16|315-5011/315-5012]] and [[Sega System 16|315-5196/315-5197]]
*[[Texas Instruments]]' [[TMS9918]]
*[[Yamaha Corporation|Yamaha]]'s [[Yamaha V9938|V9938]], [[Yamaha V9958|V9958]] and [[Mega Drive#Technical specifications|YM7101 VDP]]
 
Line 314:
The user interface within individual software applications is typically 2D in nature as well, due in part to the fact that most common [[input device]]s, such as the [[computer mouse|mouse]], are constrained to two dimensions of movement.
 
2D graphics are very important in the control peripherals such as printers, plotters, sheet cutting machines, etc. They were also used in most early [[video game]]s; and are still used for card and board games such as [[Solitaire (game)|solitaire]], [[chess]], [[mahjongg]], etc.
 
2D graphics editors or ''drawing programs'' are application-level software for the creation of images, diagrams and illustrations by direct manipulation (through the mouse, [[graphics tablet]], or similar device) of 2D computer graphics primitives. These editors generally provide [[2D geometric primitive|geometric primitives]] as well as [[digital image]]s; and some even support procedural models. The illustration is usually represented internally as a layered model, often with a hierarchical structure to make editing more convenient. These editors generally output [[graphics file format|graphics files]] where the layers and primitives are separately preserved in their original form. [[MacDraw]], introduced in 1984 with the [[Apple Macintosh|Macintosh]] line of computers, was an early example of this class; recent examples are the commercial products [[Adobe Illustrator]] and [[CorelDRAW]], and the free editors such as [[xfig]] or [[Inkscape]]. There are also many 2D graphics editors specialized for certain types of drawings such as electrical, electronic and VLSI diagrams, topographic maps, computer fonts, etc.
Line 321:
 
==Developmental animation==
With the resurgence<ref name="Pile">{{cite book |last=Pile |first=John Jr. |author-link=John Pile Jr |date=May 2013 |title=2D Graphics Programming for Games |url=http://www.crcpress.com/product/isbn/9781466501898 |location=New York, NY |publisher=CRC Press |isbn=978-1466501898 }}</ref>{{rp|8}} of 2D animation, free and proprietary software packages have become widely available for amateurs and professional animators. The principal issue with 2D animation is labor requirements.{{citation needed|date=April 2013}} With software like [[RETAS]] [[UbiArt Framework]] and [[Adobe After Effects]], coloring and compositing can be done in less time.{{citation needed|date=April 2013}}
Various approaches have been developed<ref name="Pile"/>{{rp|38}} to aid and speed up the process of digital 2D animation. For example, by [[vector graphics editor|generating vector artwork]] in a tool like [[Adobe Flash]] an artist may employ software-driven automatic coloring and [[tweening|in-betweening]].
 
Programs like [[Blender (software)|Blender]] or [[Adobe Substance]] allow the user to do either 3D animation, 2D animation or combine both in its software allowing experimentation with multiple forms of animation.<ref>{{Cite web|url=https://www.blender.org/|title=blender.org - Home of the Blender project - Free and Open 3D Creation Software|last=Foundation|first=Blender|website=blender.org|language=en|access-date=2019-04-24}}</ref>
 
==See also==
Line 353:
{{DEFAULTSORT:2d Computer Graphics}}
[[Category:Computer graphics]]
[[Category:Euclidean plane geometry]]