本文整理汇总了C++中CanvasRenderingContext2D::setStrokeColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CanvasRenderingContext2D::setStrokeColor方法的具体用法?C++ CanvasRenderingContext2D::setStrokeColor怎么用?C++ CanvasRenderingContext2D::setStrokeColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CanvasRenderingContext2D
的用法示例。
在下文中一共展示了CanvasRenderingContext2D::setStrokeColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void V8CanvasRenderingContext2D::strokeStyleAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
if (value->IsString())
impl->setStrokeColor(toWebCoreString(value));
else
impl->setStrokeStyle(toCanvasStyle(value, info.GetIsolate()));
}
示例2:
void JSCanvasRenderingContext2D::setStrokeStyle(ExecState* exec, JSValue value)
{
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
if (value.isString()) {
context->setStrokeColor(asString(value)->value(exec));
return;
}
context->setStrokeStyle(toHTMLCanvasStyle(exec, value));
}
示例3:
void V8CanvasRenderingContext2D::strokeStyleAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
if (RefPtr<CanvasStyle> canvasStyle = toCanvasStyle(value, info.GetIsolate())) {
impl->setStrokeStyle(canvasStyle);
} else {
TOSTRING_VOID(V8StringResource<>, colorString, value);
impl->setStrokeColor(colorString);
}
}
示例4: switch
// TODO: SetStrokeColor and SetFillColor are similar except function names,
// consolidate them into one.
v8::Handle<v8::Value> V8CanvasRenderingContext2D::setStrokeColorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.CanvasRenderingContext2D.setStrokeColor()");
CanvasRenderingContext2D* context = V8CanvasRenderingContext2D::toNative(args.Holder());
switch (args.Length()) {
case 1:
if (args[0]->IsString())
context->setStrokeColor(toWebCoreString(args[0]));
else
context->setStrokeColor(toFloat(args[0]));
break;
case 2:
if (args[0]->IsString())
context->setStrokeColor(toWebCoreString(args[0]), toFloat(args[1]));
else
context->setStrokeColor(toFloat(args[0]), toFloat(args[1]));
break;
case 4:
context->setStrokeColor(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]));
break;
case 5:
context->setStrokeColor(toFloat(args[0]), toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]));
break;
default:
V8Proxy::throwError(V8Proxy::SyntaxError, "setStrokeColor: Invalid number of arguments");
break;
}
return v8::Undefined();
}
示例5: throwError
JSValue* JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
// string arg = named color
// number arg = gray color
// string arg, number arg = named color, alpha
// number arg, number arg = gray color, alpha
// 4 args = r, g, b, a
// 5 args = c, m, y, k, a
switch (args.size()) {
case 1:
if (args[0]->isString())
context->setStrokeColor(static_cast<JSString*>(args[0])->value());
else
context->setStrokeColor(args[0]->toFloat(exec));
break;
case 2:
if (args[0]->isString())
context->setStrokeColor(static_cast<JSString*>(args[0])->value(), args[1]->toFloat(exec));
else
context->setStrokeColor(args[0]->toFloat(exec), args[1]->toFloat(exec));
break;
case 4:
context->setStrokeColor(args[0]->toFloat(exec), args[1]->toFloat(exec),
args[2]->toFloat(exec), args[3]->toFloat(exec));
break;
case 5:
context->setStrokeColor(args[0]->toFloat(exec), args[1]->toFloat(exec),
args[2]->toFloat(exec), args[3]->toFloat(exec), args[4]->toFloat(exec));
break;
default:
return throwError(exec, SyntaxError);
}
return jsUndefined();
}