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 …

A

Subpaths

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
Q

Can a path be stroked/not stroked and filled/not filled independently?

A

Yes

26
Q

Can be path be used to define a clipping area?

A

Yes

27
Q

Can a path consist of subpaths that don’t intersect on another?

A

Yes

28
Q

What is done before stroking or filling a path?

A

The path must be created first.

29
Q

How do you specify the starting point for a new subpath?

A

CGContextMoveToPoint()

30
Q

Regarding point (in a coordinate system), Quartz always keeps track of the …

A

current point.

31
Q

How can you add a series of connected lines to a path?

A

CGContextAddLines()

32
Q

How is an arc added to a path?

A

CGContextAddArc()

33
Q

What is used for curvilinear shapes

A

Quadratic and cubic Bezier functions.

34
Q

What is the advantage of using a formula for a curve?

A

1) It is compact to store, and 2) it can be reproduced at any resolution.

35
Q

A cubic Bezier curve uses two endpoints and …

A

Two control points.

36
Q

A quadratic Bezier curve uses two endpoints and …

A

One control point.

37
Q

How can I always close a subpath?

A

With CGContextClosePath(). This adds a line segment from the current point to the subpath’s starting point.

38
Q

What shapes can easily be added to the current path (as their own subpaths)?

A

Ellipses and rectangles.

39
Q

How to create a path and set its starting point?

A

CGContextBeginPath() and GGContextMoveToPoint()

40
Q

What are some parameters that affect path stroking?

A

line width, line join, line cap

41
Q

How does path filling work with subpaths?

A

When you fill the current path, Quartz acts as if each subpath contained in the path were closed.

42
Q

What are blend modes?

A

Blend modes specify how Quartz applies paint over a background.

43
Q

What is the alpha value?

A

It determines how to composite newly painted objects to the existing page. 1=opaque, 0=invisible.

44
Q

Besides specifying alpha as part of a color, what else can I do?

A

I can set a global alpha value with CGContextSetAlpha().

45
Q

Do the current colors “stick” in the graphic state?

A

Yes

46
Q

Are user-space coordinates related to the pixel-resolution of the device space?

A

No

47
Q

Before transforming the CTM, you should…

A

Save the graphics state so that it can be restored.

48
Q

What is a pattern?

A

A sequence of drawing operations that is repeatedly painted to a graphics context.

49
Q

What is a shadow?

A

An image painted underneath, and offset from, a graphics object.