本文整理汇总了C++中cairo::RefPtr::user_to_device方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::user_to_device方法的具体用法?C++ RefPtr::user_to_device怎么用?C++ RefPtr::user_to_device使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::user_to_device方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UserToDevice
static void UserToDevice(Cairo::RefPtr<Cairo::Context> cr, int& x, int& y)
{
double d_x = x, d_y = y;
cr->user_to_device(d_x, d_y);
x = Round(d_x), y = Round(d_y);
}
示例2: draw_triangle
void cairo::draw_triangle( const Cairo::RefPtr<Cairo::Context>& cr, const Geodesics::edge_handle& e0 )
{
const rgba_color_t color( .8, .8, .8, .3);
// get edge-free pair
const Geodesics::edge_handle e1 ( e0.next() );
const Geodesics::edge_handle e2 ( e1.next() );
const coord_t e0l= e0.length();
const coord_t e1l= e1.length();
const coord_t e2l= e2.length();
// coordinates of C - using circle-circle intersection ( intersect circle (w.b0,w.d0) with (w.b1,w.d1) )
cairo_coord_t A(0.,0.);
cairo_coord_t B(e0l,0.);
cairo_coord_t C;
boost::tie(C[0],C[1]) = utk::triangulate( e0l, e2l, e1l );
//C[1] = - C[1];
const coord2_t centroid = ( ( coord2_t(e0l, 0) += C ) /= coord_t(3) );
cr->save();
//cr->set_operator( Cairo::OPERATOR_DEST_OVER );
cr->set_source_rgba( color[0], color[1], color[2], color[3] );
cr->save();
// shrink slightly towards centroid
cr->translate( centroid[0], centroid[1] );
cr->scale( .95, .95 );
cr->translate( -centroid[0], -centroid[1] );
//draw triangle
cr->set_line_width( 1. * user_unit_distance( cr ).length() );
draw_half_arrow( cr, A, B );
draw_half_arrow( cr, B, C );
draw_half_arrow( cr, C, A );
cr->restore();
cr->stroke();
cr->restore();
// draw text
cr->save();
cr->user_to_device( A[0], A[1] );
cr->user_to_device( B[0], B[1] );
cr->user_to_device( C[0], C[1] );
cr->set_identity_matrix();
//cr->select_font_face( "Purisa", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL );
cr->set_source_rgba( 0., 0., 0.,.5 );
cr->set_font_size( 8. /* user_unit_distance( cr ).length()*/ );
std::ostringstream nrss;
nrss << e0.source().descriptor();
draw_centered_text( cr, nrss.str(), A );
nrss.str("");
nrss << e1.source().descriptor();
draw_centered_text( cr, nrss.str(), B );
nrss.str("");
nrss << e2.source().descriptor();
draw_centered_text( cr, nrss.str(), C );
cr->restore();
}