Core Graphics Flashcards

1
Q

What is a graphics context (CGContextRef)?

A

An opaque data type that Quartz uses to draw images to screen, bitmap, PDF file, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How ubiquitous is CGContextRef?

A

All objects in Quartz are drawn to, or contained by, a graphics context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Think of a graphics context (CGContextRef) as a …..?

A

Drawing destination.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is CGLayerRef?

A

An offscreen drawing destination associated with another graphics context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What prefix is used for functions in the Core Graphics API?

A

CG for Core Graphics.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is used for offscreen drawing?

A

CGLayerRef

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the graphics state?

A

The graphics state contains parameters that would otherwise be taken as arguments to drawing routines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can graphics states be saved?

A

Yes. There is actually a stack of them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

My code specifies locations and sizes in which coordinate system

A

User-space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How is user space mapped to device space?

A

With a content transformation matrix, or CTM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The content transformation matrix is what kind of matrix?

A

An Affine transform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is UIKit’s coordinate system different from Quartz’s?

A

In Quartz, the y-axis goes up, whereas in UIKit it grows down.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How is memory management done in Core Graphics?

A

With reference counting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

When do I own a reference to an object?

A

If I got it from a function with name beginning with Copy or Create.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do I draw to the screen in an iOS application

A

With [UIView drawRect:]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In [UIView drawRect:] how do I get a graphics context?

A

By calling UIGraphicsGetCurrentContext()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In [UIView drawRect:] how are coordinate systems handled?

A

The UView modified the coordinate transformation matrix so as to flip the y-axis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is anti-aliasing?

A

Artificially correcting jagged edges in text glyphs and bitmaps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Can anti-aliasing be turned on and off?

A

Yes, with CGContextSetShouldAntialias().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

A path consists of one or more …

21
Q

A subpath consists of:

A

straight lines, curves, or both.

22
Q

Is a path open or closed?

A

It can be either.

23
Q

What is stroking a path?

A

Actually drawing its line.

24
Q

What is filling a path?

A

Filling the interior of a closed path.

25
Can a path be stroked/not stroked and filled/not filled independently?
Yes
26
Can be path be used to define a clipping area?
Yes
27
Can a path consist of subpaths that don't intersect on another?
Yes
28
What is done before stroking or filling a path?
The path must be created first.
29
How do you specify the starting point for a new subpath?
CGContextMoveToPoint()
30
Regarding point (in a coordinate system), Quartz always keeps track of the ...
current point.
31
How can you add a series of connected lines to a path?
CGContextAddLines()
32
How is an arc added to a path?
CGContextAddArc()
33
What is used for curvilinear shapes
Quadratic and cubic Bezier functions.
34
What is the advantage of using a formula for a curve?
1) It is compact to store, and 2) it can be reproduced at any resolution.
35
A cubic Bezier curve uses two endpoints and ...
Two control points.
36
A quadratic Bezier curve uses two endpoints and ...
One control point.
37
How can I always close a subpath?
With CGContextClosePath(). This adds a line segment from the current point to the subpath's starting point.
38
What shapes can easily be added to the current path (as their own subpaths)?
Ellipses and rectangles.
39
How to create a path and set its starting point?
CGContextBeginPath() and GGContextMoveToPoint()
40
What are some parameters that affect path stroking?
line width, line join, line cap
41
How does path filling work with subpaths?
When you fill the current path, Quartz acts as if each subpath contained in the path were closed.
42
What are blend modes?
Blend modes specify how Quartz applies paint over a background.
43
What is the alpha value?
It determines how to composite newly painted objects to the existing page. 1=opaque, 0=invisible.
44
Besides specifying alpha as part of a color, what else can I do?
I can set a global alpha value with CGContextSetAlpha().
45
Do the current colors "stick" in the graphic state?
Yes
46
Are user-space coordinates related to the pixel-resolution of the device space?
No
47
Before transforming the CTM, you should...
Save the graphics state so that it can be restored.
48
What is a pattern?
A sequence of drawing operations that is repeatedly painted to a graphics context.
49
What is a shadow?
An image painted underneath, and offset from, a graphics object.