SlideShare a Scribd company logo
1 of 80
Computer Graphics
Output Primitives

                      Marwa K. U. Al-Rikaby
                       Babylon University
                           IT College
This Presentation has no copyrights.

Contents are taken from:
Outlines:
  Introduction.
  Point Drawing.
  Line Drawing Algorithms.
  Circle Generation Algorithms.
  Ellipse Generation Algorithms.
  Other Curves.
  Filled Area Primitives.
  Character Generation.
Introduction:

    Picture descriptions:
      Raster:
         Completely specified by the set of intensities for the pixels positions in the
          display.
         Shapes and colors are described with pixel arrays.
         Scene displayed by loading pixels array into the frame buffer.
      Vector:
         Set of complex objects positioned at specified coordinates locations within
          the scene.
         Shapes and colors are described with sets of basic geometric structures.
         Scene is displayed by scan converting the geometric-structure specifications
          into pixel patterns.
Introduction:

    Output Primitives:
      Basic geometric structures used to describe scenes.
      Can be grouped into more complex structures.
      Each one is specified with input coordinate data and
      other information about the way that object is to be
      displayed.
      Examples: point, line and circle each one with
      specified coordinates.
      Construct the vector picture.
Introduction:
 In digital representation:
    Display screen is divided into scan lines and columns.
    Pixels positions are referenced according to scan line number
     and column number (columns across scan lines).
    Scan lines start from 0 at screen bottom, and columns start
     from 0 at the screen left side.
    Screen locations (or pixels) are referenced with integer values.
    The frame buffer stores the intensities temporarily.
    Video controller reads from the frame buffer and plots the
     screen pixels.
Point Drawing




y




      x
Point Drawing:
    Converting a single coordinate position furnished by
     an application program into appropriate operation for
     the output device in use.
    In raster system:
      Black-white: setting the bit value corresponding to a
       specified screen position within the frame buffer to 1.
      RGB: loading the frame buffer with the color codes for the
       intensities that are to be displayed at the screen pixel
       positions.
Line Drawing Algorithms

y2




y1
       x1         x2
Line Drawing:

  A straight line is specified by two endpoint
   positions.
  Line drawing is done by:
      Calculating intermediate positions between the
      endpoints.
      Directing the output device to fill in the calculated
      positions as in the case of plotting single points.
Line Drawing:
    Plotted positions may be only approximations to the
     actual line positions between endpoints.
      A computed position (10.48, 20.51) is converted to pixel
      (10,21).
      This rounding causes the lines to be displayed with a stairstep
      appearance.
      Stairsteps are noticeable in low resolution systems, it can be
      improved by:
          Displaying lines on high resolution systems.
          Adjusting intensities along line path.
Line Drawing:
    The Cartesian intercept equation for a straight line:
     y= m. x +b
     Where m is the line slop and b is y intercept.
    For line segment starting in (x1,y1) and ending in (x2,y2), the
     slop is:
     m= (y1-y2)/(x1-x2)
     b= y1- m.x1
    For any given x interval x, we can compute the corresponding y
     interval y:
      y= m .x
    Or x interval x from a given y:
      x= y/m
Line Drawing:
                                                     Sampling along x axis
     On raster systems, lines are plotted
                                                Y2
     with pixels, and step sizes in the
     horizontal and vertical directions are
     constrained by pixel separations.          y1


                                                       X1         x2
     Scan conversion process samples a
     line at discrete positions and determine        Sampling along y axis
     the nearest pixel to the line at each      Y2
     sampled position.

                                                y1



                                                       X1   x2
Line Drawing Algorithms:

    Digital Differential Analyzer (DDA):
     Samples the line at unit intervals in one coordinate
     and determine corresponding integer values nearest
     the line path for the other coordinate.
    Bresenham’s Line Algorithm:
     Scan converts lines using only incremental integer
     calculations.
Line Drawing Algorithms:

    DDA
      A scan-conversion line algorithm based on calculating either
       y or x using line points calculating equations.
      In each case, choosing the sample axis depends on the slop
       value.
      The unit step for the selected axis is 1.
      The other axis is calculated depending on the first axis and
       the slop m.
      The next slides will show the different cases of the slop:
Line Drawing Algorithms:

    DDA
      Case 1:the slop is Positive and less than 1
          Sample at unit x interval (x=1) and compute each successive
           y value as :
             y k+1= yk+ m
          K takes integer values starting from 1,at the first point, and
           increasing by 1 on each step until reaching the final endpoint.
          The calculated y must be rounded to the nearest integer.
          Example:
             Describe the line segment which starts at (3,3) and ends at
                (23,7).
Lines Drawing Algorithms: DDA
                   24
                   23
                   22
                   21
 m= (7-3)/(23-3)   20
  =4/20            19
                   18
  =0.2             17
                   16
                   15
 x=1              14
                   13
 y=0.2            12
                   11
                   10
                   9
                   8
                   7
                   6
                   5
                   4
                   3
                   2
                   1
                   0
                        0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Lines Drawing Algorithms: DDA
x    y actual point pixel position   24
                                     23
3    3   (3,3)         (3,3)         22
4    3.2 (4,3.2)       (4,3)         21
5    3.4 (5,3.4)       (5,3)         20
6    3.6 (6,3.6)       (6,4)         19
                                     18
7    3.8 (7,3.8)       (7,4)         17
8    4   (8,4)         (8,4)         16
9    4.2 (9,4.2)       (9,4)         15
10   4.4 (10,4.4)      (10,4)        14
                                     13
11   4.6 (11,4.6)      (11,5)        12
12   4.8 (12,4.8)      (12,5)        11
13   5   (13,5)        (13,5)        10
                                     9
14   5.2 (14,5.2)      (14,5)        8
15   5.4 (15,5.4)      (15,5)        7
16   5.6 (16,5.6)      (16,6)        6
17   5.8 (17,5.8)      (17,6)        5
                                     4
