本文整理汇总了C++中cairo::RefPtr::rel_line_to方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::rel_line_to方法的具体用法?C++ RefPtr::rel_line_to怎么用?C++ RefPtr::rel_line_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::rel_line_to方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_expose_event
bool CalibrationArea::on_expose_event(GdkEventExpose *event)
{
// check that screensize did not change
if (display_width != get_width() ||
display_height != get_height()) {
set_display_size(get_width(), get_height());
}
Glib::RefPtr<Gdk::Window> window = get_window();
if (window) {
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
cr->save();
cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
cr->clip();
// Print the text
cr->set_font_size(font_size);
double text_height = -1;
double text_width = -1;
Cairo::TextExtents extent;
for (int i = 0; i != help_lines; i++) {
cr->get_text_extents(help_text[i], extent);
text_width = std::max(text_width, extent.width);
text_height = std::max(text_height, extent.height);
}
text_height += 2;
double x = (display_width - text_width) / 2;
double y = (display_height - text_height) / 2 - 60;
cr->set_line_width(2);
cr->rectangle(x - 10, y - (help_lines*text_height) - 10,
text_width + 20, (help_lines*text_height) + 20);
// Print help lines
y -= 3;
for (int i = help_lines-1; i != -1; i--) {
cr->get_text_extents(help_text[i], extent);
cr->move_to(x + (text_width-extent.width)/2, y);
cr->show_text(help_text[i]);
y -= text_height;
}
cr->stroke();
// Draw the points
for (int i = 0; i <= calibrator->get_numclicks(); i++) {
// set color: already clicked or not
if (i < calibrator->get_numclicks())
cr->set_source_rgb(1.0, 1.0, 1.0);
else
cr->set_source_rgb(0.8, 0.0, 0.0);
cr->set_line_width(1);
cr->move_to(X[i] - cross_lines, Y[i]);
cr->rel_line_to(cross_lines*2, 0);
cr->move_to(X[i], Y[i] - cross_lines);
cr->rel_line_to(0, cross_lines*2);
cr->stroke();
cr->arc(X[i], Y[i], cross_circle, 0.0, 2.0 * M_PI);
cr->stroke();
}
// Draw the clock background
cr->arc(display_width/2, display_height/2, clock_radius/2, 0.0, 2.0 * M_PI);
cr->set_source_rgb(0.5, 0.5, 0.5);
cr->fill_preserve();
cr->stroke();
cr->set_line_width(clock_line_width);
cr->arc(display_width/2, display_height/2, (clock_radius - clock_line_width)/2,
3/2.0*M_PI, (3/2.0*M_PI) + ((double)time_elapsed/(double)max_time) * 2*M_PI);
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->stroke();
// Draw the message (if any)
if (message != NULL) {
// Frame the message
cr->set_font_size(font_size);
Cairo::TextExtents extent;
cr->get_text_extents(this->message, extent);
text_width = extent.width;
text_height = extent.height;
x = (display_width - text_width) / 2;
y = (display_height - text_height + clock_radius) / 2 + 60;
cr->set_line_width(2);
cr->rectangle(x - 10, y - text_height - 10,
text_width + 20, text_height + 25);
// Print the message
cr->move_to(x, y);
cr->show_text(this->message);
cr->stroke();
}
cr->restore();
}
//.........这里部分代码省略.........
示例2: DrawPorts
void NodeSurface::DrawPorts(
Cairo::RefPtr<Cairo::Context> refCairo,
TopologyNode* pNode )
{
refCairo->save();
const float k_divisor = 255.0;
float red = 38 / k_divisor;
float green = 199 / k_divisor;
float blue = 38 / k_divisor;
refCairo->set_source_rgb( red, green, blue );
refCairo->set_source_rgb( 0, 0, 0 );
refCairo->set_line_width( 5 );
int numChildren = 0;
for ( unsigned int i=0; i < pNode->GetNumPorts(); i++ )
{
if ( pNode->GetPortType(i) == TopologyNode::CONNECTED_TO_CHILD )
{
numChildren++;
}
}
int childIndex = 0;
for ( unsigned int i=0; i < pNode->GetNumPorts(); i++ )
{
TopologyNode::PortType currPort = pNode->GetPortType(i);
switch (currPort)
{
case TopologyNode::NOT_CONNECTED:
break;
case TopologyNode::CONNECTED_TO_PARENT:
{
refCairo->move_to( sk_nodeWidth/2 - sk_portWidth/2, 0 );
refCairo->rel_line_to( sk_portWidth, 0 );
refCairo->rel_line_to( 0, sk_portHeight );
refCairo->rel_line_to( -sk_portWidth, 0 );
refCairo->fill();
}
break;
case TopologyNode::CONNECTED_TO_CHILD:
{
int startX = (sk_nodeWidth / (numChildren+1)) * (childIndex+1);
refCairo->move_to( startX - sk_portWidth/2, sk_nodeHeight );
refCairo->rel_line_to( sk_portWidth, 0 );
refCairo->rel_line_to( 0, -sk_portHeight );
refCairo->rel_line_to( -sk_portWidth, 0 );
refCairo->fill();
childIndex++;
}
break;
default:
break;
}
}
refCairo->restore();
}
示例3: on_draw
bool graphView::on_draw(const Cairo::RefPtr<Cairo::Context>& cr){
//Get the allocation of our widget, and get the height and width from it
Gtk::Allocation wAllocation = this->get_allocation();
const int wHeight = wAllocation.get_height();
const int wWidth = wAllocation.get_width();
const double lineWidth = wHeight;
//scale the Cario context obj to the current wHeight and wWidth
//cr->scale(wWidth, wHeight);
//now change the offset point coordinates, so point (0,0) will be at (0.5,0.5)
cr->translate(wWidth/2, wHeight/2);
//set the line width to 2 px, this should be a settings for each graph in the futur
cr->set_line_width(1);
//paint the background white
cr->set_source_rgb(1,1,1);
cr->paint();
//draw the coordinatesystem
cr->set_source_rgb(0,0,0);
cr->move_to(0,0);
cr->line_to(wWidth,0);
cr->move_to(0,0);
cr->line_to(0,wHeight);
cr->move_to(0,0);
cr->line_to(-1*wWidth,0);
cr->move_to(0,0);
cr->line_to(0,-1*wHeight);
//draw the axes unit, again this should't be hardcoded in the futur
cr->move_to(0,0);
for(int i = 1; i <= 25; i++)
{
cr->move_to((wWidth*0.5/25)*i,0);
cr->rel_move_to(0, -8);
cr->rel_line_to(0,16);
cr->rel_move_to(0, -8);
cr->move_to((wWidth*0.5/25)*-i,0);
cr->rel_move_to(0, -8);
cr->rel_line_to(0,16);
cr->rel_move_to(0, -8);
}
cr->move_to(0, 0);
for(int i = 1; i <= 25; i++)
{
cr->move_to(0,(wHeight*0.5/25)*i);
cr->rel_move_to(-8,0);
cr->rel_line_to(16,0);
cr->rel_move_to(-8,0);
cr->move_to(0,(wHeight*0.5/25)*-i);
cr->rel_move_to(-8,0);
cr->rel_line_to(16,0);
cr->rel_move_to(-8,0);
}
cr->stroke();
cr->set_source_rgb(0.8,0,0);
if(this->tree)
{
cr->set_line_width(3);
std::vector<equation*> eqs = this->tree->getEquations();
double pxWidth = wWidth/50;
double pxHeight = wHeight/50;
for(int i = 0; i < eqs.size(); i++){
equation *eq = eqs[i];
for(double x = -25; x<= 25; x+= 0.01)
{
double y = eq->getYFromX(x);
cr->move_to(x*pxWidth,-1*(y*pxHeight));
cr->rel_line_to(1,1);
}
cr->stroke();
}
}
return true;
}