|
@ -5,6 +5,7 @@ |
|
|
// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
|
|
|
// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
|
|
|
//
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "color.h" |
|
|
#include "Canvas.h" |
|
|
#include "Canvas.h" |
|
|
#include "CanvasGradient.h" |
|
|
#include "CanvasGradient.h" |
|
|
|
|
|
|
|
@ -74,15 +75,23 @@ Gradient::AddColorStop(const Arguments &args) { |
|
|
return ThrowException(Exception::TypeError(String::New("offset required"))); |
|
|
return ThrowException(Exception::TypeError(String::New("offset required"))); |
|
|
if (!args[1]->IsString()) |
|
|
if (!args[1]->IsString()) |
|
|
return ThrowException(Exception::TypeError(String::New("color string required"))); |
|
|
return ThrowException(Exception::TypeError(String::New("color string required"))); |
|
|
RGBA_ARGS(1); |
|
|
|
|
|
Gradient *grad = ObjectWrap::Unwrap<Gradient>(args.This()); |
|
|
Gradient *grad = ObjectWrap::Unwrap<Gradient>(args.This()); |
|
|
cairo_pattern_add_color_stop_rgba( |
|
|
short ok; |
|
|
grad->pattern() |
|
|
String::AsciiValue str(args[1]); |
|
|
, args[0]->NumberValue() |
|
|
uint32_t rgba = rgba_from_string(*str, &ok); |
|
|
, r / 255 * 1 |
|
|
|
|
|
, g / 255 * 1 |
|
|
if (ok) { |
|
|
, b / 255 * 1 |
|
|
rgba_t color = rgba_create(rgba); |
|
|
, a); |
|
|
cairo_pattern_add_color_stop_rgba( |
|
|
|
|
|
grad->pattern() |
|
|
|
|
|
, args[0]->NumberValue() |
|
|
|
|
|
, color.r |
|
|
|
|
|
, color.g |
|
|
|
|
|
, color.b |
|
|
|
|
|
, color.a); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return Undefined(); |
|
|
return Undefined(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|