SlideShare a Scribd company logo
Graphics 1
Graphics & Graphical
Programming
Lecture 2 - Graphics Fundamentals
Graphics 2
Fundamentals Outline
• Historical perspective
• Model of a Computer - Memory & Graphics
• Devices
• Raster Model & Bitmaps
• Coordinates
• Drawing Spaces
• Colours
• Graphics Libraries
Graphics 3
Brief History
• Teletypes(pre 1950s), Display Tubes(post
WW2), CRTs(last half of 20th century), Flat
Panels (modern era)
• Size and Quality (eg resolution) driven by
economics (eg 640x320…1024x768…)
• Vector (circa WW2) & Raster/Bitmap models
• Devices & Human / Machine Interaction
• Memory and Processing Speed limitations
Graphics 4
Computer Memory Model
• Main Memory
• Graphics memory
– Used to be limited to separate
amount on eg graphics card
– Modern idea is to partition
main memory dynamically
(ie by software instruction)
• Modern idea is to map
memory to the display
• Independent of display
hardware type
• CPU + Cache memory +
Main memory
• Cache memory is fast but
expensive so (still often)
only have small amount eg
512kBytes available
• Main memory relatively
plentiful (eg GBytes) but
slow
Graphics 5
Memory & Graphics
• Idea is that we can write
programs that interact
with the graphical
display device simply
by writing to a
predetermined area of the
computer’s memory
• Known as Bitmap graphics
• The bits are mapped to the
pixels
• Flexible, portable software
• Independent of Hardware &
Operating System
Graphics 6
Graphical Devices
• Devices eg mouse,
stereo glasses, tracker
ball, light pen, touch
screen, 3d-wand, “rat”,
sensor gloves, head
tracker, iris tracker,…
• Even Mouse varies in
form factor and number
of buttons
• Mouse - most well known
device
• Buttons, and scan movements
• Jargon ideas that have become
common:
– Drag
– Click
– Double-Click
– Left -Click
• Main idea is to let you specify a
location in a space eg x,y (or
x,y,z) coordinates
Graphics 7
Raster Model - Pixels
• Pixel or sometimes “pel”
Picture Element
• Each pixel is a sample
that can be rendered as a
dot or rectangle on the
screen
• Often try to design them
as squares but not always
• Might be implemented
as small area of
phosphor on a
monochrome monitor
• Or three areas of eg
red, green and blue
phosphors for colour
• Or simple a transistor
logic gate assembly
on a flat panel display
Graphics 8
Coordinate Systems
• Pixel Coordinate System -
rows and columns
• Rectilinear
• Usually for graphics, we
start at top left corner and
work our way across and
down
• Same as raster orientation
• Array[row][column]
• Row major used in C
and C+ ( last index
moves fastest in
memory)
• Not all languages do
it this way - eg Fortran
uses column major
(first index moves
fastest)
Graphics 9
Cartesian Coordinates
• Often we use the
Cartesian coordinate
convention ie x,y
coordinates (or x,y,z
in 3D) and map this
to our display
• Usually column
corresponds to x, and
-row corresponds to y
• This works if we know
the max min values.
• Common values are eg
640 columns x 320 rows
• Or 1024x768 or better
• Aspect ratio is the ratio of
these eg 4:3 - Chosen to suit
the common display devices
eg TV screens or monitors
x
y
Graphics 10
Drawing Space or Canvas
• Coordinate Systems
• Drawing Primitives
• Library of utilities
– eg drawDot( int x, int y);
– Or drawLine( x1, y1, x2, y2 );
• Usually we have “Primitive”
Models for coordinate spaces
and colours
• We do not want to write
our application programs
worrying about pixel
resolutions
• We may have libraries
that allow us to do so, but
often they will support
more general coordinates
• Eg real space
“normalised” coordinates
[0.0,1.0]
Graphics 11
Colours in Brief
• Red Green Blue is not the
Only colour model although
still most common
• We specify separate RGB
values for each pixel
• They map to intensities
• All colours can be expressed
as combination of these
• Sometimes also an “alpha” or
transparency value
• These will conveniently pack
into a computer word of 4
bytes, one byte for each
entity
• 1 Byte gives us 256 values
- hence numbers of colours
• Need not use this resolution
• Can also use Look-up tables
to save memory
Graphics 12
Graphics Libraries and packages
• What is a graphics
system?
• A package or Library
that links to a Language
or environment and lets
us write programs that
are independent of the
graphics hardware and
devices
• Java Development Kit
and Java 2D and Java
3D libraries
• GL and OpenGL
(Graphics Library),
VOGL
• X11, DirectX, PHIGS,…
and lots of others
Graphics 13
Java Graphics Program Outline
• A short example- MyProg01 draws a black
rectangle inside a white rectangle
• See the course web pages for these codes
• Use a text editor or your favourite text tool
(eg emacs or vi or notepad) to create
MyProg01.java
• Compile it using javac MyProg01.java
• Run using java Myprog01
Graphics 14
Java Graphics Code Fragment
// g2 is the Graphics2D object supplied by the system…
g2.setBackground( Color.white ); // set background colour
g2.clearRect( 0, 0, getWidth(), getHeight() ); // clear an area
g2.setColor( Color.black ); // set the drawing colour
g2.fillRect( 10, 10, 20, 20 ); // fill in a rectangle of that colour
g2.drawRect( 0, 0, getWidth()-1, getHeight()-1 ); // draw a border around everything
• More on how this works next lecture and at
the tutorials…
Graphics 15
What MyProg01 Output Looks Like
Black rectangle inside a white area…
Graphics 16
Summary
• Graphics has a varied
history
• Very technology driven
• Good advances in recent
years with adequate
memory and processing
power
• Primitives and library
layers approach is very
common
• Note devices and
memory model
• Colour models and
drawing spaces are
important ideas for our
programs
• We will use the Java
Development Kit graphics
libraries and primitives

