Graphics Vector graphics 2D only. Overview of common functions and parameters.. Drawing in Matlab. We will see how a common file format stores the information.

Slides:



Advertisements
Similar presentations
Chapter 14 Graph class design Bjarne Stroustrup
Advertisements

Word Lesson 6 Working with Graphics
Step-by-Step: Adjust a Chart Axis USE the Pricing Final presentation that is still open from the previous exercise. 1.Click the chart on slide 2 to select.
Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Chapter 3 Drawing and Composing an Illustration. Objectives Draw straight lines Draw curved lines Draw elements of an illustration Apply attributes to.
INTRODUCTION TO ADOBE ILLUSTRATOR VECTOR MONSTERS Created by CHRIS SPOONER.
Chapter 12 Using Clipping Masks, Paths, & Shapes.
Chapter 7 Creating Graphics. Chapter Objectives Use the Pen tool Reshape frames and apply stroke effects Work with polygons and compound paths Work with.
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Graphics CS 121 Concepts of Computing II. What is a graphic? n A rectangular image. n Stored in a file of its own, or … … embedded in another data file.
Working with Vector Graphics – Lesson 21 Working with Vector Graphics Lesson 2.
Adobe Photoshop CS Design Professional PATHS, & SHAPES USING CLIPPING MASKS,
Higher-level PHP constructs for manipulating image files.
SWE 423: Multimedia Systems Chapter 4: Graphics and Images.
Text, Masks, and Live Effects – Lesson 41 Text, Masks, and Live Effects Lesson 4.
Introduction to Computer Graphics
Vector vs. Bitmap SciVis V
V Obtained from a summer workshop in Guildford County July, 2014
Graphics Standard Grade Computing. Graphics Package n A graphics package is another General Purpose Package. n It is used to draw pictures on the monitor.
Vector Graphics Making custom images. Raster vs. Vector Graphics In computer graphics, a raster graphics image, or bitmap, is a dot matrix data structure.
CSC/FAR 020, Computer Graphics, October 27, 2014 Dr. Dale E. Parson Outline for Week 9 Vectors and Paths, also File.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
Lecture 4 - Introduction to Computer Graphics
Vector vs. Bitmap
Bitmap Vs. Vector Graphics. To create effective artwork, you need to understand some basic concepts about vector graphics versus bitmap images, resolution,
Graphics A graphics program allows you to combine pictures and text in many different ways. Features – General Level Draw graphics Enter Text Common Tools.
Working with Symbols and Interactivity
Lecture 3 Drawing Basic Shapes Professor: Dr. Miguel Alonso Jr.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
© 2011 Delmar, Cengage Learning Chapter 1 Getting to Know Illustrator.
Introduction to Matlab’s Graphical User Interface (GUI) Type “guide” “Guide” creates interface on a Figure window and code in an M-file. Some hidden code.
Laboratory Exercise # 9 – Inserting Graphics to Documents Office Productivity Tools 1 Laboratory Exercise # 9 Inserting Graphics to Documents Objectives:
Lecture 16 Image Document Formats. Bitmap vs. Vector Images Bitmaps do not generally.
Outline Announcements –Homework I due Wed. 5PM by Subject: CIS 402 Homework 1 Plain text Not allowed to use errorbar Try to do plotCI without looking.
Chapter 4 Working with Frames. Align and distribute objects on a page Stack and layer objects Work with graphics frames Work with text frames Chapter.
Illustrator I I450 Technology Seminar. Bitmap vs. Vector Photoshop = Bitmap Illustrator = Vector Bitmap images are resolution dependent Vector images.
Tkinter Canvas.
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
Figures & Axes, Printing & Saving. Outline Announcements –Homework I due Wed. 5PM by –No lecture on Fri. 10/26, rescheduled to Wed. 10/31 at 8AM.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
CIS 205—Web Design & Development Fireworks Chapter 2.
© 2011 Delmar, Cengage Learning Chapter 4 Working with Frames.
CISC 110 Day 3 Introduction to Computer Graphics.
Introduction to Images & Graphics JMA260. Objectives Images introduction Photoshop.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
Computer Graphics Matrices
© 2011 Delmar, Cengage Learning Chapter 12 Using Clipping Masks, Paths, & Shapes.
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Object Oriented Programming Lecture 3: Things OO.
Guilford County SciVis V104.03
Computer Graphics CC416 Lecture 02: Overview of Graphics Systems: Raster & Random Displays – Chapter 2 Dr. Manal Helal – Fall 2014.
Computer – Aided Design Terminology You must have a generic understanding of commands and techniques which are used in a number of packages (YOU CANNOT.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
Main characteristics of Vector graphics  Vector graphics provide an elegant way of constructing digital images (diagrams, technical illustration and.
Vector vs. Bitmap. Vector Images Vector images (also called outline images) are images made with lines, text, and shapes. Test type is considered to be.
Drawing Geometric Objects
Vector vs. Bitmap.
CSI-447: Multimedia Systems
Adobe Illustrator CS5 - Illustrator
Flash Interface, Commands and Functions
Dr. Jim Rowan ITEC 2110 Wednesday, September 12
IMAGES.
Bitmap vs. Vector.
Learning Intention I will learn how a computer stores graphics.
Word Lesson 6 Working with Graphics
Exercise 28 - Skills Vector tools enable you to create perfectly formed shapes and lines of all sorts. What’s more the vector objects keep their shape.
Digital Media Dr. Jim Rowan ITEC 2110.
Presentation transcript:

Graphics Vector graphics 2D only. Overview of common functions and parameters.. Drawing in Matlab. We will see how a common file format stores the information. Looking at similar functions in PDF.

Graphics Source of confusion. Vectors vs Bitmaps. Here we are concerned with vector graphics.

Vector Graphics Is to pictures what MIDI is to sound. Uses lines, predefined shapes, curves and (predefined text). Can be very compact. Good for plotters. Converted to bitmap for monitor display.

Co-ordinate systems Vector graphics based upon an x, y co-ordinate system. The x co-ordinate runs from left to right across the screen. The y co-ordinate usually runs from the bottom (= 0) of the image to the top, but sometimes from top (= 0) to the bottom.

Co-ordinate systems To set up co-ordinate system in Matlab. haxes=axes –Sets up a co-ordinate system starting at 0 on the x- and y-axes and extending to 1.0 on the x-axis and 1.0 on the y-axis. You may now draw on this system. You can change the axis scaling using the “axis” command. But by default the scaling will increase to accommodate your objects.

Lines in Matlab Function line used to draw lines h = line(x, y) where x and y are x and y co-ordinates of the start and end of a line. H is a “handle” to the graphics object (used for setting properties. Example –x=[20 50] –y=[30 80] –hline = line(x,y) Draws a line from point x=20, y=30 to the point x=50, y=80

Rectangles in Matlab Function “rectangle” used to draw rectangles in Matlab. Often (in other packages and ‘C’ routines) rectangles are defined by 2 points only –Bottom left and top right. In Matlab –hrect = rectangle('Position', [ ]) – (start position (x,y) then width and height.) Also used to draw ellipses and circles –hcirc = rectangle('Position', [ ], 'Curvature', [1 1]). –A circle is an ellipse with the same (height as its width)

Polygons in Matlab h = patch(x, y, ‘c’) draws a polygon, the vertices of which are contained in x and y, and is filled by colour ‘c’. Example draw a red filled pentagon. –Need 5 points in x and y. –x=[ ] –y=[ ] –hpoly = patch(x, y, ‘r’)

Exercises Draw a line from point x=20, y=30 to the point x=50, y=60. Draw a rectangle with the bottom left hand corner at point x=30, y=50 and the top right hand corner at point x=70, y=80. Draw a circle of radius 3 and centred at point x=50, y=60. Draw a blue filled triangle.

Handles The main figure has a “handle” in the Matlab environment. Handles allow Matlab to keep track of figures and graphic objects. Within the main figure we have an axis object; this also also has a handle. It is a “child” object of the figure.

Handles We differentiate between or identify objects by their handles Sort of pointer. When we add drawing objects such as our lines, rectangles, patches, they become child objects of the axis object and are also identified by handles. So we now have an axes with four children. We can return there values using Hchild=get(haxes, ‘Children’)

Handles So our structure so far could be drawn as. Hfigure is the handle to the figure and has child object with handle haxes haxes has 4 children with handles hline, hrect, hcirc, and hpoly

Handles Or in hierarchical form Figure ‘children’ Axes linerectpatchrect Represents handles hfigure

Handles The handle of the figure is returned in variable “hfigure”. It gives us access to all the properties of the figure. get(h) returns a copy of the figure’s (object’s) properties including its children.

Handles, Try it Type “maindetails=get(hfigure)” maindetails lists all the properties in the figure. The structure includes handles to the child objects. We can use the handles to gain access to the child objects and alter their properties.

Properties, get() and set() We can retrieve a copy of the values associated with a graphic object through its handle by using S=get(hrect) The structure contains all the properties of the graphic object. However, since it is a copy we cannot change the actual information associated with the graphic object.

Properties, get() and set() So in true “OO’” style we must use an access method/function to adjust parameters.. Set(h,'PropertyName',Propert yValue) Get(h) or Get(h, ‘PropertyName’) returns the property. Note ‘quotes’

Order of objects As an drawing object is added to the axes object an entry (drawing object’s handle) is placed in the “children” array of the axis object. We can rearrange this array to change which object is on top. Again we are simply swapping handles We need to call “refresh” to see it.

Order of objects So we get the axes objects “children” array. hchild=get(haxes, ‘children’) Make a copy –htemp=hchild Rearrange the handles to the objects –htemp(4)=hchild(1) –htemp(1)=hchild(4) And set the axes “children: array to our new values set(haxes,’children’, htemp)

Deleting objects. We can delete an object using its handle. delete(hpoly) Better put it back! hpoly = patch(x, y, ‘r’)

Stroke, Fill and Colour All vector graphic shapes have stroke and fill “properties”. They affect how the graphic is drawn. Stroke is how lines (and outlines are drawn) fill is how shapes are filled in. One property is “colour” (‘color’ in Matlab. Some other properties for stroke are: –Width ‘LineWidth’ –style (dotted dashed etc.) ‘LineStyle’

Stroke, Fill and Colour To alter the fill and edge colour of a shape in Matlab: –set(hrect, 'FaceColor', [1 0 0]) for fill colour –set(hrect, 'EdgeColor', [ ]) for stroke colour. –Where hr is a handle to the shape. Line width and style may also be applied to the shape’s outline.

Transparency and “alpha” channels. Another property of vector graphics is the ability to add transparency. Many packages allow the adjustment of transparency from 0% to 100%. An “alpha channel” (in addition to the colour channels id s provided with the objects for this purpose.

Transparency and “alpha” channels. We can access the alpha channel of our shapes by the alpha property of the “patch” drawing object in Matlab. Face and edge (fill and stroke) have separate alpha channels. It has values between 0 and 1. Defaults to 1 set(hpoly, ‘FaceAlpha’, 0.5)

Text Text may be added to vector graphics. htext=text(50,100, ‘Dogs and cats’) Properties “font” and “colour” (at least) may be changed.

Exercises Draw the rectangle as above but change the outline to red and fill the rectangle with cyan.

Curves Described mathematically. Polynomial equations. Degree of equations is the highest power of x. Linear y = ax + b –degree 1 Quadratic. y = ax 2 + bx + c. –degree 2 Cubic. y = ax 3 + bx 2 + cx + d –degree 3

Exercises Linear degree 1 e.g. y = 2x + 5. x = [-10 :10]; plot(x, 2*x + 5) Quadratic degree 2 e.g. y = x 2 + 0x + 5. x = [-10 : 10]; plot(x, (x.^2) + 5) Cubic degree 3 e.g. y = 2x x 2 + 3x +2. x = [-10 : 10]; plot(x, 2*(x.^3) + 20*(x.^2) + 3*x + 2)

Bezier curves P(t) = P 0 (1-t) 3 + P 1 3t(1-t) 2 + P 2 3t 2 (1-t) + P 3 t 3 As t takes values between 0 and 1. P’s are x, y points Really two equations. x(t) = x 0 (1-t) 3 + x 1 3t(1-t) 2 + x 2 3t 2 (1-t) + x 3 t 3. y(t) = y 0 (1-t) 3 + y 1 3t(1-t) 2 + y 2 3t 2 (1-t) + y 3 t 3

Bezier curves Consider t=0 then (1-t) = 1 –P(0) = (x 0, y 0 ) = P 0 so curve goes through first point. Consider t=1 then (1-t) = 0 –P(1) = (x 3, y 3 ) = P 3 so curve goes through last point. In between curve is pulled towards P 1 and P 2.,

Exercises Try Matlab function mybezier.m Examine the function. Set up four points P0, P1, P2, P3. –e.g. P0 = [2, 3] Run the function. Experiment with different points.

Other mathematical curves B-splines NURBS

Storage of Vector Graphics. Many formats –Autocad DXF. –Photoshop PSD. –Paintshop Pro PSP. We will consider PDF’s implementation because it may be viewed easily.

PDF format Portable Document Format Developed by Adobe. Developed from PostScript (and EPS (Encapsulated PostScript)). PostScript describes pages as vector graphics.

Graphics in PDF Similar operations to Matlab (and other). PDF allows many complex graphics operations. Lines Rectangles Curves No direct method for circles. We will look at a small selection to see that the PDF file can store vector graphics.

PDF graphic instructions. All PDF graphic instructions use postfix notation where parameters are followed by the graphics operation instruction. Fill and stroke parameters are set before the object is drawn. To see a created object we must “fill” and “stroke” it.

PDF graphic instructions. After adding to the PDF file we should really adjust the “Length” parameter of the stream and the “startxref” pointer at the end of the file. (see example file test.pdf) When counting additions a new line (in Windows/Dos) counts as 2 characters. However, Acrobat seems quite tolerant of errors in these fields. (Ghostscript is not)

Lines in PDF We must firstly move to the start of the path. (see test.pdf) – m Then we draw a line from this point to the end of line. – l To see the line we must draw the stroke –S Try your own using note pad saving the file by some different name.

Rectangles in PDF We set up the start point (x, y), then specify the width and height of the rectangle. Then use the re operator to create the rectangle. – re We must then draw the stroke and fill the rectangle. “B” does this in one operation. –B

Rectangles in PDF We set up the start point (x, y), then specify the width and height of the rectangle. Then use the re operator to create the rectangle. – re Creates a rectangle starting at point x=200 y=300 width=50, height = 75. We must then draw the stroke and fill the rectangle. “B” does this in one operation. –B

Bezier curve in PDF Set starting point (x, y) for curve using m operator – m Add the two “control points” (x, y pairs) and the end point and create the curve using the c operator: – c Draw and fill the curve. –The example also closes (joins the ends together) using the b operator (which also draws the stroke and fills the closed shape) –b

Stroke and fill in PDF Note that fill and stroke colours are set up before the affected object is drawn. In PDF terms we set the “graphics state”. Some “graphics state” commands: –Set line width Number w. –Set line style [ a b ] 0 d ( [ ] is solid line) –Set stroke colour R G B RG –Set fill colour R G B rg

Graphic manipulations Explained in detail in separate lecture. Translation, scaling, rotation. May be applied to vector or bitmap images. Less artefacts with vectors. This is set up as a “graphics state” in PDF using the cm operator.

Scaling Making objects larger or smaller In PDF we change the “current transformation matrix” of the “graphics state” using the cm operator. For scaling: – s x 0 0 s y 0 0 cm

Translation Moving objects left/right and up/down In PDF we change the “current transformation matrix” of the “graphics state” using the cm operator. For translation: – t x t y cm

Rotation Making objects larger or smaller In PDF we change the “current transformation matrix” of the “graphics state” using the cm operator. For rotation: – cos  sin  -sin  cos  0 0 cm –Eg – cm rotates the current co-ordinates by 45 o

Further information Hill, Computer Graphics. Prentice Hall. Adobe specifications available from –Postscript –PDF