当前位置: 首页>>代码示例>>C++>>正文


C++ RefPtr::stroke_preserve方法代码示例

本文整理汇总了C++中cairo::RefPtr::stroke_preserve方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::stroke_preserve方法的具体用法?C++ RefPtr::stroke_preserve怎么用?C++ RefPtr::stroke_preserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cairo::RefPtr的用法示例。


在下文中一共展示了RefPtr::stroke_preserve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:darylbutler,项目名称:sysmon,代码行数:61,代码来源:bar_widget.cpp

示例2: font_desc

void
Operation::draw_patient_info(const Glib::RefPtr<Gtk::PrintContext>& print)
{
	Cairo::RefPtr<Cairo::Context> cairo = print->get_cairo_context();

	Glib::RefPtr<Pango::Layout> layout = print->create_pango_layout();

	Pango::FontDescription font_desc("sans 12");
	layout->set_font_description(font_desc);

	layout->set_width(width_ * Pango::SCALE);

	DICOM::SummaryInfo* info = const_cast<DICOM::SummaryInfo*>(&dicom_info_);
	DICOM::PatientInfo* patient = info->get_patient_info();

	//Set and mark up the text to print:
	Glib::ustring marked_up_form_text;
	Glib::ustring txt = DICOM::format_person_name(patient->get_name());
	marked_up_form_text += "<b>Patient's name</b>: " + txt + "\n";
	marked_up_form_text += "<b>Sex</b>: " + info->get_patient_sex() + "\n";

	DICOM::PatientAge age = info->get_patient_age();
	marked_up_form_text += "<b>Age</b>: " + age.age_string() + "\n\n";

	layout->set_markup(marked_up_form_text);
	layout->show_in_cairo_context(cairo);

	int w, h;
	layout->get_pixel_size( w, h);
	cairo->rel_move_to( 0, h);
	cairo->stroke_preserve();
}
开发者ID:MichaelColonel,项目名称:ScanAmatiTest,代码行数:32,代码来源:operation.cpp

示例3: 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();
}
开发者ID:horacioMartinez,项目名称:facultad,代码行数:10,代码来源:graficoDeTorta.cpp

示例4:

void
Operation::draw_title(const Glib::RefPtr<Gtk::PrintContext>& print)
{
	double pos_x, pos_y;

	Cairo::RefPtr<Cairo::Context> cairo = print->get_cairo_context();

	DICOM::SummaryInfo* info = const_cast<DICOM::SummaryInfo*>(&dicom_info_);
	DICOM::StudyInfo* study = info->get_study_info();

	// Show Institution Name
	cairo->set_font_size(title_font_size_);
	Cairo::TextExtents cur_ext, prev_ext;
	cairo->get_text_extents( study->get_institution_name(), cur_ext);

	pos_x = (width_ - cur_ext.width) / 2.;
	pos_y = cur_ext.height + OFFSET;
	cairo->move_to( pos_x, pos_y);
	cairo->show_text(study->get_institution_name());

	// Show Institution Address
	prev_ext = cur_ext;
	cairo->set_font_size(subtitle_font_size_);
	cairo->get_text_extents( study->get_institution_address(), cur_ext);

	pos_x = -(prev_ext.width + prev_ext.x_bearing +
		cur_ext.width + cur_ext.x_bearing) / 2.;
	pos_y = cur_ext.height + OFFSET;
	cairo->rel_move_to( pos_x, pos_y);
	cairo->show_text(study->get_institution_address());

	// Show Study Description
	prev_ext = cur_ext;
	cairo->set_font_size(title_font_size_);
	cairo->get_text_extents( study->get_description(), cur_ext);

	pos_x = -(prev_ext.width + prev_ext.x_bearing +
		cur_ext.width + cur_ext.x_bearing) / 2.;
	pos_y = cur_ext.height + OFFSET;
	cairo->rel_move_to( pos_x, pos_y);
	cairo->show_text(study->get_description());


	pos_x = -(width_ + cur_ext.width) / 2.;
	pos_y = cur_ext.height + OFFSET;
	cairo->rel_move_to( pos_x, pos_y);

	cairo->stroke_preserve();
}
开发者ID:MichaelColonel,项目名称:ScanAmatiTest,代码行数:49,代码来源:operation.cpp

