core-graphics

Core Graphics draw line with outline

本秂侑毒 提交于 2019-12-11 07:56:38
问题 I'm drawing an arbitrary line with Core Graphics with a width of 4 pixels, now I would like this line to have a 1 pixel outline of another colour. I can't see any CG functions that would achieve this "out of the box" but I'm looking for suggestions on how it could be done. This is my existing code: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 4.0); CGPoint curPoint = [(NSValue*)[points objectAtIndex:0] CGPointValue]; CGContextMoveToPoint(context,

how to build an undo stack in iOS/core graphics

泄露秘密 提交于 2019-12-11 07:18:33
问题 I'm trying to add an undo / redo capability to a set of touches.. I have this code for touchesBegan and moved: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%s", __FUNCTION__); mouseSwiped = NO; UITouch *touch = [touches anyObject]; if ([touch tapCount] == 2) { [self eraseButtonTapped:self]; return; } lastPoint = [touch locationInView:self.view]; lastPoint.y -= 20; [self.undoPath addObject:WHATGOESHERE]; // Remove all paths from redo stack [self.redoStack

Drawing an offscreen coloured square returns a greyscale image

你。 提交于 2019-12-11 07:04:49
问题 I asked this question earlier and am now trying to explore the idea of making an offscreen image. Something is going wrong - I think maybe with colour space? I've boiled the code down and down and down, until I eventually can demonstrate the problem with just a few lines. I have a view with an imageview (called iv) and a button, which when pushed, calls "push" - (UIImage *) block:(CGSize)size { UIGraphicsBeginImageContext(size); CGContextRef context = UIGraphicsGetCurrentContext();

Multiple drawLayer:

こ雲淡風輕ζ 提交于 2019-12-11 07:00:25
问题 how can i use drawLayer for multiple layers in one class? I was thinking maybe something like this: - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context { if(layer == layer1) { //do this } if(layer == layer2) { //do something else } } how would i do that? 来源: https://stackoverflow.com/questions/4579795/multiple-drawlayer

iPhone how do i make two connected line to follow to the position?

被刻印的时光 ゝ 提交于 2019-12-11 06:36:19
问题 I made the tail of speech bubble using core graphic and The tail part of the speech buble supposed to move to any point as i want. The problem is when the tail's end part(the pointy part) is downward it works fine. But when the bubble is upside down, like the bubble part is on the bottom the tail part is on the top, the tail part's 2 connected line crosses each other and form a X, when it supposed to be like /\ can someonle please help me? double angle(CGPoint p1, CGPoint p2) { //BOOL bRev =

how to draw smoothly with a flat nib pen / traped brush effect like Instagram using core graphics..?

淺唱寂寞╮ 提交于 2019-12-11 06:35:24
问题 I tried some code to calculate control points between start and end point of bezier path with touch move , add lines to bezier path and fill with colour to give flat pen effect like Instagram but unable to get smooth curved lines with fast finger move. from the below code I am able to get angled lines not smooth like instagram in image if (_bezierPath == nil || _brushType == BrushTypeNeon) { _bezierPath = [UIBezierPath new]; } [_bezierPath moveToPoint:(CGPoint){self.controlPoint1.x + self

How do I pad a graph so that lines aren't clipped by the edges?

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:29:44
问题 I've had a pretty good look around for an answer to this, and tried several solutions in my code, nothing found so far. I have a line graph that I am plotting, a CPTScatterPlot graph, and I have got points adding to it correctly. I want to show each of these points as a dot about 3-5 pixels in diameter, and connected by lines that are about 3 pixels wide. This all works fine. The problem is that when the plot is a straight along one of the edges of the graph hosting view, the lines and dots

How to draw a drop shadow AND gradient with quartz2d?

我与影子孤独终老i 提交于 2019-12-11 06:26:35
问题 I've a custom shape drawing using coregraphics and i want to add a drop shadow and a gradient to it also. I've been trying and searching a lot of informations on how to combine and do this, but i can't get it to work. I'm able to draw only one either. Anyone doing this already or know how to do this? Thank you. 回答1: Quartz only applies shadows to fills and strokes. Drawing a gradient does not count as a fill. Fill with a solid color (to draw the shadow), then draw the gradient in the same

Draw an arc on circle [duplicate]

。_饼干妹妹 提交于 2019-12-11 06:21:49
问题 This question already has answers here : Draw part of a circle (8 answers) Closed 6 years ago . I am developing an application in which I have to show a filled arc on my circle which will indicate the selected time. I have attached an image for specifying what I exactly want to ask:- Please help me in how to draw arc on circle. Any suggestions will be highly appreciated. 回答1: you need something like this 来源: https://stackoverflow.com/questions/6519836/draw-an-arc-on-circle

Memory issues with CGlayer

怎甘沉沦 提交于 2019-12-11 05:29:09
问题 I am working CGlayers for drawing. I have implemented the drawing part, the drawingView(canvas) where the user will draw is dynamic, what I mean by this is, user can increase/decrease height of the drawingView(Canvas) For example by default size - 500*200 When user clicks on expand button - 500*300 So here is my function when user expands the canvas, - (void)IncreaseCanavasSize { CGContextRef layerContext1 = CGLayerGetContext(permanentDrawingLayer ); CGContextDrawLayerInRect(layerContext1,