关键代码:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0.5, 0.5, 0.5, 1.0);
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 0.5, 1.0);
int pointNum = 360;
double x,y;
float sx,sy;
double off = 360.0f/(float)pointNum;
x = 0.0;
double r;
for (int i=0; i<pointNum; i++) {
r = x * PI / 180.0f;
y = sin(r);
sx = x * 256.0f / 90.0f;
sy = y * 256.0f;
sy = 512.0f - sy;
CGContextFillRect(context, CGRectMake(sx,sy,1,1));
x += off;
}
360点:
7200点: