HOME

TheInfoList




2D computer graphics is the computer-based generation of
digital image A digital image is an image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (day ...
s—mostly from two-dimensional models (such as 2D geometric models, text, and digital images) and by techniques specific to them. It may refer to the branch of
computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of computation, automation, a ...
that comprises such techniques or to the models themselves. 2D computer graphics are mainly used in applications that were originally developed upon traditional
printing Printing is a process for mass reproducing text and images An Synthetic aperture radar, SAR radar imaging, radar image acquired by the SIR-C/X-SAR radar on board the Space Shuttle Endeavour shows the Teide volcano. The city of Santa Cru ...

printing
and
drawing Drawing is a form of visual art The visual arts are art forms such as painting Painting is the practice of applying paint Paint is any pigmented liquid, liquefiable, or solid mastic composition that, after application to a su ...

drawing
technologies, such as
typography Typography is the art and technique of arranging type to make written language A written language is the representation of a spoken or gestural language A language is a structured system of communication used by humans, including ...

typography
,
cartography Cartography (; from χάρτης ''chartēs'', "papyrus, sheet of paper, map"; and γράφειν ''graphein'', "write") is the study and practice of making and using s. Combining , , and technique, cartography builds on the premise that rea ...
,
technical drawing Technical drawing, drafting or drawing, is the act and discipline Discipline is action ACTION is a bus operator in Canberra Canberra ( ) is the capital city of Australia. Founded following the Federation of Australia, federat ...

technical drawing
,
advertising Advertising is a marketing Marketing is the process of intentionally stimulating demand for and purchases of goods and services; potentially including selection of a target audience; selection of certain attributes or themes to emphasi ...

advertising
, etc. In those applications, the two-dimensional
image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (daytime vision), color vision, sco ...

image
is not just a representation of a real-world object, but an independent artifact with added semantic value; two-dimensional models are therefore preferred, because they give more direct control of the image than
3D computer graphics 3D computer graphics, sometimes called CGI, 3DCG or three-dimensional computer graphics (in contrast to 2D computer graphics 2D computer graphics is the Computer-generated imagery, computer-based generation of digital images—mostly from t ...
(whose approach is more akin to
photography Photography is the art Art is a diverse range of (products of) human activities Humans (''Homo sapiens'') are the most populous and widespread species of primates, characterized by bipedality, opposable thumbs, hairlessness, and int ...

photography
than to typography). In many domains, such as
desktop publishing Desktop publishing (DTP) is the creation of documents using page layout software on a personal ("desktop") personal computer, computer. It was first used almost exclusively for print publications, but now it also assists in the creation of variou ...
,
engineering Engineering is the use of scientific principles to design and build machines, structures, and other items, including bridges, tunnels, roads, vehicles, and buildings. The discipline of engineering encompasses a broad range of more speciali ...

engineering
, and
business Business is the activity of making one's living or making money by producing or buying and selling products (such as goods and services). Simply put, it is "any activity or enterprise entered into for profit." Having a business name A trad ...

business
, a description of a document based on 2D computer graphics techniques can be much smaller than the corresponding digital image—often by a factor of 1/1000 or more. This representation is also more flexible since it can be rendered at different
resolution Resolution(s) may refer to: Common meanings * Resolution (debate), the statement which is debated in policy debate * Resolution (law), a written motion adopted by a deliberative body * New Year's resolution, a commitment that an individual make ...
s to suit different
output device An output device is any piece of computer hardware Computer hardware includes the physical parts of a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Mode ...
s. For these reasons, documents and illustrations are often stored or transmitted as 2D graphic files. 2D computer graphics started in the 1950s, based on vector graphics devices. These were largely supplanted by raster-based devices in the following decades. The
PostScript PostScript (PS) is a page description language In digital printing, a page description language (PDL) is a computer language that describes the appearance of a printed page in a higher level than an actual output bitmap (or generally raster gra ...

PostScript
language and the
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system An operating system (OS) is system software that manages computer ...
protocol were landmark developments in the field.


2D graphics techniques

2D graphics models may combine
geometric model __NOTOC__ Geometric modeling is a branch of applied mathematics Applied mathematics is the application of mathematical methods by different fields such as physics Physics (from grc, φυσική (ἐπιστήμη), physikḗ (epist ...
s (also called
vector graphics Vector graphics, as a form of computer graphics, is the set of mechanisms for creating visual images directly from Geometric primitive , geometric shapes defined on a Cartesian coordinate system, Cartesian plane, such as Point (geometry), po ...
), digital images (also called
raster graphics upright=1, The Smiley, smiley face in the top left corner is a raster image. When enlarged, individual pixels appear as squares. Enlarging further, each pixel can be analyzed, with their colors constructed through combination of the values for ...
), text to be
typeset on a composing stick A Miller & Richard composing stick, showing the adjustment mechanism (left side) In letterpress printing and typesetting on a composing stick on a type case. , letter founder, from the 1728 edition of '' Cyclopaedia, o ...
(defined by content,
font In metal A metal (from Greek Greek may refer to: Greece Anything of, from, or related to Greece Greece ( el, Ελλάδα, , ), officially the Hellenic Republic, is a country located in Southeast Europe. Its population is approxim ...

font
style and size, color, position, and orientation), mathematical
function Function or functionality may refer to: Computing * Function key A function key is a key on a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...
s and
equation In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no ge ...

equation
s, and more. These components can be modified and manipulated by two-dimensional
geometric transformation In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). I ...
s such as
translation Translation is the communication of the meaning Meaning most commonly refers to: * Meaning (linguistics), meaning which is communicated through the use of language * Meaning (philosophy), definition, elements, and types of meaning discusse ...
,
rotation A rotation is a circular movement of an object around a center (or point) of rotation. The plane (geometry), geometric plane along which the rotation occurs is called the ''rotation plane'', and the imaginary line extending from the center an ...

rotation
,
scaling Scaling may refer to: Science and technology Mathematics and physics * Scaling (geometry), a linear transformation that enlarges or diminishes objects * Scale invariance, a feature of objects or laws that do not change if scales of length, energy ...
. In object-oriented graphics, the image is described indirectly by an
object Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Entity, something that is tangible and within the grasp of the senses ** Object (abstract), an object which does not exist at any particular time or pl ...
endowed with a self- rendering
method Method ( grc, μέθοδος, methodos) literally means a pursuit of knowledge, investigation, mode of prosecuting such inquiry, or system. In recent centuries it more often means a prescribed process for completing a task. It may refer to: *Scien ...
—a procedure which assigns colors to the image
pixel In digital imaging Digital imaging or digital image acquisition is the creation of a representation of the visual characteristics of an object, such as a physical scene or the interior structure of an object. The term is often assumed to imp ...

pixel
s by an arbitrary algorithm. Complex models can be built by combining simpler objects, in the
paradigms In science Science (from the Latin word ''scientia'', meaning "knowledge") is a systematic enterprise that Scientific method, builds and Taxonomy (general), organizes knowledge in the form of Testability, testable explanations and prediction ...
of
object-oriented programming Object-oriented programming (OOP) is a programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Some paradigms are concerned mai ...
. In
Euclidean geometry Euclidean geometry is a mathematical system attributed to Alexandria Alexandria ( or ; ar, الإسكندرية ; arz, اسكندرية ; Coptic Coptic may refer to: Afro-Asia * Copts, an ethnoreligious group mainly in the area of modern ...
, a translation moves every point a constant distance in a specified direction. A translation can be described as a
rigid motion Rigid or rigidity may refer to: Mathematics and physics *Stiffness Stiffness is the extent to which an object resists deformation in response to an applied force In physics Physics (from grc, φυσική (ἐπιστήμη) ...
: other rigid motions include rotations and reflections. A translation can also be interpreted as the addition of a constant
vector Vector may refer to: Biology *Vector (epidemiology) In epidemiology Epidemiology is the study and analysis of the distribution (who, when, and where), patterns and risk factor, determinants of health and disease conditions in defined pop ...
to every point, or as shifting the
origin Origin(s) or The Origin may refer to: Arts, entertainment, and media Comics and manga * Origin (comics), ''Origin'' (comics), a Wolverine comic book mini-series published by Marvel Comics in 2002 * The Origin (Buffy comic), ''The Origin'' (Bu ...
of the
coordinate system In geometry Geometry (from the grc, γεωμετρία; ''wikt:γῆ, geo-'' "earth", ''wikt:μέτρον, -metron'' "measurement") is, with arithmetic, one of the oldest branches of mathematics. It is concerned with properties of space t ...

coordinate system
. A translation operator is an operator T_\mathbf such that T_\mathbf f(\mathbf) = f(\mathbf+\mathbf). If v is a fixed vector, then the translation ''T''v will work as ''T''v(p) = p + v. If ''T'' is a translation, then the
image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (daytime vision), color vision, sco ...
of a subset ''A'' under the
function Function or functionality may refer to: Computing * Function key A function key is a key on a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...
''T'' is the translate of ''A'' by ''T''. The translate of ''A'' by ''T''v is often written ''A'' + v. In a
Euclidean space Euclidean space is the fundamental space of classical geometry. Originally, it was the three-dimensional space of Euclidean geometry, but in modern mathematics there are Euclidean spaces of any nonnegative integer dimension (mathematics), dimens ...
, any translation is an
isometry In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities an ...
. The set of all translations forms the translation group ''T'', which is isomorphic to the space itself, and a
normal subgroup In abstract algebra In algebra, which is a broad division of mathematics, abstract algebra (occasionally called modern algebra) is the study of algebraic structures. Algebraic structures include group (mathematics), groups, ring (mathematics), ...
of
Euclidean group In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It h ...
''E''(''n'' ). The
quotient group A quotient group or factor group is a mathematical group (mathematics), group obtained by aggregating similar elements of a larger group using an equivalence relation that preserves some of the group structure (the rest of the structure is "factore ...
of ''E''(''n'' ) by ''T'' is isomorphic to the
orthogonal group In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...
''O''(''n'' ): :''E''(''n'' ) ''/ T'' ≅ ''O''(''n'' ).


Translation

Since a translation is an
affine transformation In Euclidean geometry Euclidean geometry is a mathematical system attributed to Alexandrian Greek mathematics , Greek mathematician Euclid, which he described in his textbook on geometry: the ''Euclid's Elements, Elements''. Euclid's method c ...
but not a
linear transformation In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
,
homogeneous coordinates In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It h ...
are normally used to represent the translation operator by a
matrix Matrix or MATRIX may refer to: Science and mathematics * Matrix (mathematics), a rectangular array of numbers, symbols, or expressions * Matrix (logic), part of a formula in prenex normal form * Matrix (biology), the material in between a eukaryoti ...
and thus to make it linear. Thus we write the 3-dimensional vector w = (''w''''x'', ''w''''y'', ''w''''z'') using 4 homogeneous coordinates as w = (''w''''x'', ''w''''y'', ''w''''z'', 1). To translate an object by a
vector Vector may refer to: Biology *Vector (epidemiology) In epidemiology Epidemiology is the study and analysis of the distribution (who, when, and where), patterns and risk factor, determinants of health and disease conditions in defined pop ...
v, each homogeneous vector p (written in homogeneous coordinates) would need to be multiplied by this translation matrix: : T_ = \begin 1 & 0 & 0 & v_x \\ 0 & 1 & 0 & v_y \\ 0 & 0 & 1 & v_z \\ 0 & 0 & 0 & 1 \end As shown below, the multiplication will give the expected result: : T_ \mathbf = \begin 1 & 0 & 0 & v_x \\ 0 & 1 & 0 & v_y\\ 0 & 0 & 1 & v_z\\ 0 & 0 & 0 & 1 \end \begin p_x \\ p_y \\ p_z \\ 1 \end = \begin p_x + v_x \\ p_y + v_y \\ p_z + v_z \\ 1 \end = \mathbf + \mathbf The inverse of a translation matrix can be obtained by reversing the direction of the vector: : T^_ = T_ . \! Similarly, the product of translation matrices is given by adding the vectors: : T_T_ = T_ . \! Because addition of vectors is
commutative In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no ge ...
, multiplication of translation matrices is therefore also commutative (unlike multiplication of arbitrary matrices).


Rotation

In
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mat ...
, a rotation matrix is a
matrix Matrix or MATRIX may refer to: Science and mathematics * Matrix (mathematics), a rectangular array of numbers, symbols, or expressions * Matrix (logic), part of a formula in prenex normal form * Matrix (biology), the material in between a eukaryoti ...
that is used to perform a
rotation A rotation is a circular movement of an object around a center (or point) of rotation. The plane (geometry), geometric plane along which the rotation occurs is called the ''rotation plane'', and the imaginary line extending from the center an ...
in
Euclidean space Euclidean space is the fundamental space of classical geometry. Originally, it was the three-dimensional space of Euclidean geometry, but in modern mathematics there are Euclidean spaces of any nonnegative integer dimension (mathematics), dimens ...
. :R = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \\ \end rotates points in the ''xy''-
Cartesian plane A Cartesian coordinate system (, ) in a plane Plane or planes may refer to: * Airplane An airplane or aeroplane (informally plane) is a fixed-wing aircraft A fixed-wing aircraft is a heavier-than-air flying machine Early fly ...
counterclockwise through an angle ''θ'' about the origin of the
Cartesian coordinate system A Cartesian coordinate system (, ) in a plane Plane or planes may refer to: * Airplane An airplane or aeroplane (informally plane) is a fixed-wing aircraft A fixed-wing aircraft is a heavier-than-air flying machine Early fly ...
. To perform the rotation using a rotation matrix ''R'', the position of each point must be represented by a
column vector In linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and ...
v, containing the coordinates of the point. A rotated vector is obtained by using the
matrix multiplication In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and t ...

matrix multiplication
''R''v. Since matrix multiplication has no effect on the zero vector (i.e., on the coordinates of the origin), rotation matrices can only be used to describe rotations about the origin of the coordinate system. Rotation matrices provide a simple algebraic description of such rotations, and are used extensively for computations in
geometry Geometry (from the grc, γεωμετρία; ' "earth", ' "measurement") is, with , one of the oldest branches of . It is concerned with properties of space that are related with distance, shape, size, and relative position of figures. A mat ...

geometry
,
physics Physics is the natural science that studies matter, its Elementary particle, fundamental constituents, its Motion (physics), motion and behavior through Spacetime, space and time, and the related entities of energy and force. "Physical scie ...

physics
, and
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great dea ...

computer graphics
. In 2-dimensional space, a rotation can be simply described by an angle ''θ'' of rotation, but it can be also represented by the 4 entries of a rotation matrix with 2 rows and 2 columns. In 3-dimensional space, every rotation can be interpreted as a rotation by a given angle about a single fixed axis of rotation (see
Euler's rotation theorem In geometry Geometry (from the grc, γεωμετρία; ''wikt:γῆ, geo-'' "earth", ''wikt:μέτρον, -metron'' "measurement") is, with arithmetic, one of the oldest branches of mathematics. It is concerned with properties of space t ...
), and hence it can be simply described by an angle and a vector with 3 entries. However, it can also be represented by the 9 entries of a rotation matrix with 3 rows and 3 columns. The notion of rotation is not commonly used in dimensions higher than 3; there is a notion of a rotational displacement, which can be represented by a matrix, but no associated single axis or angle. Rotation matrices are
square matrices In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...
, with
real Real may refer to: * Reality Reality is the sum or aggregate of all that is real or existent within a system, as opposed to that which is only Object of the mind, imaginary. The term is also used to refer to the ontological status of things, ind ...
entries. More specifically they can be characterized as
orthogonal matrices In linear algebra, an orthogonal matrix, or orthonormal matrix, is a real square matrix whose columns and rows are orthonormal vectors. One way to express this is :Q^\mathrm Q = Q Q^\mathrm = I, where is the transpose In linear algebra, t ...
with
determinant In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and t ...

determinant
 1: :R^ = R^, \det R = 1\,. The set of all such matrices of size ''n'' forms a
group A group is a number A number is a mathematical object used to counting, count, measurement, measure, and nominal number, label. The original examples are the natural numbers 1, 2, 3, 4, and so forth. Numbers can be represented in language with ...
, known as the
special orthogonal group In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...
.


In two dimensions

In two dimensions every rotation matrix has the following form: : R(\theta) = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \\ \end. This rotates
column vector In linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and ...
s by means of the following
matrix multiplication In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and t ...

matrix multiplication
: : \begin x' \\ y' \\ \end = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \\ \end\begin x \\ y \\ \end. So the coordinates (x',y') of the point (x,y) after rotation are: :x' = x \cos \theta - y \sin \theta\,, :y' = x \sin \theta + y \cos \theta\,. The direction of vector rotation is counterclockwise if θ is positive (e.g. 90°), and clockwise if θ is negative (e.g. -90°). : R(-\theta) = \begin \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \\ \end\,.


Non-standard orientation of the coordinate system

If a standard
right-handed In human biology, handedness is the better, faster, or more precise performance or individual preference for use of a hand, known as the dominant hand. The incapable, less capable or less preferred hand is called the non-dominant hand. Right-ha ...
Cartesian coordinate system A Cartesian coordinate system (, ) in a plane Plane or planes may refer to: * Airplane An airplane or aeroplane (informally plane) is a fixed-wing aircraft A fixed-wing aircraft is a heavier-than-air flying machine Early fly ...
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. See
below Below may refer to: *Earth *Ground (disambiguation) *Soil *Floor *Bottom (disambiguation) *Less than *Temperatures below freezing *Hell or underworld People with the surname *Fred Below (1926–1988), American blues drummer *Fritz von Below (1853 ...
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: : R(90^\circ) = \begin 0 & -1 \\
pt
pt
1 & 0 \\ \end (90° counterclockwise rotation) :R(180^\circ) = \begin -1 & 0 \\
pt
pt
0 & -1 \\ \end (180° rotation in either direction – a half-turn) :R(270^\circ) = \begin 0 & 1 \\
pt
pt
-1 & 0 \\ \end (270° counterclockwise rotation, the same as a 90° clockwise rotation) In
Euclidean geometry Euclidean geometry is a mathematical system attributed to Alexandria Alexandria ( or ; ar, الإسكندرية ; arz, اسكندرية ; Coptic Coptic may refer to: Afro-Asia * Copts, an ethnoreligious group mainly in the area of modern ...
, uniform scaling (
isotropic Isotropy is uniformity in all orientations; it is derived from the Greek ''isos'' (ἴσος, "equal") and ''tropos'' (τρόπος, "way"). Precise definitions depend on the subject area. Exceptions, or inequalities, are frequently indicated by ...
scaling, homogeneous dilation,
homothety
homothety
) is a
linear transformation In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
that enlarges (increases) or shrinks (diminishes) objects by a
scale factor A scale factor is usually a decimal which scales Scale or scales may refer to: Mathematics * Scale (descriptive set theory)In the mathematical discipline of descriptive set theory, a scale is a certain kind of object defined on a set (mathemat ...
that is the same in all directions. The result of uniform scaling is 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.) More general is scaling with a separate scale factor for each axis direction. Non-uniform scaling (
anisotropic Anisotropy () is the property of a material which allows it to change or assume different properties in different directions as opposed to isotropy Isotropy is uniformity in all orientations; it is derived from the Greek ''isos'' (ἴσος, ...
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 A shape or figure is the form of an object or its external boundary, outline, or external Surface (mathematics), surface, as opposed to other properties such as color, Surface texture, texture, or material type. A plane shape, two-dimensional s ...

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 Vector may refer to: Biology *Vector (epidemiology) In epidemiology Epidemiology is the study and analysis of the distribution (who, when, and where), patterns and risk factor, determinants of health and disease conditions in defined pop ...
''v'' = (''vx, vy, vz''), each point ''p'' = (''px, py, pz'') would need to be multiplied with this scaling matrix: : S_v = \begin v_x & 0 & 0 \\ 0 & v_y & 0 \\ 0 & 0 & v_z \\ \end. As shown below, the multiplication will give the expected result: : S_vp = \begin v_x & 0 & 0 \\ 0 & v_y & 0 \\ 0 & 0 & v_z \\ \end \begin p_x \\ p_y \\ p_z \end = \begin v_xp_x \\ v_yp_y \\ v_zp_z \end. Such a scaling changes the
diameter In geometry Geometry (from the grc, γεωμετρία; ' "earth", ' "measurement") is, with , one of the oldest branches of . It is concerned with properties of space that are related with distance, shape, size, and relative position ...

diameter
of an object by a factor between the scale factors, the
area Area is the quantity Quantity is a property that can exist as a multitude or magnitude, which illustrate discontinuity and continuity. Quantities can be compared in terms of "more", "less", or "equal", or by assigning a numerical value in ...

area
by a factor between the smallest and the largest product of two scale factors, and the
volume Volume is a scalar quantity expressing the amount Quantity or amount is a property that can exist as a multitude Multitude is a term for a group of people who cannot be classed under any other distinct category, except for their shared fact ...

volume
by the product of all three. The scaling is uniform
if and only if In logic Logic is an interdisciplinary field which studies truth and reasoning. Informal logic seeks to characterize Validity (logic), valid arguments informally, for instance by listing varieties of fallacies. Formal logic represents st ...
the scaling factors are equal (''vx = vy = vz''). If all except one of the scale factors are equal to 1, we have directional scaling. In the case where ''vx = vy = vz = k'', the scaling is also called an enlargement or dilation by a factor k, increasing the area by a factor of k2 and the volume by a factor of k3. A scaling in the most general sense is any
affine transformation In Euclidean geometry Euclidean geometry is a mathematical system attributed to Alexandrian Greek mathematics , Greek mathematician Euclid, which he described in his textbook on geometry: the ''Euclid's Elements, Elements''. Euclid's method c ...
with a
diagonalizable matrix In linear algebra, a square matrix In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change ...
. 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), 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 In mathematics, projective geometry is the study of geometric properties that are invariant with respect to projective transformations. This means that, compared to elementary Euclidean geometry, projective geometry has a different setting, proj ...
, often used in
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great dea ...

computer graphics
, points are represented using
homogeneous coordinates In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It h ...
. To scale an object by a
vector Vector may refer to: Biology *Vector (epidemiology) In epidemiology Epidemiology is the study and analysis of the distribution (who, when, and where), patterns and risk factor, determinants of health and disease conditions in defined pop ...
''v'' = (''vx, vy, vz''), each homogeneous coordinate vector ''p'' = (''px, py, pz'', 1) would need to be multiplied with this
projective transformation In projective geometry, a homography is an isomorphism In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), a ...
matrix: : S_v = \begin v_x & 0 & 0 & 0 \\ 0 & v_y & 0 & 0 \\ 0 & 0 & v_z & 0 \\ 0 & 0 & 0 & 1 \end. As shown below, the multiplication will give the expected result: : S_vp = \begin v_x & 0 & 0 & 0 \\ 0 & v_y & 0 & 0 \\ 0 & 0 & v_z & 0 \\ 0 & 0 & 0 & 1 \end \begin p_x \\ p_y \\ p_z \\ 1 \end = \begin v_xp_x \\ v_yp_y \\ v_zp_z \\ 1 \end. Since the last component of a homogeneous coordinate can be viewed as the denominator of the other three components, a uniform scaling by a common factor ''s'' (uniform scaling) can be accomplished by using this scaling matrix: : S_v = \begin 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & \frac \end. For each vector ''p'' = (''px, py, pz'', 1) we would have : S_vp = \begin 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & \frac \end \begin p_x \\ p_y \\ p_z \\ 1 \end = \begin p_x \\ p_y \\ p_z \\ \frac \end which would be homogenized to : \begin sp_x \\ sp_y \\ sp_z \\ 1 \end.


Direct painting

A convenient way to create a complex image is to start with a blank "canvas" raster map (an array of
pixel In digital imaging Digital imaging or digital image acquisition is the creation of a representation of the visual characteristics of an object, such as a physical scene or the interior structure of an object. The term is often assumed to imp ...

pixel
s, also known as a
bitmap In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and softw ...

bitmap
) filled with some uniform background color and then "draw", "paint" or "paste" simple patches of color onto it, in an appropriate order. In particular the canvas may be the frame buffer for a computer display. Some programs will set the pixel colors directly, but most will rely on some 2D graphics library or the machine's graphics card, which usually implement the following operations: * paste a given digital image, image at a specified offset onto the canvas; * write a string of characters with a specified font, at a given position and angle; * paint a simple geometric shape, such as a triangle defined by three corners, or a circle with given center and radius; * draw a line segment, Arc (geometry), arc, or simple curve with a ''virtual pen'' of given width.


Extended color models

Text, shapes and lines are rendered with a client-specified color. Many libraries and cards provide color gradients, which are handy for the generation of smoothly-varying backgrounds, shadow effects, etc. (See also Gouraud shading). The pixel colors can also be taken from a texture, e.g. a
digital image A digital image is an image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (day ...
(thus emulating rub-on screentones and the fabled ''checker paint'' which used to be available only in cartoons). Painting a
pixel In digital imaging Digital imaging or digital image acquisition is the creation of a representation of the visual characteristics of an object, such as a physical scene or the interior structure of an object. The term is often assumed to imp ...

pixel
with a given color usually replaces its previous color. However, many systems support painting with Transparency (graphic), transparent and translucent colors, which only modify the previous pixel values. The two colors may also be combined in more complex ways, e.g. by computing their bitwise operation, bitwise exclusive or. This technique is known as ''inverting color'' or ''color inversion'', and is often used in graphical user interfaces for highlighting, rubber-band drawing, and other volatile painting—since re-painting the same shapes with the same color will restore the original pixel values.


Layers

The models used in 2D computer graphics usually do not provide for three-dimensional shapes, or three-dimensional optical phenomena such as lighting, shadows, Reflection (physics), reflection, refraction, etc. However, they usually can model multiple ''layers'' (conceptually of ink, paper, or film; opaque, translucent, or Transparency (graphic), transparent—stacked in a specific order. The ordering is usually defined by a single number (the layer's ''depth'', or distance from the viewer). Layered models are sometimes called "2-D computer graphics". They make it possible to mimic traditional drafting and printing techniques based on film and paper, such as cutting and pasting; and allow the user to edit any layer without affecting the others. For these reasons, they are used in most graphics editors. Layered models also allow better spatial anti-aliasing of complex drawings and provide a sound model for certain techniques such as ''mitered joints'' and the even-odd rule. Layered models are also used to allow the user to suppress unwanted information when viewing or printing a document, e.g. roads or railways from a map, certain process layers from an integrated circuit diagram, or hand annotations from a business letter. In a layer-based model, the target image is produced by "painting" or "pasting" each layer, in order of decreasing depth, on the virtual canvas. Conceptually, each layer is first rendered on its own, yielding a
digital image A digital image is an image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (day ...
with the desired
resolution Resolution(s) may refer to: Common meanings * Resolution (debate), the statement which is debated in policy debate * Resolution (law), a written motion adopted by a deliberative body * New Year's resolution, a commitment that an individual make ...
which is then painted over the canvas, pixel by pixel. Fully transparent parts of a layer need not be rendered, of course. The rendering and painting may be done in parallel, i.e., each layer pixel may be painted on the canvas as soon as it is produced by the rendering procedure. Layers that consist of complex geometric objects (such as String (computer science), text or polylines) may be broken down into simpler elements (Character (computing), characters or line segments, respectively), which are then painted as separate layers, in some order. However, this solution may create undesirable aliasing artifacts wherever two elements overlap the same pixel. See also Portable Document Format#Layers.


2D graphics hardware

Modern computer graphics card displays almost overwhelmingly use raster techniques, dividing the screen into a rectangular grid of
pixel In digital imaging Digital imaging or digital image acquisition is the creation of a representation of the visual characteristics of an object, such as a physical scene or the interior structure of an object. The term is often assumed to imp ...

pixel
s, due to the relatively low cost of raster-based video hardware as compared with vector graphic hardware. Most graphic hardware has internal support for BitBLT, blitting operations or Sprite (computer graphics), sprite drawing. A co-processor dedicated to BitBLT, blitting is known as a ''Blitter chip''. Classic 2D graphics chips and graphics processing units of the late 1970s to 1980s, used in 8-bit to early 16-bit, arcade games, video game consoles, and home computers, include: *Atari's Television Interface Adapter, TIA, ANTIC, Color Television Interface Adapter, CTIA and George's Television Interface Adapter, GTIA *Capcom's CP System, CPS-A and CPS-B *Commodore International, Commodore's Original Chip Set, OCS *MOS Technology's MOS Technology VIC, VIC and MOS Technology VIC-II, VIC-II *Hudson Soft's X68000#Technical specifications, Cynthia and Hudson Soft HuC6270, HuC6270 *NEC's NEC μPD7220, μPD7220 and μPD72120 *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' Texas Instruments TMS9918, TMS9918 *Yamaha Corporation, Yamaha's Yamaha V9938, V9938, Yamaha V9958, V9958 and Mega Drive#Technical specifications, YM7101 VDP


2D graphics software

Many graphical user interfaces (GUIs), including macOS, Microsoft Windows, or the
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system An operating system (OS) is system software that manages computer ...
, are primarily based on 2D graphical concepts. Such software provides a visual environment for interacting with the computer, and commonly includes some form of window manager to aid the user in conceptually distinguishing between different applications. The user interface within individual software applications is typically 2D in nature as well, due in part to the fact that most common input devices, 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 games; and are still used for card and board games such as 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 A digital image is an image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (day ...
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. Digital image processing, Image editors are specialized for the manipulation of
digital image A digital image is an image An image (from la, imago) is an artifact that depicts visual perception Visual perception is the ability to interpret the surrounding environment (biophysical), environment through photopic vision (day ...
s, mainly by means of free-hand drawing/painting and signal processing operations. They typically use a direct-painting paradigm, where the user controls virtual pens, brushes, and other free-hand artistic instruments to apply paint to a virtual canvas. Some image editors support a multiple-layer model; however, in order to support signal-processing operations like blurring each layer is normally represented as a digital image. Therefore, any geometric primitives that are provided by the editor are immediately converted to pixels and painted onto the canvas. The name ''raster graphics editor'' is sometimes used to contrast this approach to that of general editors which also handle ''vector graphics''. One of the first popular image editors was Apple Computer, Apple's MacPaint, companion to MacDraw. Modern examples are the free GIMP editor, and the commercial products Photoshop and Paint Shop Pro. This class too includes many specialized editors — for medicine, remote sensing, digital photography, etc.


Developmental animation

With the resurgence 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. With software like RETAS UbiArt Framework and Adobe After Effects, coloring and compositing can be done in less time. Various approaches have been developed 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 allow the user to do either 3D animation, 2D animation or combine both in its software allowing experimentation with multiple forms of animation.


See also

* 2.5D *
3D computer graphics 3D computer graphics, sometimes called CGI, 3DCG or three-dimensional computer graphics (in contrast to 2D computer graphics 2D computer graphics is the Computer-generated imagery, computer-based generation of digital images—mostly from t ...
*Computer animation *CGI animation, CGI * Bit blit * Computer graphics * Graphic art software * Graphics * Image scaling * List of home computers by video hardware * Turtle graphics * Transparency (graphic), Transparency in graphics * Palette (computing) * Pixel art


References

{{DEFAULTSORT:2d Computer Graphics Computer graphics