|
@ -8,6 +8,7 @@ |
|
|
#include <math.h> |
|
|
#include <math.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
|
|
|
#include <vector> |
|
|
#include "Canvas.h" |
|
|
#include "Canvas.h" |
|
|
#include "Point.h" |
|
|
#include "Point.h" |
|
|
#include "Image.h" |
|
|
#include "Image.h" |
|
@ -2033,7 +2034,7 @@ NAN_METHOD(Context2d::SetLineDash) { |
|
|
Handle<Array> dash = Handle<Array>::Cast(args[0]); |
|
|
Handle<Array> dash = Handle<Array>::Cast(args[0]); |
|
|
uint32_t dashes = dash->Length() & 1 ? dash->Length() * 2 : dash->Length(); |
|
|
uint32_t dashes = dash->Length() & 1 ? dash->Length() * 2 : dash->Length(); |
|
|
|
|
|
|
|
|
double a[dashes]; |
|
|
std::vector<double> a(dashes); |
|
|
for (uint32_t i=0; i<dashes; i++) { |
|
|
for (uint32_t i=0; i<dashes; i++) { |
|
|
Local<Value> d = dash->Get(i % dash->Length()); |
|
|
Local<Value> d = dash->Get(i % dash->Length()); |
|
|
if (!d->IsNumber()) NanReturnUndefined(); |
|
|
if (!d->IsNumber()) NanReturnUndefined(); |
|
@ -2045,7 +2046,7 @@ NAN_METHOD(Context2d::SetLineDash) { |
|
|
cairo_t *ctx = context->context(); |
|
|
cairo_t *ctx = context->context(); |
|
|
double offset; |
|
|
double offset; |
|
|
cairo_get_dash(ctx, NULL, &offset); |
|
|
cairo_get_dash(ctx, NULL, &offset); |
|
|
cairo_set_dash(ctx, a, dashes, offset); |
|
|
cairo_set_dash(ctx, a.data(), dashes, offset); |
|
|
NanReturnUndefined(); |
|
|
NanReturnUndefined(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2059,8 +2060,8 @@ NAN_METHOD(Context2d::GetLineDash) { |
|
|
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); |
|
|
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); |
|
|
cairo_t *ctx = context->context(); |
|
|
cairo_t *ctx = context->context(); |
|
|
int dashes = cairo_get_dash_count(ctx); |
|
|
int dashes = cairo_get_dash_count(ctx); |
|
|
double a[dashes]; |
|
|
std::vector<double> a(dashes); |
|
|
cairo_get_dash(ctx, a, NULL); |
|
|
cairo_get_dash(ctx, a.data(), NULL); |
|
|
|
|
|
|
|
|
Local<Array> dash = NanNew<Array>(dashes); |
|
|
Local<Array> dash = NanNew<Array>(dashes); |
|
|
for (int i=0; i<dashes; i++) |
|
|
for (int i=0; i<dashes; i++) |
|
@ -2083,9 +2084,9 @@ NAN_SETTER(Context2d::SetLineDashOffset) { |
|
|
cairo_t *ctx = context->context(); |
|
|
cairo_t *ctx = context->context(); |
|
|
|
|
|
|
|
|
int dashes = cairo_get_dash_count(ctx); |
|
|
int dashes = cairo_get_dash_count(ctx); |
|
|
double a[dashes]; |
|
|
std::vector<double> a(dashes); |
|
|
cairo_get_dash(ctx, a, NULL); |
|
|
cairo_get_dash(ctx, a.data(), NULL); |
|
|
cairo_set_dash(ctx, a, dashes, offset); |
|
|
cairo_set_dash(ctx, a.data(), dashes, offset); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|