Quartz 2D Programming Guide - Apple (2009).pdf

(27278 KB) Pobierz
Quartz 2D Programming Guide
Quartz2DProgrammingGuide
Graphics&Animation:2DDrawing
2010-11-19
727162270.002.png
AppleInc.
©2001,2010AppleInc.
Allrightsreserved.
EventhoughApplehasreviewedthisdocument,
APPLEMAKESNOWARRANTYORREPRESENTATION,
EITHEREXPRESSORIMPLIED,WITHRESPECTTO
THISDOCUMENT,ITSQUALITY,ACCURACY,
MERCHANTABILITY,ORFITNESSFORAPARTICULAR
PURPOSE.ASARESULT,THISDOCUMENTIS
PROVIDED“ASIS,”ANDYOU,THEREADER,ARE
ASSUMINGTHEENTIRERISKASTOITSQUALITY
ANDACCURACY.
INNOEVENTWILLAPPLEBELIABLEFORDIRECT,
INDIRECT,SPECIAL,INCIDENTAL,OR
CONSEQUENTIALDAMAGESRESULTINGFROMANY
DEFECTORINACCURACYINTHISDOCUMENT,even
ifadvisedofthepossibilityofsuchdamages.
THEWARRANTYANDREMEDIESSETFORTHABOVE
AREEXCLUSIVEANDINLIEUOFALLOTHERS,ORAL
ORWRITTEN,EXPRESSORIMPLIED.NoApple
dealer,agent,oremployeeisauthorizedtomake
anymodification,extension,oradditiontothis
warranty.
Somestatesdonotallowtheexclusionorlimitation
ofimpliedwarrantiesorliabilityforincidentalor
consequentialdamages,sotheabovelimitationor
exclusionmaynotapplytoyou.Thiswarrantygives
youspecificlegalrights,andyoumayalsohave
otherrightswhichvaryfromstatetostate.
Nopartofthispublicationmaybereproduced,
storedinaretrievalsystem,ortransmitted,in
anyformorbyanymeans,mechanical,
electronic,photocopying,recording,or
otherwise,withoutpriorwrittenpermissionof
AppleInc.,withthefollowingexceptions:Any
personisherebyauthorizedtostore
documentationonasinglecomputerfor
personaluseonlyandtoprintcopiesof
documentationforpersonaluseprovidedthat
thedocumentationcontainsApple’scopyright
notice.
TheApplelogoisatrademarkofAppleInc.
Nolicenses,expressorimplied,aregranted
withrespecttoanyofthetechnologydescribed
inthisdocument.Appleretainsallintellectual
propertyrightsassociatedwiththetechnology
describedinthisdocument.Thisdocumentis
intendedtoassistapplicationdevelopersto
developapplicationsonlyforApple-labeled
computers.
AppleInc.
1InfiniteLoop
Cupertino,CA95014
408-996-1010
Apple,theApplelogo,Cocoa,ColorSync,eMac,
Mac,MacOS,Objective-C,Pages,Quartz,
QuickTime,Spaces,Tiger,andXcodeare
trademarksofAppleInc.,registeredinthe
UnitedStatesandothercountries.
Adobe,Acrobat,andPostScriptaretrademarks
orregisteredtrademarksofAdobeSystems
IncorporatedintheU.S.and/orothercountries.
Adobe,Acrobat,andPostScriptaretrademarks
orregisteredtrademarksofAdobeSystems
IncorporatedintheU.S.and/orothercountries.
Adobe,Acrobat,andPostScriptaretrademarks
orregisteredtrademarksofAdobeSystems
IncorporatedintheU.S.and/orothercountries.
Helveticaisaregisteredtrademarkof
HeidelbergerDruckmaschinenAG,available
fromLinotypeLibraryGmbH.
IOSisatrademarkorregisteredtrademarkof
CiscointheU.S.andothercountriesandisused
underlicense.
OpenGLisaregisteredtrademarkofSilicon
Graphics,Inc.
727162270.003.png
Contents
Introduction Introduction 15
WhoShouldReadThisDocument? 15
OrganizationofThisDocument 15
SeeAlso 16
Chapter1 OverviewofQuartz2D 19
ThePage 19
DrawingDestinations:TheGraphicsContext 20
Quartz2DOpaqueDataTypes 22
GraphicsStates 23
Quartz2DCoordinateSystems 24
MemoryManagement:ObjectOwnership 26
Chapter2 GraphicsContexts 29
DrawingtoaViewGraphicsContextiniOS 29
CreatingaWindowGraphicsContextinMacOSX 29
CreatingaPDFGraphicsContext 31
CreatingaBitmapGraphicsContext 35
SupportedPixelFormats 39
Anti-Aliasing 40
ObtainingaGraphicsContextforPrinting 41
Chapter3 Paths 43
PathCreationandPathPainting 43
TheBuildingBlocks 44
Points 45
Lines 45
Arcs 45
Curves 47
ClosingaSubpath 48
Ellipses 49
Rectangles 49
CreatingaPath 50
PaintingaPath 51
ParametersThatAffectStroking 51
FunctionsforStrokingaPath 54
FillingaPath 54
SettingBlendModes 55
2010-11-19 | © 2001, 2010 Apple Inc. All Rights Reserved.
3
727162270.004.png
CONTENTS
ClippingtoaPath 64
Chapter4 ColorandColorSpaces 67
AboutColorandColorSpaces 67
TheAlphaValue 68
CreatingColorSpaces 69
CreatingDevice-IndependentColorSpaces 70
CreatingGenericColorSpaces 70
CreatingDeviceColorSpaces 71
CreatingIndexedandPatternColorSpaces 71
SettingandCreatingColors 71
SettingRenderingIntent 73
Chapter5 Transforms 75
AboutQuartzTransformationFunctions 75
ModifyingtheCurrentTransformationMatrix 76
CreatingAffineTransforms 80
EvaluatingAffineTransforms 81
GettingtheUsertoDeviceSpaceTransform 82
TheMathBehindtheMatrices 82
Chapter6 Patterns 85
TheAnatomyofaPattern 85
ColoredPatternsandStencil(Uncolored)Patterns 88
Tiling 89
HowPatternsWork 89
PaintingColoredPatterns 90
WriteaCallbackFunctionThatDrawsaColoredPatternCell 90
SetUptheColoredPatternColorSpace 91
SetUptheAnatomyoftheColoredPattern 92
SpecifytheColoredPatternasaFillorStrokePattern 93
DrawWiththeColoredPattern 93
ACompleteColoredPatternPaintingFunction 93
PaintingStencilPatterns 95
WriteaCallbackFunctionThatDrawsaStencilPatternCell 95
SetUptheStencilPatternColorSpace 96
SetUptheAnatomyoftheStencilPattern 97
SpecifytheStencilPatternasaFillorStrokePattern 97
DrawingwiththeStencilPattern 98
ACompleteStencilPatternPaintingFunction 98
4
2010-11-19 | © 2001, 2010 Apple Inc. All Rights Reserved.
727162270.005.png
CONTENTS
Chapter7 Shadows 101
HowShadowsWork 102
ShadowDrawingConventionsVaryBasedontheContext 102
PaintingwithShadows 102
Chapter8 Gradients 105
AxialandRadialGradientExamples 105
AComparisonofCGShadingandCGGradientObjects 108
ExtendingColorBeyondtheEndofaGradient 109
UsingaCGGradientObject 110
UsingaCGShadingObject 113
PaintinganAxialGradientUsingaCGShadingObject 114
PaintingaRadialGradientUsingaCGShadingObject 120
SeeAlso 124
Chapter9 TransparencyLayers 125
HowTransparencyLayersWork 126
PaintingtoaTransparencyLayer 126
Chapter10 DataManagementinQuartz2D 129
MovingDataintoQuartz2D 130
MovingDataoutofQuartz2D 131
MovingDataBetweenQuartz2DandCoreImageinMacOSX 132
Chapter11 BitmapImagesandImageMasks 135
AboutBitmapImagesandImageMasks 135
BitmapImageInformation 136
DecodeArray 137
PixelFormat 137
ColorSpacesandBitmapLayout 137
CreatingImages 139
CreatinganImageFromPartofaLargerImage 140
CreatinganImagefromaBitmapGraphicsContext 142
CreatinganImageMask 142
MaskingImages 143
MaskinganImagewithanImageMask 143
MaskinganImagewithanImage 145
MaskinganImagewithColor 146
MaskinganImagebyClippingtheContext 149
UsingBlendModeswithImages 151
NormalBlendMode 152
2010-11-19 | © 2001, 2010 Apple Inc. All Rights Reserved.
5
727162270.001.png
Zgłoś jeśli naruszono regulamin