Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf ·...

124
ECM2410: Graphics and Animation Rasterisation Part I: Simple Lines Rasterisation 1/16

Transcript of Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf ·...

Page 1: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

ECM2410: Graphics and Animation

Rasterisation

Part I: Simple Lines

Rasterisation 1/16

Page 2: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rendering a scene

User space Device space

Compose Render

Affine transformation

Transform

Compose from primitives (lines, ellipses, etc) in user space.

Transform affine transformations:lines→ lines;ellipses→ ellipses

Render primitives on device.Rasterisation Line Rasterisation 2/16

Page 3: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rendering a scene

User space Device space

Compose Render

Affine transformation

Transform

Compose from primitives (lines, ellipses, etc) in user space.

Transform affine transformations:lines→ lines;ellipses→ ellipses

Render primitives on device.Rasterisation Line Rasterisation 2/16

Page 4: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rendering a scene

User space Device space

Compose Render

Affine transformation

Transform

Compose from primitives (lines, ellipses, etc) in user space.

Transform affine transformations:lines→ lines;ellipses→ ellipses

Render primitives on device.Rasterisation Line Rasterisation 2/16

Page 5: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rendering a scene

User space Device space

Compose Render

Affine transformation

Transform

Compose from primitives (lines, ellipses, etc) in user space.

Transform affine transformations:lines→ lines;ellipses→ ellipses

Render primitives on device.Rasterisation Line Rasterisation 2/16

Page 6: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rendering a scene

User space Device space

Compose Render

Affine transformation

Transform

Compose from primitives (lines, ellipses, etc) in user space.

Transform affine transformations:lines→ lines;ellipses→ ellipses

Render primitives on device.Rasterisation Line Rasterisation 2/16

Page 7: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 8: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 9: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 10: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 11: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 12: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 13: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 14: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 15: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 16: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 17: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 18: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 19: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 20: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 21: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Vector displaysPen plottersTektronix cathode ray tubes

Raster displaysMonitorsTelevisionsLaser, ink-jet, dot matrix printersLiquid crystal displaysArrays of LEDs

Rasterisation is the conversion of ideal, mathematicalgraphics primitives onto raster displays.

Drawing linesDrawing circles and ellipsesFilling areas

Hearn & Baker, Chapter 2 for displays.Rasterisation Line Rasterisation 3/16

Page 22: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 23: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 24: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 25: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 26: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 27: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 28: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 29: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Framebuffer

Raster display is a 2D array of picture elements: pixelsFramebuffer: in-memory image of the display.

00

1 2

12

Screen coordinates of pixelsare centered at the integers.

Pixels are individually set orcleared (random access).Sequential readout byphysical device.

Graphical objects arecontinuous.Framebuffer is discrete.

Rasterisation / Framebuffer Line Rasterisation 4/16

Page 30: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 31: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 32: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 33: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 34: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 35: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 36: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Rasterisation

Rasterisationis the conversion of ideal, mathematical graphicsprimitives onto raster displays.

Efficiencywe seek efficient algorithms for computing thediscrete approximation to continuous description.

Scan Conversionrasterisation line by line of the raster display.

Rasterisation / Framebuffer Line Rasterisation 5/16

Page 37: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 38: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 39: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 40: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 41: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 42: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 43: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 44: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Line Segments

Problem: Draw a line from (Xstart ,Ystart) to (Xend ,Yend )Simplified: Draw a line from (0, 0) to (Xend ,Yend )

(Xend > 0 and Yend > 0)

(0,0)

(19,4)

Grid marks pixel centres

Example: Line from (0, 0) to (Xend ,Yend )= (19, 4)

Lines Line Rasterisation 6/16

Page 45: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Which pixels to illuminate?

Illuminate every pixel the line intersects

Illuminate the vertically closest pixel

Lines / Which Pixel? Line Rasterisation 7/16

Page 46: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Which pixels to illuminate?

Illuminate every pixel the line intersects

Illuminate the vertically closest pixel

Lines / Which Pixel? Line Rasterisation 7/16

Page 47: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Which pixels to illuminate?

Illuminate every pixel the line intersects

Illuminate the vertically closest pixel

Lines / Which Pixel? Line Rasterisation 7/16

Page 48: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Which pixels to illuminate?

Illuminate every pixel the line intersects

Illuminate the vertically closest pixel