More Related Content

PPTX
Overview of Computer Graphics
United International University
 
PDF
Computer graphics notes
smruti sarangi
 
PPT
Introduction to computer graphics
Partnered Health
 
PPT
Overview of graphics systems
Jay Nagar
 
PPT
Computer graphics - Nitish Nagar
Nitish Nagar
 
PPT
lecture4 raster details in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
lecture1 introduction to computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPTX
Application of computer graphics and input devices
Mani Kanth
 
Overview of Computer Graphics
United International University
 
Computer graphics notes
smruti sarangi
 
Introduction to computer graphics
Partnered Health
 
Overview of graphics systems
Jay Nagar
 
Computer graphics - Nitish Nagar
Nitish Nagar
 
lecture4 raster details in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
lecture1 introduction to computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Application of computer graphics and input devices
Mani Kanth
 

What's hot (20)

PPTX
1. Introduction of Computer Graphics
Aparna Joshi
 
PPTX
Computer Graphics
NANDINI SHARMA
 
PPTX
Computer graphics.
ALIHAMID71
 
PPT
Lecture applications of cg
avelraj
 
PDF
Introduction Computer Graphic
Suwanna Thongkhome
 
PPTX
Frame buffer
Aparna Joshi
 
PPT
Introduction to computer graphics
Amandeep Kaur
 
PPTX
Introduction to computer graphics
Priyodarshini Dhar
 
PPT
Computer Graphics
Ankur Soni
 
PDF
Computer graphics
Bilal Maqbool ツ
 
PPTX
Introduction to computer graphics
Rajamanickam Gomathijayam
 
PPTX
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
PPTX
Computer Graphics
Adri Jovin
 
PPTX
Introduction to computer graphics
sonal_badhe
 
PPT
Applications of cg
Ankit Garg
 
PPTX
Applications Of Computer Graphics
Muhammad Amjad Rana
 
PPTX
Applications of computer graphics
-jyothish kumar sirigidi
 
PDF
Unit-1 basics of computer graphics
Amol Gaikwad
 
PPT
computer graphics
ashpri156
 
1. Introduction of Computer Graphics
Aparna Joshi
 
Computer Graphics
NANDINI SHARMA
 
Computer graphics.
ALIHAMID71
 
Lecture applications of cg
avelraj
 
Introduction Computer Graphic
Suwanna Thongkhome
 