..    ..    ..            ..         3
..    ..    ..            ..         2
22   6.8 (22,6.8)      (22,7)        1
23   7    (23,7)       (23,7)        0
                                          0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms:

    DDA
      Case 2:the slop is Positive and greater than 1
          Sample at unit y interval (y=1) and compute each successive
           y value as :
             x k+1= xk+ (1/m)
          K takes integer values starting from 1,at the first point, and
           increasing by 1 on each step until reaching the final endpoint.
          The calculated x must be rounded to the nearest integer.
          Example:
             Describe the line segment which starts at (3,3) and ends at
                (7,23).
Line Drawing Algorithms: DDA
                  24
                  23
                  22
m= (23-3)/(7-3)   21
                  20
 = 20/4           19
 =5               18
                  17
                  16
                  15
x =1/m           14
   =1/5           13
                  12
   =0.2           11
                  10
                  9
y =1             8
                  7
                  6
                  5
                  4
                  3
                  2
                  1
                  0
                       0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms: DDA
y    x actual point pixel position   24
                                     23
3    3   (3,3)         (3,3)         22
4    3.2 (3.2,4)       (3,4)         21
5    3.4 (3.4,5)       (3,5)         20
6    3.6 (3.6,6)       (4,6)         19
                                     18
7    3.8 (3.8,7)       (4,7)         17
8    4   (4,8)         (4,8)         16
9    4.2 (4.2,9)       (4,9)         15
10   4.4 (4.4,10)      (4,10)        14
                                     13
11   4.6 (4.6,11)      (5,11)        12
12   4.8 (4.8,12)      (5,12)        11
13   5   (5,13)        (5,13)        10
                                     9
14   5.2 (5.2,14)      (5,14)        8
15   5.4 (5.4,15)      (5,15)        7
16   5.6 (5.6,16)      (6,16)        6
17   5.8 (5.8,17)      (6,17)        5
                                     4
..    ..    ..            ..         3
..    ..    ..            ..         2
22   6.8 (6.8,22)      (7,22)        1
23   7    (7,23)       (7,23)        0
                                          0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms:

    DDA
      Case 3:the slop is negative and its absolute value is less than 1
         Follow the same way in case 1.
      Case 4:the slop is negative and its absolute value is greater than 1
         Follow the same way in case 2.
      In the previous 4 cases, we start from the left to the right. If
       the state is reversed then:
         If the absolute slop is less than 1, set x=-1 and
              y k+1= yk - m
         If the absolute slop is greater than 1, set y=-1 and
              x k+1= xk - (1/m)
Line Drawing Algorithms:

    DDA properties
      A faster method for calculating pixel positions than the direct
       use: y= m . x +b.
      Uses x or y to eliminate the multiplication in the above
       equation.
      Rounding successive additions of the floating-point
       increment can cause the calculated pixel positions to drift
       away from the true line path for long line segment.
      Rounding and floating-point arithmetic are time-consuming
       operations.
Line Drawing Algorithms:

    Bresenham’s Line Algorithm:
      Scan converts lines using only incremental integer
      calculations.
      Can be adapted to display circles and other
      curves.
      When sampling at unit x intervals, we need to
      decide which of two possible pixel positions is
      closer to the line path at each sample step by using
      a decision parameter.
Line Drawing Algorithms:

    Bresenham’s Line Algorithm:
     The decision parameter (pk) is an integer number
      that is proportional to the difference between the
      separations of the two pixel positions from the
      actual line path.
     Depending on the slop sign and value the decision
      parameter determine which pixel coordinates would
      be taken in the next step.
Line Drawing Algorithms:

    Bresenham’s Line Algorithm:
      Pk for line with positive slop less than 1:
         Sampling at unit x intervals.
         At pixel (xk,yk) we need to decide whether (xk+1,yk) or
         (xk+1,yk+1) would be plotted in column xk+1.
         d1 and d2 are the vertical pixel separations from the
         mathematical line path.
         y coordinate on the mathematical line at pixel xk+1 is
         calculated as:
            y= (x+1.m)+b
            d1= y-yk
            d2= yk+1-y
        Pk =x(d1-d2)
Line Drawing Algorithms:

    Bresenham’s Line Algorithm:
     Properties of Pk for line with positive slop less than 1:
        If the pixel at yk is closer to the line path than the
         pixel at yk+l (that is, d1 < d2), then decision
         parameter pk is negative and we plot the lower
         pixel.
        On reverse, pk is positive and we plot the upper
         pixel.
       If pk is zero ,then choose either yk+l for all such
         cases, or yk.
Line Drawing Algorithms:

    Bresenham’s Line Algorithm:
     Properties of Pk for line with positive slop less than 1:
        Incremental integer calculations can be used to
         obtain     values      of    successive      decision
         parameters, because change occur on either x
         or y coordinates:
              pk+1=pk+2y-2x(yk+1-yk)
              and p0=2y-x
Line Drawing Algorithms: Bresenham’s
                           24
                           23
Drawing the line between   22
                           21
the endpoints (3,3) and    20
(23,13)                    19
                           18
                           17
m= (13-3)/(23-3)= 0.5      16
                           15
                           14
                           13
x= 20                     12
y=10                      11
                           10
                           9
                           8
P0= 2(10)-20=0             7
                           6
                           5
                           4
                           3
                           2
                           1
                           0
                                0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms: Bresenham’s
                       24
K     P    x+1   y+1   23
                       22
0    0      4      4   21
1    -20    5     4    20
                       19
2    0      6     5    18
                       17
3    -20    7     5    16
4    0      8     6    15
                       14
5    -20    9     6    13
6    0      10    7    12
                       11
7    -20    11   7     10
                       9
8    0      12    8    8
9    -20    13    8    7
                       6
10   0      14    9    5
                       4
..   ..     ..    ..   3
..   ..     ..    ..   2
                       1
19   -20    23   13    0
                            0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Line Drawing Algorithms:

    Bresenham’s line algorithm properties

      It is generalized to lines with arbitrary slope by considering
       the symmetry between the various octants and quadrants of
       the xy plane.
      The constants 2y and 2y - 2x are calculated once for
       each line to be scan converted, so the arithmetic involves
       only integer addition and subtraction of these two constants.
