Esempio n. 1
0
/** internal Helper */
void CGPathWriter_path_walker(void *info, const CGPathElement *elm)
{
	assert(info != NULL);
	CGPathWriter_t *const t = (CGPathWriter_t *)info;
	assert(t->absolute && "currently only absolute positions supported.");
	assert(t->buffer && "buffer to write to mustn't be NULL");
	switch( elm->type ) {
	case kCGPathElementMoveToPoint:
		CGPathWriter_snprintf(t, "M%f,%f", elm->points[0].x, elm->points[0].y);
		break;
	case kCGPathElementAddLineToPoint:
		CGPathWriter_snprintf(t, "L%f,%f", elm->points[0].x, elm->points[0].y);
		break;
	case kCGPathElementAddQuadCurveToPoint:
		CGPathWriter_snprintf(t, "Q%f,%f,%f,%f", elm->points[0].x, elm->points[0].y, elm->points[1].x, elm->points[1].y);
		break;
	case kCGPathElementAddCurveToPoint:
		CGPathWriter_snprintf(t, "C%f,%f,%f,%f,%f,%f", elm->points[0].x, elm->points[0].y, elm->points[1].x, elm->points[1].y, elm->points[2].x, elm->points[2].y);
		break;
	case kCGPathElementCloseSubpath:
		CGPathWriter_snprintf(t, "Z");
		break;
	default:
		fprintf(stderr, "Switch-case-fallthrough\n");
		assert(0);
		break;
	}
}
Esempio n. 2
0
/// internal Helper
void CGPathWriter_path_walker(void *info, const CGPathElement *elm)
{
	assert(info != NULL);
	CGPathWriter_t *const t = (CGPathWriter_t *)info;
	if ( t->buffer == NULL )
		return;
	switch ( elm->type ) {
	case kCGPathElementMoveToPoint:
		CGPathWriter_snprintf(t, "M%f,%f", elm->points[0].x, elm->points[0].y);
		break;
	case kCGPathElementAddLineToPoint:
		CGPathWriter_snprintf(t, "L%f,%f", elm->points[0].x, elm->points[0].y);
		break;
	case kCGPathElementAddQuadCurveToPoint:
		CGPathWriter_snprintf(t, "Q%f,%f,%f,%f", elm->points[0].x, elm->points[0].y, elm->points[1].x, elm->points[1].y);
		break;
	case kCGPathElementAddCurveToPoint:
		CGPathWriter_snprintf(t, "C%f,%f,%f,%f,%f,%f", elm->points[0].x, elm->points[0].y, elm->points[1].x, elm->points[1].y, elm->points[2].x, elm->points[2].y);
		break;
	case kCGPathElementCloseSubpath:
		CGPathWriter_snprintf(t, "Z");
		break;
	default:
		fprintf(stderr, "Switch-case-fallthrough\n");
		assert(0);
		break;
	}
}