Efficient method to draw a line with millions of points

前端 未结 2 1954
栀梦
栀梦 2020-12-07 16:02

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

2条回答
  •  广开言路
    2020-12-07 16:50

    In relation to the particular question of anti-aliasing. In Quartz the anti-aliasing is applied to the context at the moment of drawing. The CGPathRef is agnostic to the drawing context. Thus, the same CGPathRef can be rendered into an antialiased context or to a non-antialiased context. For example, to disable antialiasing during animations:

    CGContextRef context = UIGraphicsGetCurrentContext();
    GMutablePathRef fill_path = CGPathCreateMutable();
    // Fill the path with the wave
    ...
    
    CGContextAddPath(context, fill_path);
    if ([self animating])
        CGContextSetAllowsAntialiasing(context, NO);
    else
        CGContextSetAllowsAntialiasing(context, YES);
    // Do the drawing
    CGContextDrawPath(context, kCGPathStroke);
    

提交回复
热议问题