本文整理汇总了C++中cairo::RefPtr::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::fill方法的具体用法?C++ RefPtr::fill怎么用?C++ RefPtr::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderLabels
void renderLabels(Cairo::RefPtr<Cairo::Context> cr, std::vector<std::pair<string, FloatPoint> >& toPlace) {
cr->save();
cr->set_source_rgba(0.0, 0.0, 0.0, 0.5);
Cairo::RefPtr<Cairo::ToyFontFace> font = Cairo::ToyFontFace::create(DEFAULT_FONT, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL);
cr->set_font_face(font);
cr->set_font_size(120.0);
cr->set_line_width(2.0);
Cairo::TextExtents textSize;
std::list<shared_ptr<Label> > labels;
int i = 0;
std::vector<shared_ptr<Style>> styles;
for (auto& pair : toPlace)
{
string& text = pair.first;
cr->get_text_extents(text, textSize);
shared_ptr<Style> s = boost::make_shared<Style>();
s->text = text;
styles.push_back(s);
FloatPoint center = pair.second + FloatPoint(textSize.width/2.0, textSize.height/2.0);
FloatRect owner = FloatRect(center.x, center.y, center.x, center.y);
FloatPoint origin = pair.second - FloatPoint(textSize.x_bearing, textSize.y_bearing);
shared_ptr<Label> l = boost::make_shared<Label>(FloatRect(pair.second, textSize.width, textSize.height), owner, s->text, s.get(), origin);
cr->rectangle(l->box.minX, l->box.minY, l->box.getWidth(), l->box.getHeight());
cr->stroke();
labels.push_back(l);
}
std::vector<shared_ptr<Label> > placed;
placeLabels(labels, placed);
for (auto& l: placed)
{
cr->set_source_rgba(0.0, 0.0, 0.0, 1.0);
cr->move_to(l->box.minX, l->box.maxY);
cr->show_text(l->style->text.str());
cr->fill();
cr->set_source_rgba(1.0, 0.0, 0.0, 0.5);
cr->rectangle(l->box.minX, l->box.minY, l->box.getWidth(), l->box.getHeight());
cr->fill();
}
cr->restore();
}
示例2: on_expose_event
bool TrackOutput::on_expose_event(GdkEventExpose* event)
{
// This is where we draw on the window
Glib::RefPtr<Gdk::Window> window = get_window();
if(window) // Only run if Window does exist
{
// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->set_source_rgb(0.1 , 0.1 , 0.1 );
cr->fill();
TrackOutputState* state = &stateStore->trackoutputState.at(ID);
if ( state->selected )
setColour(cr, COLOUR_GREY_3 );
else
setColour(cr, COLOUR_GREY_4 );
cr->rectangle(0, 0, 74, 102);
cr->fill();
Dial(cr,true, 7,4,state->pan,DIAL_MODE_PAN); // pan
Mute(cr, 9 , 41 , state->ID, state->mute ); // mute button
Solo(cr, 9 , 68 , state->ID, state->solo ); // solo button
Rec (cr, 9 , 85 , state->ID, state->recEnable); // rec button
Fader(cr,46 , 4 , state->volume, state->rms, state->falloff ); // fader
if ( state->selected )
{
cr->rectangle(0, -10, 74, 200);
setColour( cr, COLOUR_PURPLE_1 );
cr->set_line_width(1);
cr->stroke();
}
}
return true;
}
示例3: draw
void Anchor::draw(const Cairo::RefPtr<Cairo::Context>& context) const
{
context->save();
context->move_to(mX,mY);
context->set_source_rgb(0., 1., 0.);
context->rectangle(mX, mY, ANCHOR_WIDTH, ANCHOR_HEIGHT);
context->fill();
context->restore();
}
示例4: draw
void DependencyArrow::draw(const Cairo::RefPtr<Cairo::Context>& context) const
{
// the way to compute the (tcx, tcy) single control point of the
// quadratic
double dX = mControlPoint.getX() - mOrigin->getX();
double dY = mControlPoint.getY() - mOrigin->getY();
double d1 = std::sqrt(dX * dX + dY * dY);
double d = d1;
dX = mDestination->getX() - mControlPoint.getX();
dY = mDestination->getY() - mControlPoint.getY();
d += std::sqrt(dX * dX + dY * dY);
double t = d1/d;
double t1 = 1.0 - t;
double tSq = t * t;
double denom = 2.0 * t * t1;
double tcx = (mControlPoint.getX() - t1 * t1 * mOrigin->getX() -
tSq * mDestination->getX()) / denom;
double tcy = (mControlPoint.getY() - t1 * t1 * mOrigin->getY() -
tSq * mDestination->getY()) / denom;
// from the single point of the quadratic to the both of the cubic
double tcxq1 = mOrigin->getX() + 2. * (tcx - mOrigin->getX()) / 3.;
double tcyq1 = mOrigin->getY() + 2. * (tcy - mOrigin->getY()) / 3.;
double tcxq2 = mDestination->getX() +
2. * (tcx - mDestination->getX()) / 3.;
double tcyq2 = mDestination->getY() +
2. * (tcy - mDestination->getY()) / 3.;
// and now to draw,
std::valarray< double > dashes(2);
double angle = atan2 (mDestination->getY() - tcyq2,
mDestination->getX() - tcxq2) + M_PI;
double x1 = mDestination->getX() + 9 * std::cos(angle - 0.35);
double y1 = mDestination->getY() + 9 * std::sin(angle - 0.35);
double x2 = mDestination->getX() + 9 * std::cos(angle + 0.35);
double y2 = mDestination->getY() + 9 * std::sin(angle + 0.35);
dashes[0] = 8.0;
dashes[1] = 3.0;
context->save();
context->set_line_width(1);
context->move_to(mDestination->getX(), mDestination->getY());
context->line_to(x1,y1);
context->line_to(x2,y2);
context->line_to(mDestination->getX(), mDestination->getY());
context->fill();
context->set_dash(dashes,0.);
context->move_to(mOrigin->getX(), mOrigin->getY());
context->curve_to(tcxq1, tcyq1, tcxq2, tcyq2, mDestination->getX(),
mDestination->getY());
context->stroke();
context->restore();
}
示例5: draw_background
void Simple_GOL_Area::draw_background(const Cairo::RefPtr<Cairo::Context>& cr)
{
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
cr->set_source_rgb(0,0,0);
cr->rectangle(0, 0, width, height);
cr->fill();
}
示例6: dibujarArco
void GraficoDeTorta::dibujarArco(const Cairo::RefPtr<Cairo::Context>& c,int x, int y, int radio, float angulo0, float angulo1,float r, float g, float b){
c->set_source_rgb(1,1,1);
c->set_line_width(2);
c->arc(x,y,radio, angulo0, angulo1);
c->line_to(x,y);
c->close_path();
c->stroke_preserve();
c->set_source_rgb(r,g,b);
c->fill();
}
示例7: draw_node
void ListNode::draw_node(const Cairo::RefPtr<Cairo::Context> & cr, int x, int y) {
cr->rectangle(x, y, field_w, field_h * numFields);
cr->fill();
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->set_line_width(2.0);
for (int i = 0; i < numFields; i++) {
cr->rectangle(x, y + (i * field_h), field_w, field_h);
cr->stroke();
}
}
示例8: draw_bar
// ----------------------------------------------------------------------------
// -- Function : draw_bar(cr)
// --
// -- Takes : cr = point to a cairo reference
// --
// -- Purpose : Assumes value is already between 1 and 0! Draws the bar
// on the provided cairo reference.
void BarWidget::draw_bar(Cairo::RefPtr<Cairo::Context> cr)
{
// Get our bar coords
Size size = get_avail_rect();
Size* s = &size;
// Draw the bg first
cr->set_line_width(bar_bg_border_width);
cr->rectangle(s->x, s->y, s->width, s->height);
// -- bg border
if (draw_bar_bg_border)
{
bar_bg_border_color->set_source(cr);
cr->stroke_preserve();
}
// -- bg
if (draw_bar_bg)
{
bar_bg_color->set_source(cr);
cr->fill_preserve();
}
// Clear the path
cr->begin_new_path();
// -- Now we're drawing the value bar
// Modify the size by our value / percent
// If we're horz, modify the width.
// If we're vert, modify the height.
if (vertical)
s->height = s->height * m_value;
else
s->width = s->width * m_value;
// New path, draw!
cr->set_line_width(bar_border_width);
cr->rectangle(s->x, s->y, s->width, s->height);
// -- bar border
if (draw_bar_border)
{
bar_border_color->set_source(cr);
cr->stroke_preserve();
}
// -- Draw the bar
bar_color->set_source(cr);
cr->fill();
// clean up
cr->begin_new_path();
s = nullptr;
}
示例9: on_draw
bool MyArea_private::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
if (pixbuf == 0) return false;
cr->set_source_rgba(0xff, 0xff, 0xff, 0xff);
cr->rectangle(0, 0, 800, 640);
cr->fill();
Gdk::Cairo::set_source_pixbuf(cr, pixbuf);
cr->paint();
cr->stroke();
return true;
}
示例10: drawButton
void ItemView::drawButton(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Image* image, Gdk::Rectangle rect)
{
const Glib::RefPtr<Gdk::Pixbuf> icon = image->get_pixbuf();
const int iconLeft = rect.get_x() + (rect.get_width() * 0.5) - (icon->get_width() * 0.5);
const int iconTop = rect.get_y() + (rect.get_height() * 0.5) - (icon->get_height() * 0.5);
Gdk::Cairo::set_source_pixbuf(cr, icon, iconLeft, iconTop);
cr->rectangle(iconLeft, iconTop, icon->get_width(), icon->get_height());
cr->fill();
}
示例11: update_canvas
void HelloWorld::update_canvas(Cairo::RefPtr<Cairo::Context> &context) {
alc_allocation = ara_canvas.get_allocation();
int width = alc_allocation.get_width();
int height = alc_allocation.get_height();
cout << "width: " << width << ", height: " << height << endl;
context->save();
context->set_source_rgba(0, level, 0, 1);
context->scale(width, height);
context->rectangle(0, 0, 1, 1);
context->fill();
context->restore();
}
示例12: draw
void Rect::draw(Cairo::RefPtr<Cairo::Context> cr, int x, int y)
{
//draw a Rectangle centered on (x, y)
int w_2 = width/2;
int h_2 = height/2;
cr->save();
cr->rectangle(x - w_2, y - h_2, width, height);
cr->set_source_rgba(color->getRed(), color->getGreen(), color->getBlue(), 1.0); //opaque
cr->fill();
cr->restore();
}
示例13: on_expose_event
bool on_expose_event(GdkEventExpose* ev ){
Glib::RefPtr< Gdk::Window > v = get_window();
if (v) {
Cairo::RefPtr< Cairo::Context > ctx = v->create_cairo_context();
Gtk::Allocation alloc = get_allocation();
const int altura = alloc.get_height();
const int ancho = alloc.get_width();
ctx->set_source_rgb(0.3, 0.1, 0.4);
ctx->scale(ancho, altura);
ctx->rectangle(1.0 / 2.0, 1.0 / 4.0, 1.0 / 5.0, 1.0 / 5.0);
ctx->fill();
}
return true;
}
示例14: FillBackground
void NodeSurface::FillBackground(
Cairo::RefPtr<Cairo::Context> refCairo,
double red,
double green,
double blue )
{
// Get width / height of surface
int surfaceWidth = m_surface->get_width();
int surfaceHeight = m_surface->get_height();
refCairo->set_source_rgb( red, green, blue );
refCairo->rectangle( 0, 0, surfaceWidth, surfaceHeight );
refCairo->fill();
}
示例15: if
void BezierPath::Invocation::draw(const Cairo::RefPtr<Cairo::Context> & cr)
{
if (!path) return;
//Execute the bezier path.
path->execute(cr);
//Stroke, fill or do both.
if (stroke && fill) {
cr->fill_preserve();
cr->stroke();
}
else if (stroke) cr->stroke();
else if (fill) cr->fill();
}