示例5: renderShields

//! Only renders the shield background, the text is rendered in renderLabels
void Renderer::renderShields(const Cairo::RefPtr<Cairo::Context>& cr,
							 std::vector<shared_ptr<Shield> >& shields) const
{
	cr->save();

	cr->set_line_join(Cairo::LINE_JOIN_ROUND);

	for (auto& shield : shields)
	{
		const Style* s = shield->style;

		double x0, y0, height, width;
		double border = ceil(s->shield_frame_width/2.0 + s->shield_casing_width);
		x0 = shield->shield.minX + border;
		y0 = shield->shield.minY + border;
		width = shield->shield.getWidth() - 2*border;
		height = shield->shield.getHeight() - 2*border;
		if ((int) s->shield_frame_width % 2 == 1) {
			x0 -= 0.5;
			y0 -= 0.5;
		}
		if (s->shield_shape == Style::ShieldShape::ROUNDED) {
			cr->arc(x0 + height/2.0, y0 + height/2.0,
					height/2.0, boost::math::constants::pi<double>()/2.0, 3.0*boost::math::constants::pi<double>()/2.0);
			cr->arc(x0 + width - height/2.0, y0 + height/2.0,
					height/2.0, 3.0*boost::math::constants::pi<double>()/2.0, boost::math::constants::pi<double>()/2.0);
			cr->close_path();
		} else
			cr->rectangle(x0, y0, width, height);

		// shield casing
		if (s->shield_casing_width > 0) {
			cr->set_source_color(s->shield_casing_color),
			cr->set_line_width(s->shield_frame_width + s->shield_casing_width * 2.0);
			cr->stroke_preserve();
		}

		// shield background
		cr->set_source_color(s->shield_color),
		cr->fill_preserve();

		// shield frame
		cr->set_source_color(s->shield_frame_color),
		cr->set_line_width(s->shield_frame_width);
		cr->stroke();
	}

	cr->restore();
}
开发者ID:jorik041,项目名称:alacarte,代码行数:50,代码来源:renderer.cpp

示例6:

bool level_editor::tileset_display::on_expose_event(GdkEventExpose* event) {
  Glib::RefPtr<Gdk::Window> window = get_window();

  if (!window || !m_surface)
    return true;

  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->set_source(m_surface, 0, 0);
  cr->paint();

  // Show selection rectangle when we are selecting
  if (m_selecting
      || ((m_select_x != m_select_end_x || m_select_y != m_select_end_y)
          && m_preferences.sticky_tile_selection)) {
    const int x = std::min(m_select_x, m_select_end_x) * m_tile_width;
    const int y = std::min(m_select_y, m_select_end_y) * m_tile_height;

    const int w = (std::abs(m_select_x - m_select_end_x))
                    * m_tile_width;
    const int h = (std::abs(m_select_y - m_select_end_y))
                    * m_tile_height;

    cr->save();
      cr->rectangle(x, y, w, h);
      // TODO: move selection color somewhere else (preferences?)
      cr->set_source_rgb(0.7, 1, 1);
      if (m_preferences.selection_background) {
        cr->stroke_preserve();
        cr->set_source_rgba(0.7, 1, 0, 0.2);
        cr->fill();
      } else {
        cr->stroke();
      }
    cr->restore();
  }

  return true;
}
开发者ID:bjorn,项目名称:graal-gonstruct,代码行数:41,代码来源:tileset_display.cpp

示例7: draw

/**
 * Draws a curve for the speed graph.
 */
