quartz-graphics

How to write a web-based music visualizer?

断了今生、忘了曾经 提交于 2019-11-26 12:29:11
问题 I\'m trying to find the best approach to build a music visualizer to run in a browser over the web. Unity is an option, but I\'ll need to build a custom audio import/analysis plugin to get the end user\'s sound output. Quartz does what I need but only runs on Mac/Safari. WebGL seems not ready. Raphael is mainly 2D, and there\'s still the issue of getting the user\'s sound... any ideas? Has anyone done this before? 回答1: By WebGL being "not ready", I'm assuming that you're referring to the

Get PDF hyperlinks on iOS with Quartz

那年仲夏 提交于 2019-11-26 12:01:38
I've spent all day trying to get hyperlinks metadata from PDFs in my iPad application. The CGPDF* APIs are a true nightmare, and the only piece of information I've found on the net about all this is that I have to look for an "Annots" dictionary, but I just can't find it in my PDFs. I even used the old Voyeur Xcode sample to inspect my test PDF file, but no trace of this "Annots" dictionary... You know, this is a feature I see on every PDF reader - this same question has been asked multiple times here with no real practical answers. I usually never ask for sample code directly but apparently

How to draw a rounded rectangle in Core Graphics / Quartz 2D?

雨燕双飞 提交于 2019-11-26 10:17:52
问题 I need to draw an outline for a rounded rectangle. I know I can make lines and arcs, but maybe there is also a function for rounded rects? 回答1: Instead of making your own path out of lines and arcs, you can use [UIBezierPath bezierPathWithRoundedRect:cornerRadius:] or [UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:] (the second one lets you specify which corners are rounded) Available in iOS 3.2 or later. 回答2: There is no prepackaged way to this, you must combine arcs

Drawing rotated text with NSString drawInRect

巧了我就是萌 提交于 2019-11-26 09:34:09
问题 I found this answer on how to draw rotated text with NSString drawInRect:, but I\'m not sure how it works since it only sort of works for me: https://discussions.apple.com/thread/1779814?start=0&tstart=0 My code looks like: CGContextSaveGState(context); CGContextDrawLinearGradient(context, gradient, CGPointMake(0, centY - halfWidth), CGPointMake(0, centY + halfWidth), 0); // Add text CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); NSString *str = @\"some test string\";

iPhone - Draw transparent rectangle on UIView to reveal view beneath

烂漫一生 提交于 2019-11-26 09:06:35
问题 I currently have two UIViews: one of a red background and the other blue. The blue view is a subview of the red view. What I would like to do is be able to \"cut\" out rectangles on the blue view so that the red view can be visible. How do you go about doing this? 回答1: You have to override the top view's drawRect method. So, for example, you might create a HoleyView class that derives from UIView (you can do that by adding a new file to your project, selecting Objective-C subclass, and

How to create a colored 1x1 UIImage on the iPhone dynamically?

99封情书 提交于 2019-11-26 09:05:42
问题 I would like to create a 1x1 UIImage dynamically based on a UIColor. I suspect this can quickly be done with Quartz2d, and I\'m poring over the documentation trying to get a grasp of the fundamentals. However, it looks like there are a lot of potential pitfalls: not identifying the numbers of bits and bytes per things correctly, not specifying the right flags, not releasing unused data, etc. How can this be safely done with Quartz 2d (or another simpler way)? 回答1: You can use

Curve text on existing circle

社会主义新天地 提交于 2019-11-26 06:14:45
问题 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 characters and draw each character on it\'s own with the right angle in mind (by rotating the context you are drawing on). I just can\'t wrap my head around on how to get the right angles and positions for my characters. I included a screenshot on what

How to convert ASCII character to CGKeyCode?

≡放荡痞女 提交于 2019-11-26 04:41:22
问题 I need a function that, given a character, returns the CGKeyCode associated with the position of that character on the current keyboard layout. E.g., given \"b\", it should return kVK_ANSI_B if using U.S. QWERTY, or kVK_ANSI_N if using Dvorak. The Win32 API has the function VkKeyScan() for this purpose; X11 has the function XStringToKeySym(). Is there such a function in the CG API? I need this in order to pass a parameter to CGEventCreateKeyboardEvent(). I\'ve tried using

Is there a way to make drawRect work right NOW?

不羁岁月 提交于 2019-11-26 04:36:46
问题 The original question............................................... If you are an advanced user of drawRect, you will know that of course drawRect will not actually run until \"all processing is finished.\" setNeedsDisplay flags a view as invalidated and the OS, and basically waits until all processing is done. This can be infuriating in the common situation where you want to have: a view controller 1 starts some function 2 which incrementally 3 creates a more and more complicated artwork

Where can I find a list of Mac virtual key codes?

不打扰是莪最后的温柔 提交于 2019-11-26 04:05:32
问题 I\'m using CGEventCreateKeyboardEvent and need to know what CGKeyCode values to use. Specifically, I am after the key code for the Command key. The docs give examples for other keys: z is 6 , shift is 56 . There must be a list of Mac virtual keycodes somewhere? 回答1: The more canonical reference is in <HIToolbox/Events.h> : /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h In newer Versions of MacOS the "Events.h" moved to here: