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); } }
void BoardDrawer::drawFlag(int row, int col) { m_ctx->clearRect(col * 10 + 1, row * 10 + 1, 8, 8); m_ctx->beginPath(); m_ctx->moveTo(col * 10 + 1, row * 10 + 1); m_ctx->lineTo(col * 10 + 9, row * 10 + 1); m_ctx->lineTo(col * 10 + 1, row * 10 + 9); m_ctx->closePath(); m_ctx->fill(); }
JSValue* jsCanvasRenderingContext2DPrototypeFunctionClearRect(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->clearRect(x, y, width, height); return jsUndefined(); }
void BoardDrawer::drawMine(int row, int col) { m_ctx->clearRect(col * 10, row * 10, 10, 10); m_ctx->beginPath(); m_ctx->arc(col * 10 + 5, row * 10 + 5, 4.5, 0, 2 * M_PI); m_ctx->stroke(); }