0

我目前正在使用 iPhone 上的 CoreGraphics/Quartz CGContextAddLineToPoint 函数绘制正弦曲线:

CGContextRef _context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(_context, 6.0);
CGColorSpaceRef _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);

现在我想为整个路径添加一个阴影(而不是外发光)。使用 Quartz 是否可行(仅阅读有关 CGShading 的内容,但这似乎有点困难)?

提前谢谢你,亚历山大

4

1 回答 1

0

最简单的方法是绘制线条。

  1. 绘制“阴影”线(color1,width1)
  2. 在顶部绘制法线(color2,width2)
于 2011-02-10T11:06:00.197 回答