Browse Source

Started drawImage() w/h

v1.x
Tj Holowaychuk 14 years ago
parent
commit
29982a1e77
  1. 13
      src/CanvasRenderingContext2d.cc

13
src/CanvasRenderingContext2d.cc

@ -399,12 +399,17 @@ Context2d::DrawImage(const Arguments &args) {
Image *img = ObjectWrap::Unwrap<Image>(args[0]->ToObject());
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
double x = args[1]->NumberValue();
double y = args[2]->NumberValue();
// Dest point
double dx = args[1]->NumberValue();
double dy = args[2]->NumberValue();
// Dest dimensions
double dw = args[3]->IsNumber() ? args[3]->NumberValue() : img->width;
double dh = args[4]->IsNumber() ? args[4]->NumberValue() : img->height;
cairo_t *ctx = context->context();
cairo_save(ctx);
cairo_set_source_surface(ctx, img->surface(), x, y);
cairo_set_source_surface(ctx, img->surface(), dx, dy);
cairo_paint(ctx);
cairo_restore(ctx);

Loading…
Cancel
Save