void KPR_canvasRenderingContext2D_clip(xsMachine *the) { FskCanvas2dContext ctx = xsGetHostData(xsThis); FskCanvas2dPath path = NULL; SInt32 fillRule = kFskCanvas2dFillRuleNonZero; int numArgs = xsToInteger(xsArgc); if (numArgs > 0) { /* ctx.clip(), when numArgs==0 */ if (xsIsInstanceOf(xsArg(0), xsGet(xsGet(xsGlobal, xsID_KPR), xsID("path2D")))) { /* ctx.clip(path) */ path = xsGetHostData(xsArg(0)); if (numArgs > 1) fillRule = GetFillRule(xsToString(xsArg(1))); /* ctx.clip(path, fillRule) */ } else { fillRule = GetFillRule(xsToString(xsArg(0))); /* ctx.clip(fillRule) */ } } FskCanvas2dPathClip(ctx, path, fillRule); }
void GeometryGroup::Draw (cairo_t *cr) { Transform *transform = GetTransform (); cairo_matrix_t saved; cairo_get_matrix (cr, &saved); if (transform) { cairo_matrix_t matrix; transform->GetTransform (&matrix); cairo_transform (cr, &matrix); } GeometryCollection *children = GetChildren (); Geometry *geometry; // GeometryGroup is used for Clip (as a Geometry) so Fill (normally setting the fill rule) is never called cairo_set_fill_rule (cr, convert_fill_rule (GetFillRule ())); int children_count = children->GetCount (); for (int i = 0; i < children_count; i++) { geometry = children->GetValueAt (i)->AsGeometry (); geometry->Draw (cr); } cairo_set_matrix (cr, &saved); }
void KPR_canvasRenderingContext2D_isPointInPath(xsMachine *the) { FskCanvas2dContext ctx = xsGetHostData(xsThis); FskCanvas2dPath path = NULL; SInt32 fillRule = kFskCanvas2dFillRuleNonZero; int numArgs = xsToInteger(xsArgc); xsNumberValue x, y; if (xsIsInstanceOf(xsArg(0), xsGet(xsGet(xsGlobal, xsID_KPR), xsID("path2D")))) { /* ctx.isPointInPath(path, x, y) */ path = xsGetHostData(xsArg(0)); x = xsToNumber(xsArg(1)); y = xsToNumber(xsArg(2)); if (numArgs > 3) fillRule = GetFillRule(xsToString(xsArg(3))); /* ctx.isPointInPath(path, x, y, fillRule) */ } else { /* ctx.isPointInPath(x, y) */ x = xsToNumber(xsArg(0)); y = xsToNumber(xsArg(1)); if (numArgs > 2) fillRule = GetFillRule(xsToString(xsArg(2))); /* ctx.isPointInPath(x, y, fillRule) */ } xsResult = xsBoolean(FskCanvas2dIsPointInPathFill(ctx, path, x, y, fillRule)); }
void Geometry::Draw (cairo_t *cr) { Transform *transform = GetTransform (); cairo_matrix_t saved; cairo_get_matrix (cr, &saved); if (transform) { cairo_matrix_t matrix; transform->GetTransform (&matrix); cairo_transform (cr, &matrix); } if (!IsBuilt ()) Build (); // Geometry is used for Clip so Fill (normally setting the fill rule) is never called cairo_set_fill_rule (cr, convert_fill_rule (GetFillRule ())); if (path) cairo_append_path (cr, &path->cairo); cairo_set_matrix (cr, &saved); }