void Graphics::FillEllipse(Brush* brush, const RectF& rc) { cairo_t* cg = reinterpret_cast<cairo_t*>(_private); cairo_save(cg); cairo_pattern_t* cp = reinterpret_cast<cairo_pattern_t*>(brush->_private); cairo_set_source(cg, cp); cairo_save(cg); cairo_translate(cg, rc.GetLeft() + rc.GetWidth() / 2.0, rc.GetTop() + rc.GetHeight() / 2.0); cairo_scale(cg, 1.0 / (rc.GetHeight() / 2.), 1.0 / (rc.GetWidth() / 2.0)); cairo_arc(cg, 0.0, 0.0, 1.0, 0.0, 2 * 3.14159); cairo_restore(cg); cairo_fill(cg); cairo_restore(cg); }
void Graphics::FillRectangle(Brush* brush, const RectF& rc) { cairo_t* cg = reinterpret_cast<cairo_t*>(_private); cairo_save(cg); cairo_pattern_t* cp = reinterpret_cast<cairo_pattern_t*>(brush->_private); cairo_set_source(cg, cp); cairo_translate(cg, rc.GetLeft(), rc.GetTop()); cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight()); cairo_fill(cg); cairo_restore(cg); }
void Graphics::DrawImage(Image* image, const RectF& rc, const ImageAttributes* attr) { cairo_t* cg = reinterpret_cast<cairo_t*>(_private); cairo_surface_t* source = reinterpret_cast<cairo_surface_t*>(image->_private); cairo_pattern_t* cp = cairo_pattern_create_for_surface(source); int sourceWidth = cairo_image_surface_get_width(source); int sourceHeight = cairo_image_surface_get_height(source); cairo_matrix_t patternMatrix; cairo_matrix_init_scale(&patternMatrix, sourceWidth/rc.GetWidth(), sourceHeight/rc.GetHeight()); cairo_pattern_set_matrix(cp, &patternMatrix); cairo_save(cg); cairo_set_source(cg, cp); cairo_translate(cg, rc.GetLeft(), rc.GetTop()); cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight()); cairo_fill(cg); cairo_restore(cg); cairo_pattern_destroy(cp); }
void Graphics::DrawRectangle(Pen* pen, const RectF& rc) { cairo_t* cg = reinterpret_cast<cairo_t*>(_private); cairo_save(cg); PenPrivate* pp = reinterpret_cast<PenPrivate*>(pen->_private); cairo_pattern_t* cp = pp->pattern; cairo_set_source(cg, cp); cairo_set_line_width(cg, pp->width); cairo_translate(cg, rc.GetLeft(), rc.GetTop()); cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight()); cairo_stroke(cg); cairo_restore(cg); }
void Graphics::FillRoundRectangle(Brush* brush, const RectF& rc, float d) { Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private); Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private); Gdiplus::GraphicsPath gp; Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight()); gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f); gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f); gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f); gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f); gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f); g->FillPath(gdiBrush, &gp); }
void Graphics::DrawRoundRectangle(Pen* pen, const RectF& rc, float d) { Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private); Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private); Gdiplus::GraphicsPath gp; Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight()); gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f); gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f); gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f); gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f); gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f); g->DrawPath(gdiPen, &gp); }
void Actor::StretchTo( const RectF &r ) { // width and height of rectangle float width = r.GetWidth(); float height = r.GetHeight(); // center of the rectangle float cx = r.left + width/2.0f; float cy = r.top + height/2.0f; // zoom fActor needed to scale the Actor to fill the rectangle float fNewZoomX = width / m_size.x; float fNewZoomY = height / m_size.y; SetXY( cx, cy ); SetZoomX( fNewZoomX ); SetZoomY( fNewZoomY ); }
void Graphics::DrawImage(Image* image, const RectF& rc, const ImageAttributes* attr) { Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private); Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(image->_private); if(attr!=0) { Gdiplus::ImageAttributes* ia = reinterpret_cast<Gdiplus::ImageAttributes*>(attr->_private); g->DrawImage(gdiImage, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), 0.0f, 0.0f, (float)gdiImage->GetWidth(), (float)gdiImage->GetHeight(), Gdiplus::UnitPixel, ia); } else { g->DrawImage(gdiImage, ToGDIRect<RectF, Gdiplus::RectF>(rc)); } }
void Graphics::FillPie(Brush* brush, const RectF& rc, float start, float sweep) { Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private); Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private); g->FillPie(gdiBrush, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), start, sweep); }
void Graphics::DrawPie(Pen* pen, const RectF& rc, float start, float sweep) { Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private); Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private); g->DrawPie(gdiPen, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), start, sweep); }