void GtkGraph::draw(std::queue<double> q, double height, double increment, double maxValue, const Cairo::RefPtr<Cairo::Context>& cr)
{
	// wizards use computers
	// computers use numbers
	// no magic
	
	double offset = increment * (m_displaySize - q.size());

	cr->move_to(0, height);
	for(unsigned i = 0; i< (m_displaySize - q.size());++i)
		cr->line_to(i*increment, height);


	double oldy;
	if(q.empty()) return;

	oldy = height - (q.front() * height / maxValue);
	cr->line_to(offset, oldy);
	q.pop();
	double x = increment + offset;
	while(!q.empty())
	{
		double y = height - (q.front() * height / maxValue);
		cr->curve_to(x - increment/2, oldy, x - increment/2, y, x, y);
		q.pop();
		oldy = y;
		x += increment;
	}

	if(gt::Settings::settings["GraphStyle"] == "Fill")
	{
		cr->stroke_preserve();
		Gdk::Cairo::set_source_rgba(cr, Gdk::RGBA(gt::Settings::settings[(upl) ? "GraphUploadFillColor" : "GraphDownloadFillColor"]));
		cr->line_to(x - increment, height);
		cr->line_to(0,height);
		auto k = Gdk::RGBA(gt::Settings::settings[(upl) ? "GraphUploadFillColor" : "GraphDownloadFillColor"]);
		cr->set_source_rgba(k.get_red(), k.get_green(), k.get_blue(), k.get_alpha() * 0.5);
		cr->fill();
	}
	else cr->stroke();
}
开发者ID:Quaker762,项目名称:gtorrent-gtk,代码行数:44,代码来源:GtkGraph.cpp

示例8: renderLabels

void Renderer::renderLabels(const Cairo::RefPtr<Cairo::Context>& cr,
							std::vector<shared_ptr<LabelType> >& labels,
							AssetCache& cache) const
{
	cr->save();

	cr->set_line_join(Cairo::LINE_JOIN_ROUND);

	for (auto it = labels.rbegin(); it != labels.rend(); it++)
	{
		const shared_ptr<LabelType>& label = *it;
		const Style* s = label->style;

		cr->set_font_size(s->font_size);

		cr->move_to(label->origin.x, label->origin.y);

		cr->set_font_face(cache.getFont(
					s->font_family.str(),
					s->font_style == Style::STYLE_ITALIC ? Cairo::FONT_SLANT_ITALIC : Cairo::FONT_SLANT_NORMAL,
					s->font_weight == Style::WEIGHT_BOLD ? Cairo::FONT_WEIGHT_BOLD : Cairo::FONT_WEIGHT_NORMAL
				));

		cr->text_path(label->text.str());

		if (s->text_halo_radius > 0.0)
		{
			cr->set_source_color(s->text_halo_color);
			cr->set_line_width(s->text_halo_radius*2.0);
			cr->stroke_preserve();
		}

		cr->set_source_color(s->text_color);
		cr->fill();
	}

	cr->restore();
}
开发者ID:jorik041,项目名称:alacarte,代码行数:38,代码来源:renderer.cpp

示例9: printTileId

//! Debug function that prints identifier on the tile
void Renderer::printTileId(const Cairo::RefPtr<Cairo::Context>& cr,
						   const shared_ptr<TileIdentifier>& id) const
{
	cr->save();

	cr->set_font_size(10);
	cr->move_to(5.0, TILE_SIZE - 10);

	std::ostringstream labelstrm;
	labelstrm << "X: " << id->getX() << " Y: " << id->getY();
	labelstrm << " Zoom: " << id->getZoom();
	labelstrm << " Style: " << id->getStylesheetPath();
	std::string label = labelstrm.str();
	cr->text_path(label.c_str());

	cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
	cr->set_line_width(2.0);
	cr->stroke_preserve();
	cr->set_source_rgba(0.0, 0.0, 0.0, 1.0);
	cr->fill();

	cr->restore();
}
开发者ID:jorik041,项目名称:alacarte,代码行数:24,代码来源:renderer.cpp

示例10: test__