… Finally
                            24
                            23
Special cases can be        22
                            21
handled separately:         20
                            19
                            18
Horizontal y=0             17
Vertical   x=0             16
                            15
Diagonal |x|=|y|          14
                            13
                            12
each can be loaded          11
                            10
directly into the frame     9
                            8
buffer without processing   7
them through the line-      6
                            5
plotting algorithms.        4
                            3
                            2
                            1
                            0
                                 0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Circle Generating Algorithms
Circle Properties:
     A set of points that are all at the same distance (r)
      from a center point (xc,yc).
     Expressed by Pythagorean equation in Cartesian
      coordinates as:
      (x – xc )2 + (y - yc )2 = r2

     Any given circle can be drawn on the origin(0,0)
      and then moved to its actual position by:
       Each calculated x on the circumference moved to x+xc.
       Each calculated y on the circumference is moved to y+yc.
Circle Generating Algorithms:

  Standard  Algorithm
  Polar Algorithm
  Symmetry Algorithm
  Mid-point Algorithm     (xc, yc )
                                       r   (x, y)
Standard Algorithm:

  Uses   the Pythagorean equation to find
   the points along the circumference.
  Steps along x axis by unit steps from xc-r
   to xc+r and calculate y for each step as:
    y= yc± √r2-(xc-yc)2
  Itinvolves considerable computations at
   each step.
Standard Algorithm:
    Spacing between plotted pixels is not uniform.




    Spacing can be adjusted by stepping on y instead of x
     when the slop is greater than 1, but such approach
     increasing computations.
Polar Algorithm:
    Uses polar coordinates r and Ө.
    Calculate points by fixed regular step size equations
     as:
      x= xc + r * cosӨ
      y= yc + r * sinӨ
    Step size that is chosen for Ө depends on the
     application.
    Larger separations can be connected by line segments
     to approximate the circle path.
Polar Algorithm:
    In raster displays, step size is 1/r which plots pixel
     positions that are approximately one unit apart.


                                     x,y
                             r
                                 Ө
Symmetry Algorithm:

  Reduces computations by considering the
   symmetry of circles in the eight octants in the xy
   plane.
  Generates all pixel positions
 around a circle by calculating
 only the points within the
 sector from x = 0 to x = y.
Mid-point Algorithm:
    Samples at unit intervals and uses decision parameter to
     determine the closest pixel position to the specified circle path at
     each step.
    Along the circle section from x = 0 to x = y in the first quadrant, the
     slope of the curve varies from 0 to -1. Therefore, we can take unit
     steps in the positive x direction over this octant and use a decision
     parameter to determine which of the two possible y positions is
     closer to the circle path at each step. Positions in the other seven
     octants are then obtained by symmetry.
Mid-point Algorithm:
 To apply mid-point method, we define a circle function:




and determine the nearest y position from pk:
Mid-point Algorithm:
  If pk < 0, this midpoint is inside the circle and the pixel
 on scan line yk is closer to the circle boundary.

 Otherwise, the midposition is outside or on the circle
 boundary, and we select the pixel on scan line yk – 1 .

  Successive parameters          are    calculated     using
 incremental calculations:
Mid-point Algorithm:
  Example:
 For a circle radius=10 and center (12,12)

 we calculate positions in the first octant only , beginning with x=0
 and ending when x=y

 The initial decision parameter value:
          P0=1 - r = -9

 Drawing on the origin (0,0) and the initial point (0,10)
 2x0=0 2y0=20
Mid-point Algorithm:
                                    24
                                    23
K   P (xk+1,yk+1)   2xk+1   2yk+1   22
                                    21
0   -9  (1,10)      2        20     20
1   -6  (2,10)      4        20     19
                                    18
2   -1  (3,10)      6        20     17
3   6   (4,9)       8        18     16
                                    15
4   -3  (5,9)       10       18     14
                                    13
5   8   (6,8)       12       16     12
6   5   (7,7)       14       14     11
                                    10
                                    9
                                    8
The first octant is completed       7
and the remained seven              6
                                    5
octants can be plotted              4
                                    3
according to symmetry.              2
                                    1
                                    0
                                         0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Mid-point Algorithm:
                                24
                                23
The circle after plotting all   22
                                21
octants and moving it to its    20
original center (12,12)         19
                                18
                                17
                                16
                                15
                                14
                                13
                                12
                                11
                                10
                                9
                                8
                                7
                                6
                                5
                                4
                                3
                                2
                                1
                                0
                                     0   1   2 3   4 5 6   7 8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Ellipse Generating Algorithms
Ellipse Properties:


                          ry
           F2                  rx   F1


                d2   d1


          P=(x,y)
Ellipse Properties:
   An elongated circle.
   A set of points having an equal sum distances from two
    fixed positions (foci F1,F2).
          d1+d2=constant
   The major axis is the straight line segment extending from
    one side of the ellipse to the other through the foci.
   The minor axis spans the shorter dimension of the
    ellipse, bisecting the major axis at the halfway position
    (ellipse center) between the two foci.
   The two foci and point coordinates on the circumference
    are enough information to plot an ellipse with arbitrary
    orientation.
Ellipse Properties:
    The equation of the ellipse can be written in terms of the
     ellipse center coordinates and parameters rx, and ry, as:


    Using polar coordinates r and Ө. we can also describe the
     ellipse in standard position with the parametric equations:
        x= xc + rx * cosӨ
        y= yc + ry * sinӨ
    Symmetry considerations can be used to reduce
     computations, the four quadrants are similar ( not the eight
     octants).
Midpoint Ellipse Algorithm:
  Similar to displaying a raster circle.
  Given parameters rx, ry, and (xc,yc), we determine points ( x
   , y) for an ellipse in standard position centered on the
   origin, and then we shift the points so the ellipse is centered
   at ( xc,yc).
  To display the ellipse in nonstandard position, we could then
   rotate the ellipse about its center coordinates to reorient the
   major and minor axes.
  This method is applied throughout the first quadrant in two
   parts:
      Stepping on x when the slop is less than 1.
      Stepping on y when the slop is greater than 1.
