quartz-graphics

Text becomes invisible when stroke is added

人走茶凉 提交于 2019-12-11 10:56:19
问题 I have next issue (sample code below): I'm use CATextLayer and NSAttributedString to displaying stylized text. All work fine until I had added stroke to attributes. When I add stroke - text becomes invisible and in display I can see only stroke. Please, I can't understand what happens, why I can't use both text and stroke? Thanks. UIFont* font = [UIFont fontWithName: size:]; UIColor* strokeColor = [UIColor colorWithRed: green: blue: alpha:1.f]; UIColor* foregroundColor = [UIColor colorWithRed

Correct GraphicsContext When Using UIGraphicsGetImageFromCurrentImageContext

狂风中的少年 提交于 2019-12-11 08:53:32
问题 I have the following method where I'm trying to do some drawing into an image: - (UIImage*) renderImage { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0); CGContextRef context = UIGraphicsGetCurrentContext(); //drawing code UIImage *image = [UIGraphicsGetImageFromCurrentImageContext() retain]; UIGraphicsEndImageContext(); return [image autorelease]; } When I run this code I noticed that I'm getting hit much harder than I did when I was simply drawing this code in drawRect of a UIView

Fast, 2 Dimensional Table View

久未见 提交于 2019-12-11 07:05:14
问题 I'm implementing a view for displaying tabular information with 2 axis, but I'm starting to run into performance issues with rendering all the cells. The view looks something like this: +------------+-------------+------------+------------+------------+ | | 12.00am | 1.00am | 2.00am | 3.00am | +------------+---------+---+---+--------+--------+---+-+---+------+ | Category 1 | x | x | x | x | x | | +------------+---------+-------+-----+-----------+-----+---+------+ | Category 2 | | x | x | +---

How to find a third point using two other points and their angle

≡放荡痞女 提交于 2019-12-11 06:25:46
问题 I found an answer here, but can't understand how to transfer the math to Objective C Find the third point I have two points and I also have the angle relative to the axes. How do I find a third point which will form a straight line? The distance should be variable. 回答1: This is the code that I am using: float distanceFromPx2toP3 = 1300.0; float mag = sqrt(pow((px2.x - px1.x),2) + pow((px2.y - px1.y),2)); float P3x = px2.x + distanceFromPx2toP3 * (px2.x - px1.x) / mag; float P3y = px2.y +

CGDisplayModeGetWidth/Height() sometimes returns pixels, sometimes points

╄→гoц情女王★ 提交于 2019-12-11 06:22:32
问题 According to Apple, both CGDisplayModeGetWidth() and CGDisplayModeGetHeight() should return points instead of pixels starting in macOS 10.8. But Apple's word on those APIs isn't consistent because here they say that the functions return pixels and not points. This confusion is also reflected in practice because both functions only seem to return points sometimes, not all the time. Sometimes they also return pixels. Consider this example: CGDirectDisplayID id = CGMainDisplayID(); CFArrayRef

Ownership regarding to returned Quartz objects

浪尽此生 提交于 2019-12-11 06:12:43
问题 I have recently asked about autoreleasing a returned quartz object: Autorelease for CGMutablePathRef? Dave DeLong answered my question that there is no autorelease for quartz (or any NS foundation objects) and I should use the Create Rule. However the naming convention on the document says, The Core Foundation naming conventions, in particular use of the word “create”, only apply to C functions that return Core Foundation objects. Naming conventions for Objective-C methods are governed by the

Is anything required to get a Quartz callback besides registering for it?

筅森魡賤 提交于 2019-12-11 04:18:17
问题 I'm trying to use CGDisplayRegisterReconfigurationCallback to get display reconfiguration events in Quartz on Mac OS X. Here's the super-simple code: void CB(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) { std::cout << "In callback!" << std::endl; } int main (int argc, char * const argv[]) { std::cout << CGDisplayRegisterReconfigurationCallback(CB, NULL) << std::endl; std::cout << "Registered callback, sleeping..." << std::endl; sleep(10000000); return 0; }

How does drawRect and CGGraphicsContext work?

三世轮回 提交于 2019-12-11 02:46:42
问题 I am working with some stuff in Core Graphic's and I am looking for some additional clarification regarding a couple of topics. drawRect: I have an understanding of this and know it is where all of the drawing aspect's of a UIView goes, but am just unclear as to what is happening behind the scene's. What happen's when I create a UIView and fill out drawRect then set another object's UIView to be that custom view? When is drawRect being called? CGGraphicsContext: I know what the purpose of

Gradient color effect on CAShapeLayer

眉间皱痕 提交于 2019-12-10 21:06:46
问题 I'm trying to apply gradient colors on CAShapeLayer. For that i write code, -(void)addCircle{ { // Drawing code UIBezierPath *aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:125 startAngle:0 endAngle:DEGREES_TO_RADIANS(180) clockwise:NO]; CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init]; [shapeLayer setFrame: self.frame]; [shapeLayer setPath: [aPath CGPath]]; shapeLayer.lineWidth = 30.0f; [shapeLayer setStrokeColor:[[UIColor redColor] CGColor]]; shapeLayer

how to set a context to NSString drawAtPoint?

大憨熊 提交于 2019-12-10 17:43:11
问题 I currently working on encapsulation many [NSString drawAtPoint:withFont:] function calls to a method so that I could draw lots of strings by a single call, but how can I tell the method where to draw these strings? What if I pass a CGContextRef to it, how to set a CGContextRef as current context? 回答1: Maybe you need this part of code: CGContextRef context = UIGraphicsGetCurrentContext(); 回答2: On iOS 4 and later, wrap the NSString drawAtPoint calls with UIGraphicsPushContext(context) and