开发者

CoreGraphics/Quartz shadows

开发者 https://www.devze.com 2023-02-10 04:53 出处:网络
I\'m currently drawing a sinus-curve using the CoreGraphics/Quartz CGContextAddLineToPoint-function on the iPhone:

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

精彩评论

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