void area___::test__(){
	int width, height;
	width=da_->get_allocation().get_width();
	height=da_->get_allocation().get_height();

	double m_radius=0.42;
	double m_line_width=0.05;

	// scale to unit square and translate (0, 0) to be (0.5, 0.5), i.e.
	// the center of the window
	cr_->scale(width, height);
	cr_->translate(0.5, 0.5);
	cr_->set_line_width(m_line_width);

	cr_->save();
	cr_->set_source_rgba(0.337, 0.612, 0.117, 0.9);   // green
	cr_->paint();
	cr_->restore();
	cr_->arc(0, 0, m_radius, 0, 2 * M_PI);
	cr_->save();
	cr_->set_source_rgba(1.0, 1.0, 1.0, 0.8);
	cr_->fill_preserve();
	cr_->restore();
	cr_->stroke_preserve();
	cr_->clip();

	//clock ticks
	for (int i = 0; i < 12; i++)
	{
		double inset = 0.05;

		cr_->save();
		cr_->set_line_cap(Cairo::LINE_CAP_ROUND);

		if(i % 3 != 0)
		{
			inset *= 0.8;
			cr_->set_line_width(0.03);
		}

		cr_->move_to(
				(m_radius - inset) * cos (i * M_PI / 6),
				(m_radius - inset) * sin (i * M_PI / 6));
		cr_->line_to (
				m_radius * cos (i * M_PI / 6),
				m_radius * sin (i * M_PI / 6));
		cr_->stroke();
		cr_->restore(); // stack-pen-size
	}

	// store the current time
	time_t rawtime;
	time(&rawtime);
	struct tm * timeinfo = localtime (&rawtime);

	// compute the angles of the indicators of our clock
	double minutes = timeinfo->tm_min * M_PI / 30;
	double hours = timeinfo->tm_hour * M_PI / 6;
	double seconds= timeinfo->tm_sec * M_PI / 30;
	cout<<timeinfo->tm_min<<","<<timeinfo->tm_hour<<","<<timeinfo->tm_sec<<endl;

	cr_->save();
	cr_->set_line_cap(Cairo::LINE_CAP_ROUND);

	// draw the seconds hand
	cr_->save();
	cr_->set_line_width(m_line_width / 3);
	cr_->set_source_rgba(0.7, 0.7, 0.7, 0.8); // gray
	cr_->move_to(0, 0);
	cr_->line_to(sin(seconds) * (m_radius * 0.9),
			-cos(seconds) * (m_radius * 0.9));
	cr_->stroke();
	cr_->restore();

	// draw the minutes hand
	cr_->set_source_rgba(0.117, 0.337, 0.612, 0.9);   // blue
	cr_->move_to(0, 0);
	cr_->line_to(sin(minutes + seconds / 60) * (m_radius * 0.8),
			-cos(minutes + seconds / 60) * (m_radius * 0.8));
	cr_->stroke();

	// draw the hours hand
	cr_->set_source_rgba(0.337, 0.612, 0.117, 0.9);   // green
	cr_->move_to(0, 0);
	cr_->line_to(sin(hours + minutes / 12.0) * (m_radius * 0.5),
			-cos(hours + minutes / 12.0) * (m_radius * 0.5));
	cr_->stroke();
	cr_->restore();

	// draw a little dot in the middle
	cr_->arc(0, 0, m_line_width / 3.0, 0, 2 * M_PI);
	cr_->fill();
}
开发者ID:zzzzzzzzzzz0,项目名称:zhscript,代码行数:93,代码来源:huitu___.cpp

示例11: stroke_preserve__

	void stroke_preserve__(){
		cr_->stroke_preserve();
	}
开发者ID:zzzzzzzzzzz0,项目名称:zhscript,代码行数:3,代码来源:huitu___.cpp

示例12: generate

