コード例 #1
0
ファイル: TIPCGUtils.c プロジェクト: samiamwork/Questionable
CGMutablePathRef TIPCGUtilsRoundedBoxCreate( CGRect inRect, float margin, float radius, float lineWidth )
{	
	float halfLineWidth = lineWidth/2.0f;
	
	inRect.origin.x += margin;
	inRect.origin.y += margin;
	inRect.size.width -= 2.0f*margin;
	inRect.size.height -= 2.0f*margin;
	
	CGMutablePathRef roundedBoxRef = CGPathCreateMutable();
	
	CGPathMoveToPoint(roundedBoxRef, NULL,
					  inRect.origin.x + halfLineWidth, inRect.origin.y + halfLineWidth + radius);
	CGPathAddLineToPoint(roundedBoxRef, NULL,
						 inRect.origin.x + halfLineWidth, inRect.origin.y + inRect.size.height - radius - halfLineWidth);
	CGPathAddArcToPoint(roundedBoxRef, NULL,
						inRect.origin.x + halfLineWidth, inRect.origin.y + inRect.size.height - halfLineWidth,
						inRect.origin.x + halfLineWidth + radius, inRect.origin.y + inRect.size.height - halfLineWidth,
						radius);
	CGPathAddArcToPoint(roundedBoxRef, NULL,
						inRect.origin.x + inRect.size.width - halfLineWidth, inRect.origin.y + inRect.size.height - halfLineWidth,
						inRect.origin.x + inRect.size.width - halfLineWidth, inRect.origin.y + inRect.size.height - radius - halfLineWidth,
						radius);
	CGPathAddArcToPoint(roundedBoxRef, NULL,
						inRect.origin.x + inRect.size.width - halfLineWidth, inRect.origin.y + halfLineWidth,
						inRect.origin.x + inRect.size.width - radius - halfLineWidth, inRect.origin.y + halfLineWidth,
						radius);
	CGPathAddArcToPoint(roundedBoxRef, NULL,
						inRect.origin.x + halfLineWidth, inRect.origin.y + halfLineWidth,
						inRect.origin.x + halfLineWidth, inRect.origin.y + halfLineWidth + radius,
						radius);
	
	return roundedBoxRef;
}
コード例 #2
0
ファイル: TIPCGUtils.c プロジェクト: samiamwork/Questionable
CGMutablePathRef TIPCGUtilsPartialRoundedBoxCreate( CGRect inRect, float radius, bool lowerRight, bool upperRight, bool upperLeft, bool lowerLeft )
{
	CGMutablePathRef roundedBoxRef = CGPathCreateMutable();
	
	if( lowerRight ) {
		CGPathMoveToPoint(roundedBoxRef, NULL,
						  inRect.origin.x, inRect.origin.y + radius);
	} else {
		CGPathMoveToPoint(roundedBoxRef, NULL,
						  inRect.origin.x, inRect.origin.y);
	}
	
	if( upperRight ) {
		CGPathAddLineToPoint(roundedBoxRef, NULL,
							 inRect.origin.x, inRect.origin.y + inRect.size.height - radius);
		CGPathAddArcToPoint(roundedBoxRef, NULL,
							inRect.origin.x, inRect.origin.y + inRect.size.height,
							inRect.origin.x + radius, inRect.origin.y + inRect.size.height,
							radius);
	} else {
		CGPathAddLineToPoint(roundedBoxRef, NULL,
							 inRect.origin.x, inRect.origin.y + inRect.size.height);
	}
	
	if( upperLeft ) {
		CGPathAddArcToPoint(roundedBoxRef, NULL,
							inRect.origin.x + inRect.size.width, inRect.origin.y + inRect.size.height,
							inRect.origin.x + inRect.size.width, inRect.origin.y + inRect.size.height - radius,
							radius);
	} else {
		CGPathAddLineToPoint(roundedBoxRef, NULL,
							 inRect.origin.x + inRect.size.width, inRect.origin.y + inRect.size.height);
	}
	
	if( lowerLeft ) {
		CGPathAddArcToPoint(roundedBoxRef, NULL,
							inRect.origin.x + inRect.size.width, inRect.origin.y,
							inRect.origin.x + inRect.size.width - radius, inRect.origin.y,
							radius);
	} else {
		CGPathAddLineToPoint(roundedBoxRef, NULL,
							 inRect.origin.x + inRect.size.width, inRect.origin.y);
	}
	
	if( lowerRight ) {
		CGPathAddArcToPoint(roundedBoxRef, NULL,
							inRect.origin.x, inRect.origin.y,
							inRect.origin.x, inRect.origin.y + radius,
							radius);
	}
	
	return roundedBoxRef;
}
コード例 #3
0
ファイル: PathCG.cpp プロジェクト: 13W/phantomjs
void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
{
    CGPathAddArcToPoint(m_path, 0, p1.x(), p1.y(), p2.x(), p2.y(), radius);
}
コード例 #4
0
void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
{
    CGPathAddArcToPoint(ensurePlatformPath(), 0, p1.x(), p1.y(), p2.x(), p2.y(), radius);
}