Here is the code I use to draw:
- (void) drawSomething
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);
CGContextSetLineWidth(context, 6.0);
CGContextMoveToPoint(context, 100.0f, 100.0f);
CGContextAddLineToPoint(context, 200.0f, 200.0f);
CGContextStrokePat...
I have a view with a class called "drawingViewController", and I have the drawRect method:
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextMoveToPoint(context, 0.0...
Hi all,
I'm trying to take an image that I have in a image object and render into a Core Graphics PDF context-- happens to be on an iPhone but this question surely applies equally to desktop Quartz. This UIImage is a simple color-on-white image at about 600x800 resolution. If I (say) turn it into a PNG file, that file looks exactly as ex...
I have a view, that have a drawRect method, I know that this method is the only way I control the View to draw something on it. So, I try to my drawing logic in this way:
- (void)drawRect:(CGRect)rect {
//my drawing code...
}
In my view, I use the IB to link this class.
[myView setNeedsDisplay];
It works, so, I designed to have...
Hello all,
I have a CATiledLayer into which I render content in the following method
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
I used the QuartzDemo code to draw a pattern. This works very well until I apply a rotation transform to the layer's parentLayer (a UIView):
rotated:
These zigzag artefacts become w...
I want to draw like that. How to draw like that? Do I use Quartzcore? please advice for me.
...
I am drawing custom UITableViewCells. My cells are opaque and are completely drawn in the drawRect of the cell to help with performance. I want to handle the look of a selected cell myself. If I don't, then the contents of my cell is covered up by the selectedBackgroundView that is added. Is it common or acceptable to override the se...
I can draw many things using this :
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"dummy2.png" ofType:nil];
UIImage *img = [UIImage imageWithContentsOfFile:imagePath];
image = CGImageRetain(img.CGImage);
CGRect imageRect;
double x = 0;
double y = 0;
for (int k=0; k<someValue; k++) {
x += k;
y += k;
...
I know that the CGContext cannot call it to draw directly, and it needs to fill the drawing logic in the drawInContext, and call the CGContext to draw using "setNeedsDisplay", so, I designed a cmd to execute, but it cause some problems... like this :
http://stackoverflow.com/questions/2617827/why-i-cant-draw-in-a-loop-using-uiview-in-i...
i spent some time with the environment variable CA_COLOR_OPAQUE = 1 and have my findings to share.
things that make a CALayer non-opaque (slow, more memory, ...):
* contents with alpha (like an NSImage with an icon)
* NSImage/CGImage from a pdf as contents (even when the pdf does not contain any alpha and opaque=YES)
* b...
I need to implement 'graphing paper' in an iPhone app. The user should be presented with a grid. They user can touch individual squares to turn them on, or if they're already on, off.The user can pinch to zoom and scroll around the paper as well..
So far I'm thinking Quartz 2D + UIScrollView is the way to do this but these are both are...
how can i draw gradient line with quartz2d?
...
Been working on this problem of collision detection and there appears to be 3 main approaches I could take:
Sprite and mask approach. (AND the overlap of the sprites and check for a non-zero number in the resulting sprite pixel data).
Bounding circles, rectangles or polygons. (Create one or more shapes that enclose the sprites and do...
I'm taking a snapshot of an view. This view has got some subviews which have layer masks applied to them. For some reason, those masks take no effect in the snapshot and the masked parts are completely visible.
UIGraphicsBeginImageContext(theView.frame.size);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newIma...
I'm trying to produce a clipping area in a UIView that's generated from path objects in its subviews. For example, I might have one subview containing a square and another containing a circle. I want to be able to produce a clip in the parent superview that's the union of both these shapes. Can someone explain how to do this? About all I...
Hi,
I need to add rounded corners to an image in a UITable View cell to 3px. What's the best way to go about this? Apparently you can use the quartz framework?
Thanks.
...
I want to be able to create a greyscale image with no alpha from a png in the app bundle.
This works, and I get an image created:
// Create graphics context the size of the overlapping rectangle
UIGraphicsBeginImageContext(rectangleOfOverlap.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
// More stuff
CGContextDrawImage(ctx...
Using the plethora of drawing functions in Cocoa or Quartz it's rather easy to draw paths, and fill them using a gradient. I can't seem to find an acceptable way however, to 'stroke'-draw a path with a line width of a few pixels and fill this stroke using a gradient. How is this done?
Edit: Apparently the question wasn't clear enough. T...
Hi
I have some a UIView with several user created subviews. The user can move and rotate the subviews. I'm using the transform attribute of UIView to accomplish this. I want to save the "document" in order to recreate it later.
I'm currently writing out the transform attribute out to a file along with some other data. But the transform...
I would like to write a program that can mirror a portion of the main display into a new window. Ideally this new window could then be displayed on an external monitor. I have seen this uiltity for a flightsim that does this on a pc (a multifunction display extractor).
CLick here for a screenshot of the program (MFD Extractor)
This w...