本文整理汇总了C++中CanvasRenderingContext2D类的典型用法代码示例。如果您正苦于以下问题:C++ CanvasRenderingContext2D类的具体用法?C++ CanvasRenderingContext2D怎么用?C++ CanvasRenderingContext2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CanvasRenderingContext2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: impl
JSValue* JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
JSValue* value = args[0];
if (!value->isObject())
return throwError(exec, TypeError);
JSObject* o = static_cast<JSObject*>(value);
if (o->inherits(&JSHTMLImageElement::s_info)) {
ExceptionCode ec;
JSValue* pattern = toJS(exec,
context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
valueToStringWithNullCheck(exec, args[1]), ec).get());
setDOMException(exec, ec);
return pattern;
}
if (o->inherits(&JSHTMLCanvasElement::s_info)) {
ExceptionCode ec;
JSValue* pattern = toJS(exec,
context->createPattern(static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
valueToStringWithNullCheck(exec, args[1]), ec).get());
setDOMException(exec, ec);
return pattern;
}
setDOMException(exec, TYPE_MISMATCH_ERR);
return 0;
}
示例2: INC_STATS
v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8::Arguments& args)
{
INC_STATS("DOM.CanvasRenderingContext2D.createPattern()");
CanvasRenderingContext2D* context = V8CanvasRenderingContext2D::toNative(args.Holder());
v8::Handle<v8::Value> arg = args[0];
if (V8HTMLImageElement::HasInstance(arg)) {
HTMLImageElement* imageElement = V8HTMLImageElement::toNative(v8::Handle<v8::Object>::Cast(arg));
ExceptionCode ec = 0;
RefPtr<CanvasPattern> pattern = context->createPattern(imageElement, toWebCoreStringWithNullCheck(args[1]), ec);
if (ec != 0) {
V8Proxy::setDOMException(ec);
return notHandledByInterceptor();
}
return toV8(pattern.release());
}
if (V8HTMLCanvasElement::HasInstance(arg)) {
HTMLCanvasElement* canvasElement = V8HTMLCanvasElement::toNative(v8::Handle<v8::Object>::Cast(arg));
ExceptionCode ec = 0;
RefPtr<CanvasPattern> pattern = context->createPattern(canvasElement, toWebCoreStringWithNullCheck(args[1]), ec);
if (ec != 0) {
V8Proxy::setDOMException(ec);
return notHandledByInterceptor();
}
return toV8(pattern.release());
}
V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
return notHandledByInterceptor();
}
示例3:
void V8CanvasRenderingContext2D::fillStyleAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder());
if (value->IsString())
impl->setFillColor(toWebCoreString(value));
else
impl->setFillStyle(toCanvasStyle(value, info.GetIsolate()));
}
示例4: attach
void HTMLCanvasElement::attach()
{
HTMLElement::attach();
if (m_context && m_context->is2d()) {
CanvasRenderingContext2D* ctx = static_cast<CanvasRenderingContext2D*>(m_context.get());
ctx->updateFont();
}
}
示例5:
void JSCanvasRenderingContext2D::setFillStyle(ExecState* exec, JSValue value)
{
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
if (value.isString()) {
context->setFillColor(asString(value)->value(exec));
return;
}
context->setFillStyle(toHTMLCanvasStyle(exec, value));
}
示例6:
void V8CanvasRenderingContext2D::fillStyleAttributeSetterCustom(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->setFillStyle(canvasStyle);
} else {
TOSTRING_VOID(V8StringResource<>, colorString, value);
impl->setFillColor(colorString);
}
}
示例7: jsCanvasRenderingContext2DPrototypeFunctionClearShadow
JSValue* jsCanvasRenderingContext2DPrototypeFunctionClearShadow(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCanvasRenderingContext2D::s_info))
return throwError(exec, TypeError);
JSCanvasRenderingContext2D* castedThisObj = static_cast<JSCanvasRenderingContext2D*>(thisValue);
CanvasRenderingContext2D* imp = static_cast<CanvasRenderingContext2D*>(castedThisObj->impl());
imp->clearShadow();
return jsUndefined();
}
示例8: recalcStyle
void HTMLCanvasElement::recalcStyle(StyleChange change)
{
HTMLElement::recalcStyle(change);
// Update font if needed.
if (change == Force && m_context && m_context->is2d()) {
CanvasRenderingContext2D* ctx = static_cast<CanvasRenderingContext2D*>(m_context.get());
ctx->updateFont();
}
}
示例9: jsCanvasRenderingContext2DPrototypeFunctionSetLineJoin
JSValue* jsCanvasRenderingContext2DPrototypeFunctionSetLineJoin(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCanvasRenderingContext2D::s_info))
return throwError(exec, TypeError);
JSCanvasRenderingContext2D* castedThisObj = static_cast<JSCanvasRenderingContext2D*>(thisValue);
CanvasRenderingContext2D* imp = static_cast<CanvasRenderingContext2D*>(castedThisObj->impl());
const UString& join = args[0]->toString(exec);
imp->setLineJoin(join);
return jsUndefined();
}
示例10: jsCanvasRenderingContext2DPrototypeFunctionSetMiterLimit
JSValue* jsCanvasRenderingContext2DPrototypeFunctionSetMiterLimit(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCanvasRenderingContext2D::s_info))
return throwError(exec, TypeError);
JSCanvasRenderingContext2D* castedThisObj = static_cast<JSCanvasRenderingContext2D*>(thisValue);
CanvasRenderingContext2D* imp = static_cast<CanvasRenderingContext2D*>(castedThisObj->impl());
float limit = args[0]->toFloat(exec);
imp->setMiterLimit(limit);
return jsUndefined();
}
示例11: constructArray
JSValue JSCanvasRenderingContext2D::webkitLineDash(ExecState* exec) const
{
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
const Vector<float>& dash = context->getLineDash();
MarkedArgumentBuffer list;
Vector<float>::const_iterator end = dash.end();
for (Vector<float>::const_iterator it = dash.begin(); it != end; ++it)
list.append(JSValue(*it));
return constructArray(exec, 0, globalObject(), list);
}
示例12: impl
JSValue JSCanvasRenderingContext2D::strokeRect(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
if (args.size() <= 4)
context->strokeRect(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
args.at(2).toFloat(exec), args.at(3).toFloat(exec));
else
context->strokeRect(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
args.at(2).toFloat(exec), args.at(3).toFloat(exec), args.at(4).toFloat(exec));
return jsUndefined();
}
示例13: jsCanvasRenderingContext2DPrototypeFunctionCreateImageData
JSValue* jsCanvasRenderingContext2DPrototypeFunctionCreateImageData(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCanvasRenderingContext2D::s_info))
return throwError(exec, TypeError);
JSCanvasRenderingContext2D* castedThisObj = static_cast<JSCanvasRenderingContext2D*>(thisValue);
CanvasRenderingContext2D* imp = static_cast<CanvasRenderingContext2D*>(castedThisObj->impl());
float sw = args[0]->toFloat(exec);
float sh = args[1]->toFloat(exec);
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createImageData(sw, sh)));
return result;
}
示例14: jsCanvasRenderingContext2DPrototypeFunctionIsPointInPath
JSValue* jsCanvasRenderingContext2DPrototypeFunctionIsPointInPath(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCanvasRenderingContext2D::s_info))
return throwError(exec, TypeError);
JSCanvasRenderingContext2D* castedThisObj = static_cast<JSCanvasRenderingContext2D*>(thisValue);
CanvasRenderingContext2D* imp = static_cast<CanvasRenderingContext2D*>(castedThisObj->impl());
float x = args[0]->toFloat(exec);
float y = args[1]->toFloat(exec);
KJS::JSValue* result = jsBoolean(imp->isPointInPath(x, y));
return result;
}
示例15: jsCanvasRenderingContext2DPrototypeFunctionRect
JSValue* jsCanvasRenderingContext2DPrototypeFunctionRect(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (!thisValue->isObject(&JSCanvasRenderingContext2D::s_info))
return throwError(exec, TypeError);
JSCanvasRenderingContext2D* castedThisObj = static_cast<JSCanvasRenderingContext2D*>(thisValue);
CanvasRenderingContext2D* imp = static_cast<CanvasRenderingContext2D*>(castedThisObj->impl());
float x = args[0]->toFloat(exec);
float y = args[1]->toFloat(exec);
float width = args[2]->toFloat(exec);
float height = args[3]->toFloat(exec);
imp->rect(x, y, width, height);
return jsUndefined();
}