Lines / Which Pixel? Line Rasterisation 7/16

Page 49: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Which pixels to illuminate?

Illuminate every pixel the line intersects

Illuminate the vertically closest pixel

Lines / Which Pixel? Line Rasterisation 7/16

Page 50: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 51: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 52: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 53: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 54: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 55: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 56: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Gradient

Gradient of line

y = m x + c

m =Yend − Ystart

Xend − Xstart

Simplified line from (0, 0) to (Xend ,Yend ):

y = m x , m =Yend

Xend

Lines / Gradient Line Rasterisation 8/16

Page 57: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Naïve Midpoint Algorithm

Illuminate pixel vertically closest to the line

4/198/19 16/19

12/19

double m = Yend / Xend;int x = 0;double y = 0.0;

while ( x <= Xend ) {y = m * x;iy = round(y);setpixel(x, iy);x++;

}

DDA Digital Differential Analyser. Hearn & Baker, p86.

Floating point operations and round() are computationallyexpensive.

Lines / Naïve Algorithm Line Rasterisation 9/16

Page 58: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Naïve Midpoint Algorithm

Illuminate pixel vertically closest to the line

4/198/19 16/19

12/19

double m = Yend / Xend;int x = 0;double y = 0.0;

while ( x <= Xend ) {y = m * x;iy = round(y);setpixel(x, iy);x++;

}

DDA Digital Differential Analyser. Hearn & Baker, p86.

Floating point operations and round() are computationallyexpensive.

Lines / Naïve Algorithm Line Rasterisation 9/16

Page 59: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Naïve Midpoint Algorithm

Illuminate pixel vertically closest to the line

4/198/19 16/19

12/19

double m = Yend / Xend;int x = 0;double y = 0.0;

while ( x <= Xend ) {y = m * x;iy = round(y);setpixel(x, iy);x++;

}

DDA Digital Differential Analyser. Hearn & Baker, p86.

Floating point operations and round() are computationallyexpensive.

Lines / Naïve Algorithm Line Rasterisation 9/16

Page 60: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Naïve Midpoint Algorithm

Illuminate pixel vertically closest to the line

4/198/19 16/19

12/19

double m = Yend / Xend;int x = 0;double y = 0.0;

while ( x <= Xend ) {y = m * x;iy = round(y);setpixel(x, iy);x++;

}

DDA Digital Differential Analyser. Hearn & Baker, p86.

Floating point operations and round() are computationallyexpensive.

Lines / Naïve Algorithm Line Rasterisation 9/16

Page 61: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Naïve Midpoint Algorithm

Illuminate pixel vertically closest to the line

4/198/19 16/19

12/19

double m = Yend / Xend;int x = 0;double y = 0.0;

while ( x <= Xend ) {y = m * x;iy = round(y);setpixel(x, iy);x++;

}

DDA Digital Differential Analyser. Hearn & Baker, p86.

Floating point operations and round() are computationallyexpensive.

Lines / Naïve Algorithm Line Rasterisation 9/16

Page 62: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Naïve Midpoint Algorithm

Illuminate pixel vertically closest to the line

4/198/19 16/19

12/19

double m = Yend / Xend;int x = 0;double y = 0.0;

while ( x <= Xend ) {y = m * x;iy = round(y);setpixel(x, iy);x++;

}

DDA Digital Differential Analyser. Hearn & Baker, p86.

Floating point operations and round() are computationallyexpensive.

Lines / Naïve Algorithm Line Rasterisation 9/16

Page 63: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 64: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 65: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 66: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 67: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 68: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 69: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Remove round()

Line coherence: As x 7→ x + 1 then y 7→ y + m

4/1916/19

12/19

8/19

At each step: move right one pixeland up by 4

19 .

midpoint indicates pixel centreabove illuminated pixel.

When y crosses verticalmidpoint between two centresmove up and compute newmidpoint target.

double m = Yend / Xend;int x = 0;int iy = 0;double y = 0.0;double midpoint = 0.5;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 1.0;

}}

Lines / Eliminating Floats Line Rasterisation 10/16

Page 70: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 71: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 72: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 73: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 74: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 75: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 76: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Integers only

m =Yend

Xendy = m x =

Yend xXend

Multiply m, y and midpoint bytwice total change in x ;(i.e. by 2Xend )

m = 2 Yend y = 2 Yendx

2432

