Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 3 2D Graphics: Rendering Details
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 2 Objectives F To understand color spaces F To use the Java Color class F To be able to use different types of paints in drawing visual objects F To apply stroke types F To construct affine transforms including translation, rotation, scaling, shearing, and reflection F To understand object transformations and viewing transformations F To combine basic transformations to form more complex ones F To identify the compositing rules F To use clipping path F To apply fonts and font metrics F To understand glyph, ligature, and derived font
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 3 Color Space F CIEXYZ F RGB F CYMK F sRGB Source Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 4 Paint Source Run Generalizing the concept of color, Java 2D drawing applies an attribute called paint
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 5 Strokes F Width F End style F Join style F Miter limit F Dash pattern Source Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 6 Affine Transformation F Maps parallel lines to parallel lines F Common affine transforms –Translation –Rotation –Reflection –Scale –Shear
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 7 Affine Transformation
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 8 Transformation Matrix Source Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 9 Composition of Transforms F Combining transforms F Non-commutative F Matrix product Source Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 10 Alpha Compositing F α-channel F Transparency F Porter-Duff rules
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 11 Porter-Duff Rules F Xor F DstOver F DstIn F DstOut F Dst F DstAtop F Clear F SrcOver F SrcIn F SrcOut F Src F SrcAtop
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 12 A Probabilistic Model F α value as the probability of the color to be shown F Four different events: –source color occurs only –destination color occurs only –both colors occur –neither color occurs. Source Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 13 Clipping Path Source The rendered image may be clipped by a clipping path Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 14 Font F Logical fonts –Serif –SansSerif –Monospaced –Dialog –DialogInput F Font styles –PLAIN –ITALIC –BOLD F Derived font F Font metrics Source Run
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 15 Ligature F A glyph may contain multiple letters F A common ligature:
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 16 Glyph F Geometry of a text string with a font F Obtain a glyph Source Run Font font = new Font("Serif", Font.BOLD, 144); FontRenderContext frc = g2.getFontRenderContext(); GlyphVector gv = font.createGlyphVector(frc, "Java"); Shape glyph = gv.getOutline(100,200);