Frame buffer
Aparna Joshi
 
Introduction to computer graphics
Amandeep Kaur
 
Introduction to computer graphics
Priyodarshini Dhar
 
Computer Graphics
Ankur Soni
 
Computer graphics
Bilal Maqbool ツ
 
Introduction to computer graphics
Rajamanickam Gomathijayam
 
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
Computer Graphics
Adri Jovin
 
Introduction to computer graphics
sonal_badhe
 
Applications of cg
Ankit Garg
 
Applications Of Computer Graphics
Muhammad Amjad Rana
 
Applications of computer graphics
-jyothish kumar sirigidi
 
Unit-1 basics of computer graphics
Amol Gaikwad
 
computer graphics
ashpri156
 
Ad

Similar to fundamentals of Computer graphics(Computer graphics tutorials) (20)

PPS
CS101- Introduction to Computing- Lecture 33
Bilal Ahmed
 
PPT
Overview of graphics systems.ppt
MalleshBettadapura1
 
PPT
unit-1-basics-of-computer-graphics.ppt 7th sem
PankajPakhare1
 
PPT
Ciencias de la computación, Gráficos por computadora.
Watchsoft
 
PPTX
CADCAM: Product life cycle and CAD input, out puts advantages and
SivarajuR
 
PDF
UNit4.pdf
SugumarSarDurai
 
PPTX
This gives a brief detail about big data
chinky1118
 
PPTX
What is OpenGL ?
Mohammad Hosein Nemati
 
PPS
CS101- Introduction to Computing- Lecture 34
Bilal Ahmed
 
PDF
lec01_introanalytics-for-the-internet-of-things-iot-intelligent-analytics-for...
baburaobaban
 
PDF
Disco workshop
spil-engineering
 
PPTX
Hadoop-part1 in cloud computing subject.pptx
JyotiLohar6
 
PPTX
Unit 11. Graphics
Ashim Lamichhane
 
PPTX
Gpu with cuda architecture
Dhaval Kaneria
 
PPTX
Graphics Primitives and CG Display Devices
DIPIKA83
 
PDF
Sony Computer Entertainment Europe Research & Development Division
Slide_N
 
PDF
Mod 2 hardware_graphics.pdf
DavidsonJebaseelan1
 
PPT
Buffers
Syed Zaid Irshad
 
PPT
Introduction to computer
lina hajjar
 
PPTX
Lecture2-MapReduce - An introductory lecture to Map Reduce
ssuserb91a20
 
CS101- Introduction to Computing- Lecture 33
Bilal Ahmed
 
Overview of graphics systems.ppt
MalleshBettadapura1
 
unit-1-basics-of-computer-graphics.ppt 7th sem
PankajPakhare1
 
Ciencias de la computación, Gráficos por computadora.
Watchsoft
 
CADCAM: Product life cycle and CAD input, out puts advantages and
SivarajuR
 
UNit4.pdf
SugumarSarDurai
 
This gives a brief detail about big data
chinky1118
 
What is OpenGL ?
Mohammad Hosein Nemati
 
CS101- Introduction to Computing- Lecture 34
Bilal Ahmed
 
lec01_introanalytics-for-the-internet-of-things-iot-intelligent-analytics-for...
baburaobaban
 
Disco workshop
spil-engineering
 
Hadoop-part1 in cloud computing subject.pptx
JyotiLohar6
 
Unit 11. Graphics
Ashim Lamichhane
 
Gpu with cuda architecture
Dhaval Kaneria
 
Graphics Primitives and CG Display Devices
DIPIKA83
 
Sony Computer Entertainment Europe Research & Development Division
Slide_N
 
Mod 2 hardware_graphics.pdf
DavidsonJebaseelan1
 
Introduction to computer
lina hajjar
 
Lecture2-MapReduce - An introductory lecture to Map Reduce
ssuserb91a20
 
Ad

More from Daroko blog(www.professionalbloggertricks.com) (20)