Midpoint Ellipse Algorithm:
    The decision parameter considered by:


 It has the following properties:




 The next position to be selected depends on the sign of this
 parameter.
  The same way followed in circle we can use to choose the start
     point and depending on the slop and Pk calculate the next nearest
     pixel on the ellipse path.
Other Curves
Overview:
   Include: conics, trigonometric and exponential functions, probability
    distributions, general polynomials, and spline functions.
   Positions along paths can be generated from curves explicit
    equations y= f(x) .
   Incremental midpoints can be calculated from implicit function
    f(x,y)=0.
   The same idea in the previous primitives, choosing the stepping
    axis, can be used to obtain uniform spacing between points.
   Symmetries are also available in some curves, such as
      The normal probability distribution function is symmetric about at center position
       (the mean).
      All points along one cycle of a sine curve can be generated from the points in a
       90" interval.
Conic Sections:
    Described by:



    The parameters A,B,C,D,E,F values determine the
     section type:
Conic Sections:
   Parabolic path   Hyperbola Path
Polynomial and Splines Curves:
    Polynomial is defined as:



 where n is a nonnegative integer and the ak are
 constants, with a≠0.
  We get:
        A straight line when n=1.
        A quadratic when n=2.
        A cubic polynomial when n=3.
        A quartic when n=4…
Polynomial and Splines Curves:
    Designing object shapes or motion paths is typically done by
     specifying a few points to define the general curve contour, then
     fitting the selected points with a polynomial.
    One way to accomplish the curve fitting is to construct a cubic
     polynomial curve section between each pair of specified points.
    Each curve section is then described in parametric form as:




 where parameter u varies over the interval 0 to 1.
Polynomial and Splines Curves:
    Values for the coefficients of u in the parametric
     equations are determined from boundary conditions on
     the curve sections:
      Two adjacent curve sections have the same coordinate position at the
       boundary.
      Match the two curve slopes at the boundary so that we obtain one
       continuous, smooth individual cubic curve.


    Splines are continuous curves formed with polynomial
     pieces.
Filled Area Primitives
Overview:

  Two   basic ideas:
    Determine the overlap intervals for scan lines that
    cross      the     area.      Used       to       fill
    polygons, circles, ellipses, and other simple
    curves.
    Start from a given interior position and paint
    outward from this point until we encounter the
    specified boundary conditions. Used with more
    complex boundaries and in interactive painting
    systems.
Filled Area Primitives:
   Scan-Line Polygon Fill Algorithm:
     Locates the intersection points along the scan line with the
      polygon edges.
     Sorts the intersections from left to right.
     Set the corresponding frame buffer positions between each
      intersection with a specified fill color.
     Special handling:
         Scan line passing through a vertex intersects two edges at that
          position: add two points to the list of intersections for the scan line.
         Care should be taken to determine which side of intersection is
          belonging to the polygon.
Filled Area Primitives:
Such situations need
more      processing      to
determine:
1. Whether there is a
need to duplicate some
intersections.
2. If the points are inside
or outside the shape.

We should trace around
the shape boundaries to
make a decision.
Filled Area Primitives:
Filled Area Primitives:




   Scan line
Filled Area Primitives:




   Scan line
Filled Area Primitives:




   Scan line
Inside-Outside Tests:
     Odd-even (odd parity or even odd) rule:
       Drawing a line from any position P to a distant
       point outside the coordinate extents of the object.
       Counting the number of edge crossings along the
       line.
      If the number of polygon edges crossed by this
       line is odd, then P is an interior point, otherwise it
       is an exterior point.
      The line chosen must not intersect the polygon
       vertices.
Inside-Outside Tests:
     Non-zero winding number rule:
       Counts the number of times the polygon edges wind around
        a particular point in the counterclockwise direction, which is
        called “winding number”.
       Interior points of a two-dimensional object are defined to be
        those that have a nonzero value for the winding number.
       Counting method:
           Start winding number with 0.
           Imagine a line passing across the object and not intersect vertices.
           Add 1 to winding number when the line is crossed by an edge
           from right to left.
           Subtract 1 from winding number when the line is crossed by an
           edge from left to right.
           To determine the direction use either cross product or dot product.
Inside-Outside Tests:
Scan-Line Fill of Curved Boundary Areas :

  In circles and ellipses, only find the two
   scan-line Intersections on opposite sides
   of the curve.
  In other curves, such as ellipse arc, the
   interior region is bounded by the ellipse
   section and a straight-line segment that
   closes the curve by joining the beginning
   and ending positions of the arc.
  Symmetry can be exploited to reduce
   calculations.
Boundary-Fill Algorithm:
  Accepts as input the coordinates of an interior point
   (x, y), a fill color, and a boundary color.
  Starting from (x,y), the procedure tests neighboring
   positions to determine whether they are of the
   boundary color.
  If not, they are painted with the fill color, and their
   neighbors are tested.
  This process continues until all pixels up to the
   boundary color for the area have been tested.
Boundary-Fill Algorithm:
Boundary-Fill Algorithm:
Flood-Fill Algorithm:
  Replacing a specified interior color instead of searching
   for a boundary color value.
  Start from a specified interior point (x, y) and reassign all
   pixel values that are currently set to a given interior color
   with the desired fill color.
  If the area we want to paint has more than one interior
   color, we can first reassign pixel values so that all interior
   points have the same color.
  Using either a 4-connected or 8-connected approach, we
   then step through pixel positions until all interior points
   have been repainted.
Character Generation
Typefaces (Fonts):

  Serif   group:
     Has small lines or accents at the ends of the main
     character strokes.
     More readable.
  Sans    serif group:
     Does not have accents.
     The individual characters easier to recognize.
     More legible, and hence, good for labeling and
     short headings.
