开发者

CoreGraphics/Quartz shadows

I'm currently drawing a sinus-curve using the CoreGraphics/Quartz CGContextAddLineToPoint-function on the iPhone:

CGContextRef _context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(_context, 6.0);
CGC开发者_JAVA百科olorSpaceRef _colorSpace = CGColorSpaceCreateDeviceRGB(); 
CGFloat _whiteColorComponents[] = {1.0, 1.0, 1.0, 1.0};
CGColorRef _color = CGColorCreate(_colorSpace, _whiteColorComponents);
CGContextSetStrokeColorWithColor(_context, _color);

CGContextMoveToPoint(_context, 0, 200);

float _increment = 1;
for (float _i = 0; _i<320; _i=_i+_increment) {
    float _sin = ((sin(_i/10) + 1) * 100) + 100;
    CGContextAddLineToPoint(_context, _i, _sin);
}

CGContextStrokePath(_context);

Now I would like to add a shadow (rather an outer-glow) to the whole path. Is this possible using Quartz (only read something about CGShading, but this seems kind of difficult)?

Thank you in advance, Alexander


The simplest way would be drawing to lines.

  1. Draw 'shadow' line (color1, width1)
  2. Draw normal line on top (color2, width2)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