DOCX
Small Business ideas you can start in Nigeria 2014(best Business ideas Nigeri...
Daroko blog(www.professionalbloggertricks.com)
 
DOCX
Agriculture business ideas for 2014(Business ideas Kenya,Business ideas Niger...
Daroko blog(www.professionalbloggertricks.com)
 
DOC
An Introduction to Project management(project management tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
java arlow jdbc tutorial(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
The java rogramming swing _tutorial for beinners(java programming language)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
advanced java programming(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
An introduction to java programming language forbeginners(java programming tu...
Daroko blog(www.professionalbloggertricks.com)
 
PPT
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
Computer Graphics display technologies(Computer graphics tutorials and tips)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
Computer Graphics display technologies(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
Displays and color system in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
DOC
Data structures graphics library in computer graphics.
Daroko blog(www.professionalbloggertricks.com)
 
PPT
Csc406 lecture7 device independence and normalization in Computer graphics(Co...
Daroko blog(www.professionalbloggertricks.com)
 
PPT
lecture3 color representation in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
lecture2 computer graphics graphics hardware(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
2d/3D transformations in computer graphics(Computer graphics Tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
Computer graphics defination(An introuction to computer garphics)
Daroko blog(www.professionalbloggertricks.com)
 
Small Business ideas you can start in Nigeria 2014(best Business ideas Nigeri...
Daroko blog(www.professionalbloggertricks.com)
 
Agriculture business ideas for 2014(Business ideas Kenya,Business ideas Niger...
Daroko blog(www.professionalbloggertricks.com)
 
An Introduction to Project management(project management tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
java arlow jdbc tutorial(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
The java rogramming swing _tutorial for beinners(java programming language)
Daroko blog(www.professionalbloggertricks.com)
 
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
advanced java programming(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
An introduction to java programming language forbeginners(java programming tu...
Daroko blog(www.professionalbloggertricks.com)
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Computer Graphics display technologies(Computer graphics tutorials and tips)
Daroko blog(www.professionalbloggertricks.com)
 
Computer Graphics display technologies(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Displays and color system in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Data structures graphics library in computer graphics.
Daroko blog(www.professionalbloggertricks.com)
 
Csc406 lecture7 device independence and normalization in Computer graphics(Co...
Daroko blog(www.professionalbloggertricks.com)
 
lecture3 color representation in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
lecture2 computer graphics graphics hardware(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
2d/3D transformations in computer graphics(Computer graphics Tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Computer graphics defination(An introuction to computer garphics)
Daroko blog(www.professionalbloggertricks.com)
 

Recently uploaded (20)

PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
MariellaTBesana
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTX
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Electricity-Magnetic-and-Heating-Effects 4th Chapter/8th-science-curiosity.pd...
Sandeep Swamy
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
MariellaTBesana
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Electricity-Magnetic-and-Heating-Effects 4th Chapter/8th-science-curiosity.pd...
Sandeep Swamy
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 

fundamentals of Computer graphics(Computer graphics tutorials)

  • 1. Graphics 1 Graphics & Graphical Programming Lecture 2 - Graphics Fundamentals
  • 2. Graphics 2 Fundamentals Outline • Historical perspective • Model of a Computer - Memory & Graphics • Devices • Raster Model & Bitmaps • Coordinates • Drawing Spaces • Colours • Graphics Libraries
  • 3. Graphics 3 Brief History • Teletypes(pre 1950s), Display Tubes(post WW2), CRTs(last half of 20th century), Flat Panels (modern era) • Size and Quality (eg resolution) driven by economics (eg 640x320…1024x768…) • Vector (circa WW2) & Raster/Bitmap models • Devices & Human / Machine Interaction • Memory and Processing Speed limitations
  • 4. Graphics 4 Computer Memory Model • Main Memory • Graphics memory – Used to be limited to separate amount on eg graphics card – Modern idea is to partition main memory dynamically (ie by software instruction) • Modern idea is to map memory to the display • Independent of display hardware type • CPU + Cache memory + Main memory • Cache memory is fast but expensive so (still often) only have small amount eg 512kBytes available • Main memory relatively plentiful (eg GBytes) but slow
  • 5. Graphics 5 Memory & Graphics • Idea is that we can write programs that interact with the graphical display device simply by writing to a predetermined area of the computer’s memory • Known as Bitmap graphics • The bits are mapped to the pixels • Flexible, portable software • Independent of Hardware & Operating System
  • 6. Graphics 6 Graphical Devices • Devices eg mouse, stereo glasses, tracker ball, light pen, touch screen, 3d-wand, “rat”, sensor gloves, head tracker, iris tracker,… • Even Mouse varies in form factor and number of buttons • Mouse - most well known device • Buttons, and scan movements • Jargon ideas that have become common: – Drag – Click – Double-Click – Left -Click • Main idea is to let you specify a location in a space eg x,y (or x,y,z) coordinates
  • 7. Graphics 7 Raster Model - Pixels • Pixel or sometimes “pel” Picture Element • Each pixel is a sample that can be rendered as a dot or rectangle on the screen • Often try to design them as squares but not always • Might be implemented as small area of phosphor on a monochrome monitor • Or three areas of eg red, green and blue phosphors for colour • Or simple a transistor logic gate assembly on a flat panel display
  • 8. Graphics 8 Coordinate Systems • Pixel Coordinate System - rows and columns • Rectilinear • Usually for graphics, we start at top left corner and work our way across and down • Same as raster orientation • Array[row][column] • Row major used in C and C+ ( last index moves fastest in memory) • Not all languages do it this way - eg Fortran uses column major (first index moves fastest)
  • 9. Graphics 9 Cartesian Coordinates • Often we use the Cartesian coordinate convention ie x,y coordinates (or x,y,z in 3D) and map this to our display • Usually column corresponds to x, and -row corresponds to y • This works if we know the max min values. • Common values are eg 640 columns x 320 rows • Or 1024x768 or better • Aspect ratio is the ratio of these eg 4:3 - Chosen to suit the common display devices eg TV screens or monitors x y
  • 10. Graphics 10 Drawing Space or Canvas • Coordinate Systems • Drawing Primitives • Library of utilities – eg drawDot( int x, int y); – Or drawLine( x1, y1, x2, y2 ); • Usually we have “Primitive” Models for coordinate spaces and colours • We do not want to write our application programs worrying about pixel resolutions • We may have libraries that allow us to do so, but often they will support more general coordinates • Eg real space “normalised” coordinates [0.0,1.0]
  • 11. Graphics 11 Colours in Brief • Red Green Blue is not the Only colour model although still most common • We specify separate RGB values for each pixel • They map to intensities • All colours can be expressed as combination of these • Sometimes also an “alpha” or transparency value • These will conveniently pack into a computer word of 4 bytes, one byte for each entity • 1 Byte gives us 256 values - hence numbers of colours • Need not use this resolution • Can also use Look-up tables to save memory
  • 12. Graphics 12 Graphics Libraries and packages • What is a graphics system? • A package or Library that links to a Language or environment and lets us write programs that are independent of the graphics hardware and devices • Java Development Kit and Java 2D and Java 3D libraries • GL and OpenGL (Graphics Library), VOGL • X11, DirectX, PHIGS,… and lots of others
  • 13. Graphics 13 Java Graphics Program Outline • A short example- MyProg01 draws a black rectangle inside a white rectangle • See the course web pages for these codes • Use a text editor or your favourite text tool (eg emacs or vi or notepad) to create MyProg01.java • Compile it using javac MyProg01.java • Run using java Myprog01
  • 14. Graphics 14 Java Graphics Code Fragment // g2 is the Graphics2D object supplied by the system… g2.setBackground( Color.white ); // set background colour g2.clearRect( 0, 0, getWidth(), getHeight() ); // clear an area g2.setColor( Color.black ); // set the drawing colour g2.fillRect( 10, 10, 20, 20 ); // fill in a rectangle of that colour g2.drawRect( 0, 0, getWidth()-1, getHeight()-1 ); // draw a border around everything • More on how this works next lecture and at the tutorials…
  • 15. Graphics 15 What MyProg01 Output Looks Like Black rectangle inside a white area…
  • 16. Graphics 16 Summary • Graphics has a varied history • Very technology driven • Good advances in recent years with adequate memory and processing power • Primitives and library layers approach is very common • Note devices and memory model • Colour models and drawing spaces are important ideas for our programs • We will use the Java Development Kit graphics libraries and primitives