void OutputFile::generate() {
    unsigned E=es.size();
    bool cleanupRoutes=false;
    if(routes==NULL) {
        cleanupRoutes=true;
        routes = new vector<straightener::Route*>(E);
        for(unsigned i=0;i<E;i++) {
            straightener::Route* r=new straightener::Route(2);
            r->xs[0]=rs[es[i].first]->getCentreX();
            r->ys[0]=rs[es[i].first]->getCentreY();
            r->xs[1]=rs[es[i].second]->getCentreX();
            r->ys[1]=rs[es[i].second]->getCentreY();
            (*routes)[i]=r;
        }
    }

#if defined (CAIRO_HAS_SVG_SURFACE) && defined (CAIRO_HAS_PDF_SURFACE)
    double width,height,r=2;
    if(rects) r=rs[0]->width()/2;
    double xmin=DBL_MAX, ymin=xmin;
    double xmax=-DBL_MAX, ymax=xmax;
    for (unsigned i=0;i<rs.size();i++) {
        double x=rs[i]->getCentreX(), y=rs[i]->getCentreY();
        xmin=min(xmin,x);
        ymin=min(ymin,y);
        xmax=max(xmax,x);
        ymax=max(ymax,y);
    }
    xmax+=2*r;
    ymax+=2*r;
    xmin-=2*r;
    ymin-=2*r;
    width=xmax-xmin;
    height=ymax-ymin;

    Cairo::RefPtr<Cairo::Context> cr;
    openCairo(cr,width,height);

    /* set background colour
    cr->save(); // save the state of the context
    cr->set_source_rgb(0.86, 0.85, 0.47);
    cr->paint();    // fill image with the color
    cr->restore();  // color is back to black now
    */

    cr->set_line_width(1.);
    cr->set_font_size(8);
    cr->save();
    if(rc) for(Clusters::const_iterator c=rc->clusters.begin();c!=rc->clusters.end();c++) {
        draw_cluster_boundary(cr,**c,xmin,ymin);
    }
    if(curvedEdges)
        draw_curved_edges(cr,es,xmin,ymin);
    else 
        draw_edges(cr,*routes,xmin,ymin);
    Cairo::TextExtents te;
    for (unsigned i=0;i<rs.size();i++) {
        if(!rects) {
            double x=rs[i]->getCentreX()-xmin, y=rs[i]->getCentreY()-ymin;
            cr->arc(x,y,r, 0.0, 2.0 * M_PI);
            cr->fill();
        } else {
            double x=rs[i]->getMinX()-xmin+0.5, y=rs[i]->getMinY()-ymin+0.5;
            std::string str;
            if(labels.size()==rs.size()) {
                str=labels[i];
            } else {
                std::stringstream s; s<<i;
                str=s.str();
            }
            cr->get_text_extents(str,te);
            /*
            double llx = x-te.width/2.-1;
            double lly = y-te.height/2.-1;
            cr->rectangle(llx,lly,te.width+2,te.height+2);
            */
            cr->rectangle(x,y,
                    rs[i]->width()-1,rs[i]->height()-1);
            cr->stroke_preserve();
            cr->save();
            cr->set_source_rgba(245./255., 233./255., 177./255., 0.6);
            cr->fill();
            cr->restore();
            if(labels.size()==rs.size()) {
                cr->move_to(x-te.x_bearing+te.width/2.,y-te.y_bearing+te.height/2.);
                cr->show_text(str);
            }
            cr->stroke();
        }
    }

    cr->show_page();

    std::cout << "Wrote file \"" << fname << "\"" << std::endl;

#else
    std::cout << 
            "WARNING: cola::OutputFile::generate(): No SVG file produced." <<
            std::endl <<
            "         You must have cairomm (and cairo with SVG support) " <<
//.........这里部分代码省略.........
开发者ID:amolenaar,项目名称:adaptagrams,代码行数:101,代码来源:output_svg.cpp

示例13: on_expose_event

bool CPagePreview::on_expose_event(GdkEventExpose *event)
	{
	std::cout << "Fired!\n";
			
	Glib::RefPtr<Gdk::Window> window = get_window();
	if(window)
		{
		// get the cairo context amd allocation
		Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
		Gtk::Allocation allocation = get_allocation();
		const int width = allocation.get_width();
		const int height = allocation.get_height();
		
		// coordinates for the center of the window
		int xc, yc;
		xc = width / 2;
		yc = height / 2;

		
		// clip to the area indicated by the expose event so that we only redraw
		// the portion of the window that needs to be redrawn
		cr->rectangle(event->area.x, event->area.y,
				event->area.width, event->area.height);
		cr->clip();
		
		double border = 0.05;
		double offset = 2.0;
		
		// draw a neat shadow
		cr->set_source_rgba(0.0,0.0,0.0,0.4);
		cr->begin_new_path();
		cr->move_to( width*border+offset,height*border+offset );
		cr->line_to( width*(1.0-border)+offset,height*border+offset );
		cr->line_to( width*(1.0-border)+offset,height*(1.0-border)+offset );
		cr->line_to( width*border+offset,height*(1.0-border)+offset );
		cr->close_path();
		cr->fill();

		// draw the page outline
		cr->set_source_rgb(0.0,0.0,0.0); // black
		cr->set_line_width( 1.0 );
		cr->begin_new_sub_path();
		cr->move_to( width*border-offset,height*border-offset );
		cr->line_to( width*(1.0-border)-offset,height*border-offset );
		cr->line_to( width*(1.0-border)-offset,height*(1.0-border)-offset );
		cr->line_to( width*border-offset,height*(1.0-border)-offset );
		cr->close_path();
		cr->stroke_preserve();
		
		// fill the page with white
		cr->save();
		cr->set_source_rgb(1.0,1.0,1.0); // white
		cr->fill_preserve();
		cr->restore();

		// and the image preview
		ImagePixbuf->render_to_drawable( get_window(),
									get_style()->get_black_gc(),
									0,
									0,
									(width-ImagePixbuf->get_width())/2,
									(height-ImagePixbuf->get_height())/2,
									ImagePixbuf->get_width(), //image->get_width(),
									ImagePixbuf->get_height(), //image->get_height(),
									Gdk::RGB_DITHER_NONE,0,0 ); // */
									
		return true;
		}
	}
开发者ID:BackupTheBerlios,项目名称:gimmage-svn,代码行数:69,代码来源:PagePreview.cpp

示例14: drawWidget


//.........这里部分代码省略.........

    Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

    if(event)
    {
        // clip to the area indicated by the expose event so that we only
        // redraw the portion of the window that needs to be redrawn
        cr->rectangle(event->area.x, event->area.y,
                event->area.width, event->area.height);
        cr->clip();
    }

    // background gradient
    {
        Cairo::RefPtr<Cairo::LinearGradient> pat = Cairo::LinearGradient::create(0.0, 0.0, 0.0, height);
        pat->add_color_stop_rgb(1.0, 1.0, 1.0, 1.0);
        pat->add_color_stop_rgb(0.0, 0.0, 0.0, 0.0);
        cr->rectangle(0, 0, width, height);
        cr->set_source(pat);
        cr->fill();
    }

    // scale to unit square and translate (0, 0) to be (0.5, 0.5), i.e.
    // the center of the window
    cr->scale(width, height);
    cr->translate(0.5, 0.5);
    cr->set_line_width(m_line_width);

    cr->arc(0, 0, m_radius, 0, 2 * M_PI);
    cr->save();
    cr->set_source_rgba(1.0, 1.0, 1.0, 0.8);
    cr->fill_preserve();
    cr->restore();
    cr->stroke_preserve();
    cr->clip();

    //clock ticks
    for (int i = 0; i < 12; i++)
    {
        double inset = 0.05;

        cr->save();
        cr->set_line_cap(Cairo::LINE_CAP_ROUND);

        if(i % 3 != 0)
        {
            inset *= 0.8;
            cr->set_line_width(0.03);
        }

        cr->move_to(
                (m_radius - inset) * cos (i * M_PI / 6),
                (m_radius - inset) * sin (i * M_PI / 6));
        cr->line_to (
                m_radius * cos (i * M_PI / 6),
                m_radius * sin (i * M_PI / 6));
        cr->stroke();
        cr->restore(); /* stack-pen-size */
    }

    // store the current time
    time_t rawtime;
    time(&rawtime);
    struct tm * timeinfo = localtime (&rawtime);

    // compute the angles of the indicators of our clock
开发者ID:ereslibre,项目名称:ideallibrary-old-extern,代码行数:67,代码来源:main.cpp

示例15: determineColor

void guiRenderer2D::drawMatrices(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height, bool screenshot) {

	cr->scale(m_scaleFactor, m_scaleFactor); // Scale sensor to fit the active window
	cr->translate(m_offsetX, m_offsetY); // Center figure on drawable/surface

	cr->set_line_width(0.25);

	for(uint m = 0; m < m_frameManager->getNumMatrices(); m++) {
		matrixInfo &matrix = m_frameManager->getMatrixInfo(m);
		// TSFrame* tsFrame = m_frameManager->getCurrentFrame();
		TSFrame* tsFrame = m_frameManager->getCurrentFilteredFrame();

		for(uint y = 0; y < matrix.cells_y; y++) {
			for(uint x = 0; x < matrix.cells_x; x++) {

				bool maskedStatic = m_frameManager->getStaticMask(m, x, y);
				bool maskedDynamic = m_frameManager->getDynamicMask(m, x, y);
				uint cellID = matrix.texel_offset + y * matrix.cells_x + x;
				float value = tsFrame->cells[cellID];

				if(maskedStatic) {
					RGB color = determineColor(value);

					// Draw sensor cell rectangle
					cr->rectangle(m_rectangleTopLeftX[cellID], m_rectangleTopLeftY[cellID], m_rectangleWidth[cellID], m_rectangleHeight[cellID]);
					cr->set_source_rgb(0.0, 0.0, 0.0);
					cr->stroke_preserve(); // Cell outline

					if(maskedDynamic) {
						if(value > 0.0) {
							cr->set_source_rgb(color.r, color.g, color.b); // Active cells
						} else  {
							cr->set_source_rgb(1.0, 1.0, 1.0); // Inactive cells
						}
					} else {
						cr->set_source_rgb(0.8, 0.8, 0.8); // Disabled cells
					}
					cr->fill();
				}

				// Highlight selected cells
				if(m_frameManager->isSelected(cellID)) {
					cr->rectangle(m_rectangleTopLeftX[cellID], m_rectangleTopLeftY[cellID], m_rectangleWidth[cellID], m_rectangleHeight[cellID]);
					cr->set_source_rgba(0.0, 1.0, 0.0, 0.5); // Fill active cells
					cr->fill();
				}

				if(screenshot) {
					if(maskedStatic) {
						// Print values
						Cairo::RefPtr<Cairo::ToyFontFace> font = Cairo::ToyFontFace::create("LMSans10", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL);
						cr->set_font_face(font);
						cr->set_font_size(matrix.texel_width/3);
						std::ostringstream ss;
						ss << value;
						std::string valueStr = ss.str();

						Cairo::TextExtents te;
						cr->get_text_extents(valueStr, te);

						cr->move_to(m_matrixCellCenterX[cellID]-te.width/2, m_matrixCellCenterY[cellID]+te.height/2);
						cr->set_source_rgb(0.0, 0.0, 0.0);
						cr->show_text(valueStr);
					}
				}

			}
		}

		if(!screenshot) {
			{
				// Print Matrix IDs
				Cairo::RefPtr<Cairo::ToyFontFace> font = Cairo::ToyFontFace::create("LMSans10", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL);
				cr->set_font_face(font);
				cr->set_font_size(matrix.cells_x*matrix.texel_width);
				std::ostringstream ss;
				ss << m;
				std::string idString = ss.str();

				Cairo::TextExtents te;
				cr->get_text_extents(idString, te);

				cr->move_to(m_newCenterX[m]-te.width/2, m_newCenterY[m]+te.height/2);
				cr->set_source_rgba(0.3, 0.3, 0.3, 0.3);
				cr->show_text(idString);
			}
		}

	}
}
开发者ID:pxlong,项目名称:tactile-sensors,代码行数:90,代码来源:guiRenderer2D.cpp


注:本文中的cairo::RefPtr::stroke_preserve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。