Questions tagged [quartz-2d]

Quartz 2D is the primary two-dimensional graphics rendering API for Mac OS X, part of the Core Graphics framework.

Quartz 2D is the primary two-dimensional graphics rendering API for Mac OS X, part of the Core Graphics framework.

From apple official document:

Quartz 2D provides low-level, lightweight 2D rendering with unmatched output fidelity regardless of display or printing device. Quartz 2D is resolution- and device-independent; you don’t need to think about the final destination when you use the Quartz 2D application programming interface (API) for drawing.

The Quartz 2D API is easy to use and provides access to powerful features such as transparency layers, path-based drawing, offscreen rendering, advanced color management, anti-aliased rendering, and PDF document creation, display, and parsing.

The Quartz 2D API is part of the Core Graphics framework, so you may see Quartz referred to as Core Graphics or, simply, CG.

Quartz 2D uses the painter’s model for its imaging. In the painter’s model, each successive drawing operation applies a layer of “paint” to an output “canvas,” often called a page.

For more information:

Related tags:

667 questions
132
votes
16 answers

How to map atan2() to degrees 0-360

atan2(y, x) has that discontinuity at 180° where it switches to -180°..0° going clockwise. How do I map the range of values to 0°..360°? here is my code: CGSize deltaPoint = CGSizeMake(endPoint.x - startPoint.x, endPoint.y - startPoint.y); float…
willc2
  • 38,991
  • 25
  • 88
  • 99
78
votes
3 answers

What's the difference between Quartz Core, Core Graphics and Quartz 2D?

I wonder if someone can distinguish precisely between these? For my understanding, Core Graphics is just a "Framework Package" which contains Quartz Core and Quartz 2D. But I'm not sure about if Quartz 2D actually is Quartz Core? Maybe someone can…
openfrog
  • 40,201
  • 65
  • 225
  • 373
55
votes
12 answers

Curve text on existing circle

For an application I am building I have drawn 2 circles. One a bit bigger than the other. I want to curve text between those lines, for a circular menu I am building. I read most stuff about curving a text that you have to split up your text in…
Wim Haanstra
  • 5,918
  • 5
  • 41
  • 57
54
votes
6 answers

Contex Drawing + Pagination

I am trying to draw contents of scrollview into a PDF context & I am facing problem with pagination. Following Code I have used: - (void)renderTheView:(UIView *)view inPDFContext:(CGContextRef)pdfContext { // Creating frame. CGFloat…
Sam
  • 902
  • 8
  • 16
42
votes
4 answers

How can I draw an arrow using Core Graphics?

I need to draw line with arrow on its end in my Draw app. I'm not good in trigonometry, so can't solve this problem. The user put his finger on the screen and draw the line in any direction. So, the arrow should appear on the line end.
Sasha Prent
  • 1,151
  • 2
  • 10
  • 11
38
votes
6 answers

Most efficient way to draw part of an image in iOS

Given an UIImage and a CGRect, what is the most efficient way (in memory and time) to draw the part of the image corresponding to the CGRect (without scaling)? For reference, this is how I currently do it: - (void)drawRect:(CGRect)rect { …
hpique
  • 119,096
  • 131
  • 338
  • 476
36
votes
9 answers

UIView with a Dashed line

What I have: To create this line, I basically have an UIView and I do the following: void setLayerToLineFromAToB(CALayer *layer, CGPoint a, CGPoint b, CGFloat lineWidth) { CGPoint center = { 0.5 * (a.x + b.x), 0.5 * (a.y + b.y) }; CGFloat…
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
34
votes
3 answers

Core Graphics Performance on iOS

Summary I'm working on a fairly straightforward 2D tower defense game for iOS. So far, I've been using Core Graphics exclusively to handle rendering. There are no image files in the app at all (yet). I've been experiencing some significant…
smileyborg
  • 30,197
  • 11
  • 60
  • 73
27
votes
2 answers

How to use CGAffineTransformMakeRotation?

I want to draw text use Quartz 2D. The "menu" direction is wrong. I want "Menu" still readable and have 45 degree with X-axis. Below is my code: CGContextSelectFont(context, "Arial", 12, kCGEncodingMacRoman); CGContextSetTextDrawingMode(context,…
user503853
24
votes
1 answer

iPhone, CGPDFDocument - PDF links

I'm trying to write a simple PDF viewer using CGPDFDocument, based on QuartzDemo. There is common rendering: -(void)drawInContext:(CGContextRef)context { // PDF page drawing expects a Lower-Left coordinate system, // so we flip the…
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
20
votes
2 answers

Efficient method to draw a line with millions of points

I'm writing an audio waveform editor in Cocoa with a wide range of zoom options. At its widest, it shows a waveform for an entire song (~10 million samples in view). At its narrowest, it shows a pixel accurate representation of the sound wave (~1…
tassock
  • 1,633
  • 1
  • 17
  • 32
19
votes
4 answers

How to use a UIImage as a mask over a color in Objective-C

I have a UIImage that is all black with an alpha channel so some parts are grayish and some parts are completely see-through. I want to use that images as a mask over some other color (let's say white to make it easy), so the final product is now a…
Philip Walton
  • 29,693
  • 16
  • 60
  • 84
18
votes
3 answers

Rotate CGImage taken from video frame

This is Apple's code (from Technical Q&A QA1702) for getting a UIImage from a video buffer. Unfortunately, the image returned is rotated 90 degrees. How do I edit this so that the image returned is correctly oriented? - (UIImage *)…
Drew C
  • 6,408
  • 3
  • 39
  • 50
17
votes
2 answers

Draw glow around inside edge of multiple CGPaths

If I create a CGMutablePathRef by adding together two circular paths as shown by the left image, is it possible to obtain a final CGPathRef which represents only the outer border as shown by the right image? Thanks for any help!
dmarnel
  • 4,436
  • 1
  • 15
  • 11
17
votes
2 answers

How do I change a partially transparent image's color in iOS?

I have a single-color image that has partial transparency. I have both normal and @2X versions of the image. I would like to be able to tint the image a different color, in code. The code below works fine for the normal image, but the @2X ends up…
Brandon DuRette
  • 4,810
  • 5
  • 25
  • 31
1
2 3
44 45