From 29982a1e77e9780f218864c9331b7290581ba588 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Fri, 12 Nov 2010 10:07:29 -0800 Subject: [PATCH] Started drawImage() w/h --- src/CanvasRenderingContext2d.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 9ae0a86..ef7e9bb 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -399,12 +399,17 @@ Context2d::DrawImage(const Arguments &args) { Image *img = ObjectWrap::Unwrap(args[0]->ToObject()); Context2d *context = ObjectWrap::Unwrap(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);