Character Generation Methods:
  Bitmapped     Font:
    Uses rectangular grid patterns.
    The simplest to define and display, the character grid
     only needs to be mapped to a frame-buffer position.
    Need more space, each variation (size and format)
     must be stored in a font cache.
  Outline   Font:
    Uses straight-line and curve sections.
    Require less storage since each variation does not
     require a distinct font cache.
    Need more time since to the scan conversion process.
Character Generation Methods:




   Bitmapped Font       Outline Font
Output primitives   computer graphics c version

More Related Content

What's hot

Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphicsSafayet Hossain
 
3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics FundamentalsMuhammed Afsal Villan
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clippingMdAlAmin187
 
Overview of Graphics System
Overview of Graphics SystemOverview of Graphics System
Overview of Graphics SystemPrathimaBaliga
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displaysSomya Bagai
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmArvind Kumar
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.Mohd Arif
 
Scan line method
Scan line methodScan line method
Scan line methodPooja Dixit
 
Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)shalinikarunakaran1
 
Raster Scan And Random Scan
Raster Scan And Random ScanRaster Scan And Random Scan
Raster Scan And Random ScanDevika Rangnekar
 
raster and random scan
raster and random scanraster and random scan
raster and random scanSonia Pahuja
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithmnehrurevathy
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 

What's hot (20)

Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphics
 
Computer graphics realism
Computer graphics realismComputer graphics realism
Computer graphics realism
 
3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Overview of Graphics System
Overview of Graphics SystemOverview of Graphics System
Overview of Graphics System
 
BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displays
 
3 d viewing
3 d viewing3 d viewing
3 d viewing
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
 
Scan line method
Scan line methodScan line method
Scan line method
 
Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)
 
Raster Scan And Random Scan
Raster Scan And Random ScanRaster Scan And Random Scan
Raster Scan And Random Scan
 
raster and random scan
raster and random scanraster and random scan
raster and random scan
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 

Similar to Output primitives computer graphics c version

Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2SanthiNivas
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptxAhmadAbba6
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1aravindangc
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptxssuser255bf1
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniyaTutorialsDuniya.com
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
 
Edge linking hough transform
Edge linking hough transformEdge linking hough transform
Edge linking hough transformaruna811496
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfmeenasp
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
elementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for examelementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for examtigag49721
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit Garg
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxIndhuMcamphil
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxAlamelu
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 

Similar to Output primitives computer graphics c version (20)

raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
Edge linking hough transform
Edge linking hough transformEdge linking hough transform
Edge linking hough transform
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
elementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for examelementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for exam
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
paper
paperpaper
paper
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
03raster 1
03raster 103raster 1
03raster 1
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 

Recently uploaded

MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Recently uploaded (20)

MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Output primitives computer graphics c version

  • 1. Computer Graphics Output Primitives Marwa K. U. Al-Rikaby Babylon University IT College
  • 2. This Presentation has no copyrights. Contents are taken from:
  • 3. Outlines:  Introduction.  Point Drawing.  Line Drawing Algorithms.  Circle Generation Algorithms.  Ellipse Generation Algorithms.  Other Curves.  Filled Area Primitives.  Character Generation.
  • 4. Introduction:  Picture descriptions:  Raster:  Completely specified by the set of intensities for the pixels positions in the display.  Shapes and colors are described with pixel arrays.  Scene displayed by loading pixels array into the frame buffer.  Vector:  Set of complex objects positioned at specified coordinates locations within the scene.  Shapes and colors are described with sets of basic geometric structures.  Scene is displayed by scan converting the geometric-structure specifications into pixel patterns.
  • 5. Introduction:  Output Primitives:  Basic geometric structures used to describe scenes.  Can be grouped into more complex structures.  Each one is specified with input coordinate data and other information about the way that object is to be displayed.  Examples: point, line and circle each one with specified coordinates.  Construct the vector picture.
  • 6. Introduction: In digital representation:  Display screen is divided into scan lines and columns.  Pixels positions are referenced according to scan line number and column number (columns across scan lines).  Scan lines start from 0 at screen bottom, and columns start from 0 at the screen left side.  Screen locations (or pixels) are referenced with integer values.  The frame buffer stores the intensities temporarily.  Video controller reads from the frame buffer and plots the screen pixels.
  • 8. Point Drawing:  Converting a single coordinate position furnished by an application program into appropriate operation for the output device in use.  In raster system:  Black-white: setting the bit value corresponding to a specified screen position within the frame buffer to 1.  RGB: loading the frame buffer with the color codes for the intensities that are to be displayed at the screen pixel positions.
  • 10. Line Drawing:  A straight line is specified by two endpoint positions.  Line drawing is done by:  Calculating intermediate positions between the endpoints.  Directing the output device to fill in the calculated positions as in the case of plotting single points.
  • 11. Line Drawing:  Plotted positions may be only approximations to the actual line positions between endpoints.  A computed position (10.48, 20.51) is converted to pixel (10,21).  This rounding causes the lines to be displayed with a stairstep appearance.  Stairsteps are noticeable in low resolution systems, it can be improved by:  Displaying lines on high resolution systems.  Adjusting intensities along line path.
  • 12. Line Drawing:  The Cartesian intercept equation for a straight line: y= m. x +b Where m is the line slop and b is y intercept.  For line segment starting in (x1,y1) and ending in (x2,y2), the slop is: m= (y1-y2)/(x1-x2) b= y1- m.x1  For any given x interval x, we can compute the corresponding y interval y: y= m .x  Or x interval x from a given y: x= y/m
  • 13. Line Drawing: Sampling along x axis  On raster systems, lines are plotted Y2 with pixels, and step sizes in the horizontal and vertical directions are constrained by pixel separations. y1 X1 x2  Scan conversion process samples a line at discrete positions and determine Sampling along y axis the nearest pixel to the line at each Y2 sampled position. y1 X1 x2
  • 14. Line Drawing Algorithms:  Digital Differential Analyzer (DDA): Samples the line at unit intervals in one coordinate and determine corresponding integer values nearest the line path for the other coordinate.  Bresenham’s Line Algorithm: Scan converts lines using only incremental integer calculations.
  • 15. Line Drawing Algorithms:  DDA  A scan-conversion line algorithm based on calculating either y or x using line points calculating equations.  In each case, choosing the sample axis depends on the slop value.  The unit step for the selected axis is 1.  The other axis is calculated depending on the first axis and the slop m.  The next slides will show the different cases of the slop:
  • 16. Line Drawing Algorithms:  DDA  Case 1:the slop is Positive and less than 1  Sample at unit x interval (x=1) and compute each successive y value as : y k+1= yk+ m  K takes integer values starting from 1,at the first point, and increasing by 1 on each step until reaching the final endpoint.  The calculated y must be rounded to the nearest integer.  Example: Describe the line segment which starts at (3,3) and ends at (23,7).
  • 17. Lines Drawing Algorithms: DDA 24 23 22 21 m= (7-3)/(23-3) 20 =4/20 19 18 =0.2 17 16 15 x=1 14 13 y=0.2 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 18. Lines Drawing Algorithms: DDA x y actual point pixel position 24 23 3 3 (3,3) (3,3) 22 4 3.2 (4,3.2) (4,3) 21 5 3.4 (5,3.4) (5,3) 20 6 3.6 (6,3.6) (6,4) 19 18 7 3.8 (7,3.8) (7,4) 17 8 4 (8,4) (8,4) 16 9 4.2 (9,4.2) (9,4) 15 10 4.4 (10,4.4) (10,4) 14 13 11 4.6 (11,4.6) (11,5) 12 12 4.8 (12,4.8) (12,5) 11 13 5 (13,5) (13,5) 10 9 14 5.2 (14,5.2) (14,5) 8 15 5.4 (15,5.4) (15,5) 7 16 5.6 (16,5.6) (16,6) 6 17 5.8 (17,5.8) (17,6) 5 4 .. .. .. .. 3 .. .. .. .. 2 22 6.8 (22,6.8) (22,7) 1 23 7 (23,7) (23,7) 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 19. Line Drawing Algorithms:  DDA  Case 2:the slop is Positive and greater than 1  Sample at unit y interval (y=1) and compute each successive y value as : x k+1= xk+ (1/m)  K takes integer values starting from 1,at the first point, and increasing by 1 on each step until reaching the final endpoint.  The calculated x must be rounded to the nearest integer.  Example: Describe the line segment which starts at (3,3) and ends at (7,23).
  • 20. Line Drawing Algorithms: DDA 24 23 22 m= (23-3)/(7-3) 21 20 = 20/4 19 =5 18 17 16 15 x =1/m 14 =1/5 13 12 =0.2 11 10 9 y =1 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 21. Line Drawing Algorithms: DDA y x actual point pixel position 24 23 3 3 (3,3) (3,3) 22 4 3.2 (3.2,4) (3,4) 21 5 3.4 (3.4,5) (3,5) 20 6 3.6 (3.6,6) (4,6) 19 18 7 3.8 (3.8,7) (4,7) 17 8 4 (4,8) (4,8) 16 9 4.2 (4.2,9) (4,9) 15 10 4.4 (4.4,10) (4,10) 14 13 11 4.6 (4.6,11) (5,11) 12 12 4.8 (4.8,12) (5,12) 11 13 5 (5,13) (5,13) 10 9 14 5.2 (5.2,14) (5,14) 8 15 5.4 (5.4,15) (5,15) 7 16 5.6 (5.6,16) (6,16) 6 17 5.8 (5.8,17) (6,17) 5 4 .. .. .. .. 3 .. .. .. .. 2 22 6.8 (6.8,22) (7,22) 1 23 7 (7,23) (7,23) 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 22. Line Drawing Algorithms:  DDA  Case 3:the slop is negative and its absolute value is less than 1  Follow the same way in case 1.  Case 4:the slop is negative and its absolute value is greater than 1  Follow the same way in case 2.  In the previous 4 cases, we start from the left to the right. If the state is reversed then: If the absolute slop is less than 1, set x=-1 and y k+1= yk - m If the absolute slop is greater than 1, set y=-1 and x k+1= xk - (1/m)
  • 23. Line Drawing Algorithms:  DDA properties  A faster method for calculating pixel positions than the direct use: y= m . x +b.  Uses x or y to eliminate the multiplication in the above equation.  Rounding successive additions of the floating-point increment can cause the calculated pixel positions to drift away from the true line path for long line segment.  Rounding and floating-point arithmetic are time-consuming operations.
  • 24. Line Drawing Algorithms:  Bresenham’s Line Algorithm:  Scan converts lines using only incremental integer calculations.  Can be adapted to display circles and other curves.  When sampling at unit x intervals, we need to decide which of two possible pixel positions is closer to the line path at each sample step by using a decision parameter.
  • 25. Line Drawing Algorithms:  Bresenham’s Line Algorithm: The decision parameter (pk) is an integer number that is proportional to the difference between the separations of the two pixel positions from the actual line path. Depending on the slop sign and value the decision parameter determine which pixel coordinates would be taken in the next step.
  • 26. Line Drawing Algorithms:  Bresenham’s Line Algorithm:  Pk for line with positive slop less than 1:  Sampling at unit x intervals.  At pixel (xk,yk) we need to decide whether (xk+1,yk) or (xk+1,yk+1) would be plotted in column xk+1.  d1 and d2 are the vertical pixel separations from the mathematical line path.  y coordinate on the mathematical line at pixel xk+1 is calculated as: y= (x+1.m)+b d1= y-yk d2= yk+1-y Pk =x(d1-d2)
  • 27. Line Drawing Algorithms:  Bresenham’s Line Algorithm: Properties of Pk for line with positive slop less than 1:  If the pixel at yk is closer to the line path than the pixel at yk+l (that is, d1 < d2), then decision parameter pk is negative and we plot the lower pixel.  On reverse, pk is positive and we plot the upper pixel. If pk is zero ,then choose either yk+l for all such cases, or yk.
  • 28. Line Drawing Algorithms:  Bresenham’s Line Algorithm: Properties of Pk for line with positive slop less than 1:  Incremental integer calculations can be used to obtain values of successive decision parameters, because change occur on either x or y coordinates: pk+1=pk+2y-2x(yk+1-yk) and p0=2y-x
  • 29. Line Drawing Algorithms: Bresenham’s 24 23 Drawing the line between 22 21 the endpoints (3,3) and 20 (23,13) 19 18 17 m= (13-3)/(23-3)= 0.5 16 15 14 13 x= 20 12 y=10 11 10 9 8 P0= 2(10)-20=0 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 30. Line Drawing Algorithms: Bresenham’s 24 K P x+1 y+1 23 22 0 0 4 4 21 1 -20 5 4 20 19 2 0 6 5 18 17 3 -20 7 5 16 4 0 8 6 15 14 5 -20 9 6 13 6 0 10 7 12 11 7 -20 11 7 10 9 8 0 12 8 8 9 -20 13 8 7 6 10 0 14 9 5 4 .. .. .. .. 3 .. .. .. .. 2 1 19 -20 23 13 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 31. Line Drawing Algorithms:  Bresenham’s line algorithm properties  It is generalized to lines with arbitrary slope by considering the symmetry between the various octants and quadrants of the xy plane.  The constants 2y and 2y - 2x are calculated once for each line to be scan converted, so the arithmetic involves only integer addition and subtraction of these two constants.
  • 32. … Finally 24 23 Special cases can be 22 21 handled separately: 20 19 18 Horizontal y=0 17 Vertical x=0 16 15 Diagonal |x|=|y| 14 13 12 each can be loaded 11 10 directly into the frame 9 8 buffer without processing 7 them through the line- 6 5 plotting algorithms. 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 34. Circle Properties:  A set of points that are all at the same distance (r) from a center point (xc,yc).  Expressed by Pythagorean equation in Cartesian coordinates as: (x – xc )2 + (y - yc )2 = r2  Any given circle can be drawn on the origin(0,0) and then moved to its actual position by:  Each calculated x on the circumference moved to x+xc.  Each calculated y on the circumference is moved to y+yc.
  • 35. Circle Generating Algorithms:  Standard Algorithm  Polar Algorithm  Symmetry Algorithm  Mid-point Algorithm (xc, yc ) r (x, y)
  • 36. Standard Algorithm:  Uses the Pythagorean equation to find the points along the circumference.  Steps along x axis by unit steps from xc-r to xc+r and calculate y for each step as: y= yc± √r2-(xc-yc)2  Itinvolves considerable computations at each step.
  • 37. Standard Algorithm:  Spacing between plotted pixels is not uniform.  Spacing can be adjusted by stepping on y instead of x when the slop is greater than 1, but such approach increasing computations.
  • 38. Polar Algorithm:  Uses polar coordinates r and Ө.  Calculate points by fixed regular step size equations as: x= xc + r * cosӨ y= yc + r * sinӨ  Step size that is chosen for Ө depends on the application.  Larger separations can be connected by line segments to approximate the circle path.
  • 39. Polar Algorithm:  In raster displays, step size is 1/r which plots pixel positions that are approximately one unit apart. x,y r Ө
  • 40. Symmetry Algorithm:  Reduces computations by considering the symmetry of circles in the eight octants in the xy plane.  Generates all pixel positions around a circle by calculating only the points within the sector from x = 0 to x = y.
  • 41. Mid-point Algorithm:  Samples at unit intervals and uses decision parameter to determine the closest pixel position to the specified circle path at each step.  Along the circle section from x = 0 to x = y in the first quadrant, the slope of the curve varies from 0 to -1. Therefore, we can take unit steps in the positive x direction over this octant and use a decision parameter to determine which of the two possible y positions is closer to the circle path at each step. Positions in the other seven octants are then obtained by symmetry.
  • 42. Mid-point Algorithm: To apply mid-point method, we define a circle function: and determine the nearest y position from pk:
  • 43. Mid-point Algorithm:  If pk < 0, this midpoint is inside the circle and the pixel on scan line yk is closer to the circle boundary. Otherwise, the midposition is outside or on the circle boundary, and we select the pixel on scan line yk – 1 .  Successive parameters are calculated using incremental calculations:
  • 44. Mid-point Algorithm:  Example: For a circle radius=10 and center (12,12) we calculate positions in the first octant only , beginning with x=0 and ending when x=y The initial decision parameter value: P0=1 - r = -9 Drawing on the origin (0,0) and the initial point (0,10) 2x0=0 2y0=20
  • 45. Mid-point Algorithm: 24 23 K P (xk+1,yk+1) 2xk+1 2yk+1 22 21 0 -9 (1,10) 2 20 20 1 -6 (2,10) 4 20 19 18 2 -1 (3,10) 6 20 17 3 6 (4,9) 8 18 16 15 4 -3 (5,9) 10 18 14 13 5 8 (6,8) 12 16 12 6 5 (7,7) 14 14 11 10 9 8 The first octant is completed 7 and the remained seven 6 5 octants can be plotted 4 3 according to symmetry. 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 46. Mid-point Algorithm: 24 23 The circle after plotting all 22 21 octants and moving it to its 20 original center (12,12) 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  • 48. Ellipse Properties: ry F2 rx F1 d2 d1 P=(x,y)
  • 49. Ellipse Properties:  An elongated circle.  A set of points having an equal sum distances from two fixed positions (foci F1,F2). d1+d2=constant  The major axis is the straight line segment extending from one side of the ellipse to the other through the foci.  The minor axis spans the shorter dimension of the ellipse, bisecting the major axis at the halfway position (ellipse center) between the two foci.  The two foci and point coordinates on the circumference are enough information to plot an ellipse with arbitrary orientation.
  • 50. Ellipse Properties:  The equation of the ellipse can be written in terms of the ellipse center coordinates and parameters rx, and ry, as:  Using polar coordinates r and Ө. we can also describe the ellipse in standard position with the parametric equations: x= xc + rx * cosӨ y= yc + ry * sinӨ  Symmetry considerations can be used to reduce computations, the four quadrants are similar ( not the eight octants).
  • 51. Midpoint Ellipse Algorithm:  Similar to displaying a raster circle.  Given parameters rx, ry, and (xc,yc), we determine points ( x , y) for an ellipse in standard position centered on the origin, and then we shift the points so the ellipse is centered at ( xc,yc).  To display the ellipse in nonstandard position, we could then rotate the ellipse about its center coordinates to reorient the major and minor axes.  This method is applied throughout the first quadrant in two parts:  Stepping on x when the slop is less than 1.  Stepping on y when the slop is greater than 1.
  • 52. Midpoint Ellipse Algorithm:  The decision parameter considered by: It has the following properties: The next position to be selected depends on the sign of this parameter.  The same way followed in circle we can use to choose the start point and depending on the slop and Pk calculate the next nearest pixel on the ellipse path.
  • 54. Overview:  Include: conics, trigonometric and exponential functions, probability distributions, general polynomials, and spline functions.  Positions along paths can be generated from curves explicit equations y= f(x) .  Incremental midpoints can be calculated from implicit function f(x,y)=0.  The same idea in the previous primitives, choosing the stepping axis, can be used to obtain uniform spacing between points.  Symmetries are also available in some curves, such as  The normal probability distribution function is symmetric about at center position (the mean).  All points along one cycle of a sine curve can be generated from the points in a 90" interval.
  • 55. Conic Sections:  Described by:  The parameters A,B,C,D,E,F values determine the section type:
  • 56. Conic Sections: Parabolic path Hyperbola Path
  • 57. Polynomial and Splines Curves:  Polynomial is defined as: where n is a nonnegative integer and the ak are constants, with a≠0.  We get:  A straight line when n=1.  A quadratic when n=2.  A cubic polynomial when n=3.  A quartic when n=4…
  • 58. Polynomial and Splines Curves:  Designing object shapes or motion paths is typically done by specifying a few points to define the general curve contour, then fitting the selected points with a polynomial.  One way to accomplish the curve fitting is to construct a cubic polynomial curve section between each pair of specified points.  Each curve section is then described in parametric form as: where parameter u varies over the interval 0 to 1.
  • 59. Polynomial and Splines Curves:  Values for the coefficients of u in the parametric equations are determined from boundary conditions on the curve sections:  Two adjacent curve sections have the same coordinate position at the boundary.  Match the two curve slopes at the boundary so that we obtain one continuous, smooth individual cubic curve.  Splines are continuous curves formed with polynomial pieces.
  • 61. Overview:  Two basic ideas:  Determine the overlap intervals for scan lines that cross the area. Used to fill polygons, circles, ellipses, and other simple curves.  Start from a given interior position and paint outward from this point until we encounter the specified boundary conditions. Used with more complex boundaries and in interactive painting systems.
  • 62. Filled Area Primitives:  Scan-Line Polygon Fill Algorithm:  Locates the intersection points along the scan line with the polygon edges.  Sorts the intersections from left to right.  Set the corresponding frame buffer positions between each intersection with a specified fill color.  Special handling:  Scan line passing through a vertex intersects two edges at that position: add two points to the list of intersections for the scan line.  Care should be taken to determine which side of intersection is belonging to the polygon.
  • 63. Filled Area Primitives: Such situations need more processing to determine: 1. Whether there is a need to duplicate some intersections. 2. If the points are inside or outside the shape. We should trace around the shape boundaries to make a decision.
  • 68. Inside-Outside Tests:  Odd-even (odd parity or even odd) rule:  Drawing a line from any position P to a distant point outside the coordinate extents of the object.  Counting the number of edge crossings along the line. If the number of polygon edges crossed by this line is odd, then P is an interior point, otherwise it is an exterior point. The line chosen must not intersect the polygon vertices.
  • 69. Inside-Outside Tests:  Non-zero winding number rule:  Counts the number of times the polygon edges wind around a particular point in the counterclockwise direction, which is called “winding number”.  Interior points of a two-dimensional object are defined to be those that have a nonzero value for the winding number.  Counting method:  Start winding number with 0.  Imagine a line passing across the object and not intersect vertices.  Add 1 to winding number when the line is crossed by an edge from right to left.  Subtract 1 from winding number when the line is crossed by an edge from left to right.  To determine the direction use either cross product or dot product.
  • 71. Scan-Line Fill of Curved Boundary Areas : In circles and ellipses, only find the two scan-line Intersections on opposite sides of the curve. In other curves, such as ellipse arc, the interior region is bounded by the ellipse section and a straight-line segment that closes the curve by joining the beginning and ending positions of the arc. Symmetry can be exploited to reduce calculations.
  • 72. Boundary-Fill Algorithm:  Accepts as input the coordinates of an interior point (x, y), a fill color, and a boundary color.  Starting from (x,y), the procedure tests neighboring positions to determine whether they are of the boundary color.  If not, they are painted with the fill color, and their neighbors are tested.  This process continues until all pixels up to the boundary color for the area have been tested.
  • 75. Flood-Fill Algorithm:  Replacing a specified interior color instead of searching for a boundary color value.  Start from a specified interior point (x, y) and reassign all pixel values that are currently set to a given interior color with the desired fill color.  If the area we want to paint has more than one interior color, we can first reassign pixel values so that all interior points have the same color.  Using either a 4-connected or 8-connected approach, we then step through pixel positions until all interior points have been repainted.
  • 77. Typefaces (Fonts):  Serif group:  Has small lines or accents at the ends of the main character strokes.  More readable.  Sans serif group:  Does not have accents.  The individual characters easier to recognize.  More legible, and hence, good for labeling and short headings.
  • 78. Character Generation Methods:  Bitmapped Font:  Uses rectangular grid patterns.  The simplest to define and display, the character grid only needs to be mapped to a frame-buffer position.  Need more space, each variation (size and format) must be stored in a font cache.  Outline Font:  Uses straight-line and curve sections.  Require less storage since each variation does not require a distinct font cache.  Need more time since to the scan conversion process.
  • 79. Character Generation Methods: Bitmapped Font Outline Font