void WriteWithPen(Pen &pen){ cout << pen.drawLine() << endl; cout << pen.drawCircle() << endl; }
/** void Pen::setHsva(float h, float s=1.0, float v=1.0, float a=1.0) * include/mimas/Pen.h:69 */ static int Pen_setHsva(lua_State *L) { try { Pen *self = *((Pen **)dub_checksdata(L, 1, "mimas.Pen")); int top__ = lua_gettop(L); if (top__ >= 5) { float h = dub_checknumber(L, 2); float s = dub_checknumber(L, 3); float v = dub_checknumber(L, 4); float a = dub_checknumber(L, 5); self->setHsva(h, s, v, a); return 0; } else if (top__ >= 4) { float h = dub_checknumber(L, 2); float s = dub_checknumber(L, 3); float v = dub_checknumber(L, 4); self->setHsva(h, s, v); return 0; } else if (top__ >= 3) { float h = dub_checknumber(L, 2); float s = dub_checknumber(L, 3); self->setHsva(h, s); return 0; } else { float h = dub_checknumber(L, 2); self->setHsva(h); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "setHsva: %s", e.what()); } catch (...) { lua_pushfstring(L, "setHsva: Unknown exception"); } return dub_error(L); }
CompiledTextStyle Text::textStyle() { if(isDirty()) { setDirty(false); { QVariant v = basedOn(); if(v.isValid()) { QObject *o = styleobjectFromVariant(v); Text *based_on = qobject_cast<Text*>(o); if(based_on) { m_textStyle = based_on->textStyle(); } } } { Pen* p = pen(); if(p) { m_textStyle.setPen(p->pen()); } } { Font* p = font(); if(p) { m_textStyle.setFont(p->font()); } } } return m_textStyle; }
VOID Button::draw(Graphics *pGraphics, Pen &rPen, SolidBrush &rBrush, CONST Font &/*rFont*/) const { rPen.SetColor(Color(5, 159, 225)); rPen.SetWidth(3); rBrush.SetColor(Color(255, 125, 34)); pGraphics->DrawRectangle(&rPen, RECT2Rect()); //graphics->DrawString(text_.c_str(), text_.length(), &font, PointF(RECT2RectF().GetLeft(), RECT2RectF().GetTop()), &brush); }
static void DrawPolyline(Canvas &canvas, PixelOperations operations, const Pen &pen, const BulkPixelPoint *lppt, unsigned n_points, bool loop) { const unsigned thickness = pen.GetWidth(); const unsigned mask = pen.GetMask(); const auto color = canvas.Import(pen.GetColor()); canvas.DrawPolyline(lppt, n_points, loop, color, thickness, mask); }
VOID vec::draw(double x0, double y0, Graphics *graphics, Pen &rPen, CONST Color &rColor /* = Color::Yellow */) const { rPen.SetColor(rColor); rPen.SetWidth(2); graphics->DrawLine(&rPen, Point(static_cast<INT>(x0 ), static_cast<INT>( y0)), Point(static_cast<INT>(x0 + x_), static_cast<INT>(y_ + y0))); graphics->DrawLine(&rPen, Point(static_cast<INT>(x0 + x_), static_cast<INT>(y_ + y0)), Point(static_cast<INT>(x0 + x_ - ((l_ < 0)? -1 : 1) * 5 * cos(k_ + M_PI_4)), static_cast<INT>(y_ + y0 - ((l_ < 0)? -1 : 1) * 5 * sin(k_ + M_PI_4)))); graphics->DrawLine(&rPen, Point(static_cast<INT>(x0 + x_), static_cast<INT>(y_ + y0)), Point(static_cast<INT>(x0 + x_ - ((l_ < 0)? -1 : 1) * 5 * cos(k_ - M_PI_4)), static_cast<INT>(y_ + y0 - ((l_ < 0)? -1 : 1) * 5 * sin(k_ - M_PI_4)))); l_ = sqrt(x_ * x_ + y_ * y_); k_ = atan_(x_, y_); }
/** void Pen::setWidth(float w) * include/mimas/Pen.h:57 */ static int Pen_setWidth(lua_State *L) { try { Pen *self = *((Pen **)dub_checksdata(L, 1, "mimas.Pen")); float w = dub_checknumber(L, 2); self->setWidth(w); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setWidth: %s", e.what()); } catch (...) { lua_pushfstring(L, "setWidth: Unknown exception"); } return dub_error(L); }
/** void Pen::setColor(const Color &color) * include/mimas/Pen.h:65 */ static int Pen_setColor(lua_State *L) { try { Pen *self = *((Pen **)dub_checksdata(L, 1, "mimas.Pen")); Color *color = *((Color **)dub_checksdata(L, 2, "mimas.Color")); self->setColor(*color); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setColor: %s", e.what()); } catch (...) { lua_pushfstring(L, "setColor: Unknown exception"); } return dub_error(L); }
static Pen * gdiplusCreatePen(UINT style, float width, COLORREF color) { // create GDI+ pen Color gdipColor(0, 0, 0, 255); gdipColor.SetFromCOLORREF(color); Pen * pen = new Pen(gdipColor, width > 1 ? width : 1); if (style <= PS_DASHDOTDOT) // cast is save since GDI and GDI+ use same numbers pen->SetDashStyle(static_cast<DashStyle>(style)); pen->SetLineCap(LineCapFlat, LineCapFlat, DashCapFlat); return pen; }
static void DrawPolyline(Canvas &canvas, PixelOperations operations, const Pen &pen, const RasterPoint *lppt, unsigned n_points, bool loop) { const unsigned thickness = pen.GetWidth(); const unsigned mask = pen.GetMask(); const auto color = canvas.Import(pen.GetColor()); const SDLRasterCanvas::Point *points = reinterpret_cast<const SDLRasterCanvas::Point *>(lppt); canvas.DrawPolyline(points, n_points, loop, color, thickness, mask); }
/** void Pen::setJoinStyle(int style) * include/mimas/Pen.h:83 */ static int Pen_setJoinStyle(lua_State *L) { try { Pen *self = *((Pen **)dub_checksdata(L, 1, "mimas.Pen")); int style = dub_checkint(L, 2); self->setJoinStyle(style); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setJoinStyle: %s", e.what()); } catch (...) { lua_pushfstring(L, "setJoinStyle: Unknown exception"); } return dub_error(L); }
void Opengl2dPainter::renderBegin(Pen& pen, Matrix3& matrix) { OpenglContext oglcontext(_pPimpl->hdc, _pPimpl->hrc); glClearColor(pen.color().r/ 255.0, pen.color().g/255.0, pen.color().b/255.0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Matrix3 m; m.Rotate( _pPimpl->angle); _pPimpl->worldMatrix = matrix * m; }
bool Screen::paintTile(const Pen &pen, int x, int y, bool map) { if (!gps || !pen.valid()) return false; doSetTile(pen, x, y, map); return true; }
void Rectangle(PixelScalar left, PixelScalar top, PixelScalar right, PixelScalar bottom) { DrawFilledRectangle(left, top, right, bottom, brush); if (pen_over_brush()) DrawOutlineRectangle(left, top, right, bottom, pen.GetColor()); }
void DrawLine(PixelScalar ax, PixelScalar ay, PixelScalar bx, PixelScalar by) { ax += x_offset; bx += x_offset; ay += y_offset; by += y_offset; #if SDL_GFXPRIMITIVES_MAJOR > 2 || \ (SDL_GFXPRIMITIVES_MAJOR == 2 && (SDL_GFXPRIMITIVES_MINOR > 0 || \ SDL_GFXPRIMITIVES_MICRO >= 22)) /* thickLineColor() was added in SDL_gfx 2.0.22 */ if (pen.GetWidth() > 1) ::thickLineColor(surface, ax, ay, bx, by, pen.GetWidth(), pen.GetColor().GFXColor()); else #endif ::lineColor(surface, ax, ay, bx, by, pen.GetColor().GFXColor()); }
void line(int ax, int ay, int bx, int by) { ax += x_offset; bx += x_offset; ay += y_offset; by += y_offset; #if SDL_GFXPRIMITIVES_MAJOR > 2 || \ (SDL_GFXPRIMITIVES_MAJOR == 2 && (SDL_GFXPRIMITIVES_MINOR > 0 || \ SDL_GFXPRIMITIVES_MICRO >= 22)) /* thickLineColor() was added in SDL_gfx 2.0.22 */ if (pen.get_width() > 1) ::thickLineColor(surface, ax, ay, bx, by, pen.get_width(), pen.get_color().gfx_color()); else #endif ::lineColor(surface, ax, ay, bx, by, pen.get_color().gfx_color()); }
VOID Cue::draw(Graphics *pGraphics, Pen &rPen, Image &rCue) const { auxiliaryLine_.draw((ball_ - auxiliaryLine_).getX(), (ball_ - auxiliaryLine_).getY(), pGraphics, rPen, static_cast<ARGB>(Color::Gray)); rPen.SetColor(static_cast<ARGB>(Color::Gray)); rPen.SetWidth(3); pGraphics->DrawEllipse(&rPen, static_cast<INT>(mouse_.getX() - RShari), static_cast<INT>(mouse_.getY() - RShari), RShari * 2, RShari * 2); pGraphics->TranslateTransform(static_cast<REAL>(ball_.getX()), static_cast<REAL>(ball_.getY())); pGraphics->RotateTransform(angle_); ImageAttributes imAttr; imAttr.SetColorKey(COLOR_KEY, COLOR_KEY); pGraphics->DrawImage(&rCue, Rect(static_cast<INT>(-884 - force_ * 8), static_cast<INT>(-20 / 2), 884 * 2, 20), 0, 0, 884 * 2, 20, Unit::UnitPixel, &imAttr, 0); pGraphics->ResetTransform(); }
void DrawPolygon(const Point* points, IN INT count, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width) { Pen* myPen; Graphics* myGraphics; myPen = new Pen(clr, width); if(myPen) { myPen->SetDashStyle(dashStyle); myGraphics = new Graphics(hdcPaint); if(myGraphics) { myGraphics->DrawPolygon(myPen, points, count); delete myGraphics; } delete myPen; } }
void DrawLine(const Point &pt1, const Point &pt2, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width) { Pen* myPen; Graphics* myGraphics; myPen = new Pen(clr, width); if(myPen) { myPen->SetDashStyle(dashStyle); myGraphics = new Graphics(hdcPaint); if(myGraphics) { myGraphics->DrawLine(myPen, pt1, pt2); delete myGraphics; } delete myPen; } }
void DrawRect(LPRECT prc, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width) { Pen* myPen; Graphics* myGraphics; myPen = new Pen(clr, width); if(myPen) { myPen->SetDashStyle(dashStyle); myGraphics = new Graphics(hdcPaint); if(myGraphics) { myGraphics->DrawRectangle(myPen, prc->left, prc->top, prc->right - 1 - prc->left, prc->bottom - 1 - prc->top); delete myGraphics; } delete myPen; } }
bool Screen::paintTile(const Pen &pen, int x, int y) { if (!gps || !pen.valid()) return false; auto dim = getWindowSize(); if (x < 0 || x >= dim.x || y < 0 || y >= dim.y) return false; doSetTile(pen, x*dim.y + y); return true; }
void ChartRenderer::DrawLine(const double xmin, const double ymin, const double xmax, const double ymax, const Pen &pen) { if (x.unscaled || y.unscaled) return; assert(pen.IsDefined()); canvas.Select(pen); canvas.DrawLine(ToScreen(xmin, ymin), ToScreen(xmax, ymax)); }
void Canvas::DrawOutlineRectangle(int left, int top, int right, int bottom, const Pen& pen) { SDLRasterCanvas canvas(buffer); const int x1 = left+pen.GetWidth()/2; const int y1 = top+pen.GetWidth()/2; const int x2 = right-(pen.GetWidth()+1)/2; const int y2 = bottom-(pen.GetWidth()+1)/2; canvas.DrawThickLine(x1, y1, x2, y1, pen.GetWidth(), canvas.Import(pen.GetColor()), pen.GetMask()); canvas.DrawThickLine(x1, y2, x2, y2, pen.GetWidth(), canvas.Import(pen.GetColor()), pen.GetMask()); canvas.DrawThickLine(x1, y1, x1, y2, pen.GetWidth(), canvas.Import(pen.GetColor()), pen.GetMask()); canvas.DrawThickLine(x2, y1, x2, y2, pen.GetWidth(), canvas.Import(pen.GetColor()), pen.GetMask()); }
static int screen_readTile(lua_State *L) { int x = luaL_checkint(L, 1); int y = luaL_checkint(L, 2); Pen pen = Screen::readTile(x, y); if (!pen.valid()) { lua_pushnil(L); } else { lua_newtable(L); lua_pushinteger(L, pen.ch); lua_setfield(L, -2, "ch"); lua_pushinteger(L, pen.fg); lua_setfield(L, -2, "fg"); lua_pushinteger(L, pen.bg); lua_setfield(L, -2, "bg"); lua_pushboolean(L, pen.bold); lua_setfield(L, -2, "bold"); if (pen.tile) { lua_pushinteger(L, pen.tile); lua_setfield(L, -2, "tile"); switch (pen.tile_mode) { case Pen::CharColor: lua_pushboolean(L, true); lua_setfield(L, -2, "tile_color"); break; case Pen::TileColor: lua_pushinteger(L, pen.tile_fg); lua_setfield(L, -2, "tile_fg"); lua_pushinteger(L, pen.tile_bg); lua_setfield(L, -2, "tile_bg"); break; default: break; } } } return 1; }
TEST(Pen, DefaultContructor) { Pen pen; EXPECT_EQ(Color::Black, pen.getColor()); EXPECT_EQ(1, pen.getWidth()); EXPECT_EQ(PenStyle::Solid, pen.getStyle()); EXPECT_EQ(PenEndCap::Round, pen.getEndCap()); EXPECT_EQ(PenJoin::Round, pen.getJoin()); }
/** * Basic set / get. */ void testBasicSetGet() { TS_TRACE("Pen basic set get"); Pen p; for (int i = 0; i < 10000; i++) { Pen::Style penmap[3] = {Pen::SOLID, Pen::DASH, Pen::BLANK}; uint8_t refr, refg, refb; refr = rand(); refg = rand(); refb = rand(); Color refc(refr, refg, refb); unsigned refw = lrand48(); Pen::Style refs = penmap[rand() % sizeof(penmap)]; Pen p(refs, refw, refc); TS_ASSERT_EQUALS(p.GetWidth(), refw); Color rc = p.GetColor(); TS_ASSERT_EQUALS(rc.Red(), refr); TS_ASSERT_EQUALS(rc.Green(), refg); TS_ASSERT_EQUALS(rc.Blue(), refb); TS_ASSERT_EQUALS(p.GetStyle(), refs); } }
/** * Basic ctor. */ void testBasicCtor() { TS_TRACE("Pen basic ctor"); Pen p; TS_ASSERT_EQUALS(p.GetWidth(), 1); TS_ASSERT_EQUALS(p.GetColor().Red(), 0); TS_ASSERT_EQUALS(p.GetColor().Green(), 0); TS_ASSERT_EQUALS(p.GetColor().Blue(), 0); TS_ASSERT_EQUALS(p.GetStyle(), Pen::SOLID); }
void Opengl2dPainter::drawBegin(Pen& pen, Matrix3& matrix) { OpenglContext oglcontext(_pPimpl->hdc, _pPimpl->hrc); if (pen.color().a < 255) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE); } glColor4ub( pen.color().r, pen.color().g, pen.color().b, pen.color().a ); _pPimpl->pen = pen; _pPimpl->localMatrix = matrix; glLineWidth( _pPimpl->pen.width()); if (pen.linestyle() != 0xFFFF) { glEnable(GL_LINE_STIPPLE); glLineStipple(1, pen.linestyle()); } Matrix3 selectedMovingMatrix; selectedMovingMatrix.Identity(); // apply matrix Matrix3 m3 = _pPimpl->worldMatrix * selectedMovingMatrix * _pPimpl->localMatrix; FLOAT m[4*4] = {0, }; m[0] = m3.element[0]; m[1] = m3.element[3]; m[2] = 0.0f; m[3] = 0.0f; m[4] = m3.element[1]; m[5] = m3.element[4]; m[6] = 0.0f; m[7] = 0.0f; m[8] = 0.0f; m[9] = 0.0f; m[10] = 1.0f; m[11] = 0.0f; m[12] = m3.element[2]; m[13] = m3.element[5]; m[14] = 0.0f; m[15] = 1.0f; glLoadMatrixf(m); }
bool Screen::fillRect(const Pen &pen, int x1, int y1, int x2, int y2, bool map) { auto dim = getWindowSize(); if (!gps || !pen.valid()) return false; if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0; if (x2 >= dim.x) x2 = dim.x-1; if (y2 >= dim.y) y2 = dim.y-1; if (x1 > x2 || y1 > y2) return false; for (int x = x1; x <= x2; x++) { for (int y = y1; y <= y2; y++) doSetTile(pen, x, y, map); } return true; }
int Opengl2dPainter::listBegin(Pen& pen) { OpenglContext oglcontext(_pPimpl->hdc, _pPimpl->hrc); glColor4ub( pen.color().r, pen.color().g, pen.color().b, pen.color().a ); _pPimpl->pen = pen; glLineWidth( _pPimpl->pen.width()); if (pen.linestyle() != 0xFFFF) { glEnable(GL_LINE_STIPPLE); glLineStipple(1, pen.linestyle()); } glLoadIdentity(); int listid = glGenLists(1); _pPimpl->displaylists.insert( listid); glNewList(listid, GL_COMPILE); return listid; }