y=816

19 19 57midpoint19 57

int m = 2 * Yend;int x = 0;int iy = 0;int y = 0;int midpoint = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y += m;

if (y > midpoint) {iy++;midpoint += 2 * Xend;

}}

Lines / Eliminating Floats Line Rasterisation 11/16

Page 77: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham’s algorithm

Eliminate midpoint by adjusting y tostart at the midpoint and decreasingto 0.

y=19

3 −5 => 332511

Hearn & Baker, page 88

int m = 2 * Yend;int x = 0;int iy = 0;int y = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y -= m;

if (y < 0) {iy++;y += 2 * Xend;

}}

Lines / Bresenham’s Algorithm Line Rasterisation 12/16

Page 78: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham’s algorithm

Eliminate midpoint by adjusting y tostart at the midpoint and decreasingto 0.

y=19

3 −5 => 332511

Hearn & Baker, page 88

int m = 2 * Yend;int x = 0;int iy = 0;int y = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y -= m;

if (y < 0) {iy++;y += 2 * Xend;

}}

Lines / Bresenham’s Algorithm Line Rasterisation 12/16

Page 79: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham’s algorithm

Eliminate midpoint by adjusting y tostart at the midpoint and decreasingto 0.

y=19

3 −5 => 332511

Hearn & Baker, page 88

int m = 2 * Yend;int x = 0;int iy = 0;int y = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y -= m;

if (y < 0) {iy++;y += 2 * Xend;

}}

Lines / Bresenham’s Algorithm Line Rasterisation 12/16

Page 80: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham’s algorithm

Eliminate midpoint by adjusting y tostart at the midpoint and decreasingto 0.

y=19

3 −5 => 332511

Hearn & Baker, page 88

int m = 2 * Yend;int x = 0;int iy = 0;int y = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y -= m;

if (y < 0) {iy++;y += 2 * Xend;

}}

Lines / Bresenham’s Algorithm Line Rasterisation 12/16

Page 81: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham’s algorithm

Eliminate midpoint by adjusting y tostart at the midpoint and decreasingto 0.

y=19

3 −5 => 332511

Hearn & Baker, page 88

int m = 2 * Yend;int x = 0;int iy = 0;int y = Xend;

while (x <= Xend) {setpixel(x, iy);x++;y -= m;

if (y < 0) {iy++;y += 2 * Xend;

}}

Lines / Bresenham’s Algorithm Line Rasterisation 12/16

Page 82: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 83: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 84: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 85: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 86: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 87: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 88: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 89: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 90: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 91: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 92: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 93: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Caveats

Needs adjustment for:

General starting pointm > 1

Negative slopes

Lines with different slope may have different brightness.Alleviated with anti-aliasing(give pixels different brightness).

References

Hearn & Baker, pp. 84-94Foley & van Dam

Lines / Bresenham’s Algorithm Line Rasterisation 13/16

Page 94: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 95: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 96: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 97: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 98: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 99: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 100: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Bresenham Circle Algorithm

Choose pixel withcentre closest tocircle.

Work on a singleoctant and drawothers by symmetry.

Can be written ininteger arithmetic.

Details in Hearn &Baker, Foley et al.

Lines / Bresenham Circle Algorithm Line Rasterisation 14/16

Page 101: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 102: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 103: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 104: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 105: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 106: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 107: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 108: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 109: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 110: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 111: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Column Replication

Efficient, easily implemented.Perceived thickness varieswith slope.Gaps at joins.

Rectangular Pen

Ends are thicker than middle.Perceived thickness varieswith slope.Pixels are set multiple times.

Lines / Thick Primitives Line Rasterisation 15/16

Page 112: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 113: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 114: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 115: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 116: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 117: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 118: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 119: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 120: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 121: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 122: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 123: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16

Page 124: Rasterisation - University of Exeterempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides07.pdf · Rasterisation Vector displays Pen plotters Tektronix cathode ray tubes Raster displays

Thick Primitives

Circular Pen

Thickness independent of slope.

Pixels are set multiple times.

Can be made efficient by settingonly boundary pixels.

Boundary Fill

Fill the area between boundaries.

Polygon with edges parallel toprimitive.

Precise control over joins(butt, bevel, cap ends)

Lines, circles become polygons.

Expensive.

Lines / Thick Primitives Line Rasterisation 16/16