v8::Handle<v8::Value> V8CanvasRenderingContext2D::fillTextCallback(const v8::Arguments& args) { INC_STATS("DOM.CanvasRenderingContext2D.fillText()"); CanvasRenderingContext2D* context = V8CanvasRenderingContext2D::toNative(args.Holder()); // Two forms: // * fillText(text, x, y) // * fillText(text, x, y, maxWidth) if (args.Length() < 3 || args.Length() > 4) { V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } String text = toWebCoreString(args[0]); float x = toFloat(args[1]); float y = toFloat(args[2]); if (args.Length() == 4) { float maxWidth = toFloat(args[3]); context->fillText(text, x, y, maxWidth); } else context->fillText(text, x, y); return v8::Undefined(); }
JSValue JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); // string arg = text to draw // number arg = x // number arg = y // optional number arg = maxWidth if (args.size() < 3 || args.size() > 4) return throwError(exec, SyntaxError); if (args.size() == 4) context->fillText(args.at(0).toString(exec), args.at(1).toFloat(exec), args.at(2).toFloat(exec), args.at(3).toFloat(exec)); else context->fillText(args.at(0).toString(exec), args.at(1).toFloat(exec), args.at(2).toFloat(exec)); return jsUndefined(); }
void BoardDrawer::drawEmpty(int row, int col, int number) { m_ctx->fillRect(col * 10, row * 10, 10, 10); m_ctx->clearRect(col * 10 + 1, row * 10 + 1, 8, 8); if (number > 0) { sprintf(buffer, "%u", number); m_ctx->fillText(std::string(buffer), col * 10 + 2, row * 10 + 8.5); } }