我想在 zick-zack 中画一颗钻石,就像圆形一样。请任何人帮助我。
问问题
545 次
3 回答
4
我有一个用于绘制钻石的钻石 Thish 代码
int mgX = penThickness * 6; int mgY = penThickness * 2;
CGPoint st = CGPointMake(MIN(startingPt.x, endingPt.x), MIN(startingPt.y, endingPt.y));
CGPoint et = CGPointMake(MAX(startingPt.x, endingPt.x), MAX(startingPt.y, endingPt.y));
CGRect outsideRect = CGRectMake(st.x,st.y, MAX(mgX, et.x-st.x), MAX(mgY, et.y-st.y));
CGRect insideRect = CGRectInset(outsideRect, outsideRect.size.width * 0.30f, outsideRect.size.height * 0.30f);
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(insideRect), CGRectGetMinY(outsideRect));
//0 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(insideRect), CGRectGetMinY(outsideRect));
//1 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(outsideRect), CGRectGetMidY(insideRect));
//2 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(insideRect), CGRectGetMaxY(outsideRect));
//3 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMinX(insideRect), CGRectGetMaxY(outsideRect));
//4 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMinX(outsideRect), CGRectGetMidY(insideRect));
CGPathCloseSubpath(pathRef);
于 2013-11-07T05:35:04.170 回答
4
我在绘制 Haxagon 的 Hexagone thish 代码中完成了 Draw Complet
int mgX = penThickness * 6; int mgY = penThickness * 6;
CGPoint st = CGPointMake(MIN(startingPt.x, endingPt.x), MIN(startingPt.y, endingPt.y));
CGPoint et = CGPointMake(MAX(startingPt.x, endingPt.x), MAX(startingPt.y, endingPt.y));
CGRect outsideRect = CGRectMake(st.x,st.y, MAX(mgX, et.x-st.x), MAX(mgY, et.y-st.y));
CGRect insideRect = CGRectInset(outsideRect, outsideRect.size.width * 0.30f, outsideRect.size.height * 0.30f);
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(insideRect), CGRectGetMinY(outsideRect));
//0 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(insideRect), CGRectGetMinY(outsideRect));
//1 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(outsideRect), CGRectGetMidY(insideRect));
//2 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(insideRect), CGRectGetMaxY(outsideRect));
//3 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMinX(insideRect), CGRectGetMaxY(outsideRect));
//4 line
CGPathAddLineToPoint(pathRef, nil, CGRectGetMinX(outsideRect), CGRectGetMidY(insideRect));
CGPathCloseSubpath(pathRef);
于 2013-11-07T09:29:01.117 回答
1
于 2013-10-30T09:07:44.210 回答