• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rect的典型用法代码示例。如果您正苦于以下问题:C++ rect类的具体用法?C++ rect怎么用?C++ rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1:

void
RiscosGui::setInvalidatedRegion(const rect& bounds)
{
    // Note: Bounds coordinates are in TWIPS

#ifdef RENDERER_AGG
    // forward to renderer
    _renderer->set_invalidated_region(bounds);

    if (bounds.width() > 1e10f) {
        // Region is entire screen. Don't convert to integer as this will
        // overflow.

        m_draw_minx = 0;
        m_draw_miny = 0;
        m_draw_maxx = _width - 1;
        m_draw_maxy = _height - 1;
    } else {
        // remember for renderBuffer()
        _renderer->world_to_pixel(&m_draw_minx, &m_draw_miny,
                                  bounds.get_x_min(), bounds.get_y_min());
        _renderer->world_to_pixel(&m_draw_maxx, &m_draw_maxy,
                                  bounds.get_x_max(), bounds.get_y_max());

        // add two pixels because of anti-aliasing...
        m_draw_minx = valid_coord(m_draw_minx - 2, _width);
        m_draw_miny = valid_coord(m_draw_miny - 2, _height);
        m_draw_maxx = valid_coord(m_draw_maxx + 2, _width);
        m_draw_maxy = valid_coord(m_draw_maxy + 2, _height);
    }

//    log_debug("DrawRect: (%i, %i), (%i, %i)\n",
//            m_draw_minx, m_draw_miny, m_draw_maxx, m_draw_maxy);
#endif
}
开发者ID:arcanon,项目名称:ipadflash,代码行数:35,代码来源:riscos.cpp


示例2: dialog

code_editor_dialog::code_editor_dialog(const rect& r)
  : dialog(r.x(), r.y(), r.w(), r.h()), invalidated_(0), has_error_(false),
    modified_(false), file_contents_set_(true), suggestions_prefix_(-1),
	have_close_buttons_(false)
{
	init();
}
开发者ID:,项目名称:,代码行数:7,代码来源:


示例3: slider

    bool slider(int id, const rect & r, double min, double max, double step, double & value, bool disable_dragger = false)
    {
        bool changed = false;
        const int w = r.x1 - r.x0, h = r.y1 - r.y0;
        double p = (w - h) * (value - min) / (max - min);
        if (mouse_down && clicked_id == id)
        {
            p = std::max(0.0, std::min<double>(cursor.x - clicked_offset.x - r.x0, w - h));
            double new_value = min + p * (max - min) / (w - h);
            if (step) new_value = std::round((new_value - min) / step) * step + min;
            changed = new_value != value;
            value = new_value;
            p = (w - h) * (value - min) / (max - min);
        }
        const rect dragger = { int(r.x0 + p), int(r.y0), int(r.x0 + p + h), int(r.y1) };
        if (click && dragger.contains(cursor) && !disable_dragger)
        {
            clicked_offset = { cursor.x - dragger.x0, cursor.y - dragger.y0 };
            clicked_id = id;
        }
        fill_rect(r, { 0.5, 0.5, 0.5 });

        if (!disable_dragger)
            fill_rect(dragger, { 1, 1, 1 });

        return changed;
    }
开发者ID:miguelinux,项目名称:librealsense,代码行数:27,代码来源:cpp-config-ui.cpp


示例4:

	void CDX9Renderer::Box(const rect& r, const color& c)
	{
		// No support for textured lines
		SetTexture(NULL);

		BeginBatch(batch_linestrip);
		CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());

		D3DCOLOR color = c.getD3DCOLOR();

		// 4 vertices and use 5th index to repeat first vertex closing the strip as a box
		AddVertex(color, r.topleft(), 0.0f, 0.0f);
		AddVertex(color, r.topright(), 0.0f, 0.0f);
		AddVertex(color, r.bottomright(), 0.0f, 0.0f);
		AddVertex(color, r.bottomleft(), 0.0f, 0.0f);

		unsigned short index = draw_op->vertex_count;
		AddIndex(index);
		AddIndex(index + 1);
		AddIndex(index + 2);
		AddIndex(index + 3);
		AddIndex(index);

		draw_op->vertex_count += 4;
		draw_op->index_count += 5;
	}
开发者ID:segafan,项目名称:Construct-classic,代码行数:26,代码来源:CDX9Renderer_Batch.cpp


示例5:

message_dialog::message_dialog(const std::string& text, const rect& pos,
                               const std::vector<std::string>* options)
  : text_(text), pos_(pos), line_height_(0),
    cur_row_(0), cur_char_(0), cur_wait_(0),
	selected_option_(0)
{
	line_height_ = font::char_height(FontSize);
	viewable_lines_ = pos.h()/line_height_;
	if(viewable_lines_ < 1) {
		viewable_lines_ = 1;
	}

	const int max_chars_on_line = std::max<int>(1, pos.w()/font::char_width(FontSize));
	std::string::const_iterator i1 = text.begin();
	std::string::const_iterator i2 = i1;
	while(i2 != text.end()) {
		i2 = get_line(i2, text.end(), max_chars_on_line);
		if(i2 == i1) {
			break;
		}

		while(i1 != i2 && util::isspace(*i1)) {
			++i1;
		}

		lines_.push_back(font::render_text(std::string(i1, i2), graphics::color_black(), FontSize));
		i1 = i2;
	}

	if(options != NULL) {
		foreach(const std::string& option, *options) {
			options_.push_back(font::render_text(option, graphics::color_black(), FontSize));
		}
	}
开发者ID:asimonov-im,项目名称:frogatto,代码行数:34,代码来源:message_dialog.cpp


示例6: glViewport

void OpenGL3RenderState::set_viewport(OpenGL3ContextState& state, const rect<int>& viewport) const
{
    if (state.viewport == viewport)
        return;
    glViewport(viewport.ll().x(), viewport.ll().y(), viewport.width(), viewport.height());
    state.viewport = viewport;
}
开发者ID:icedmaster,项目名称:mhe,代码行数:7,代码来源:opengl3_render_state.cpp


示例7: eval_overlap

int eval_overlap(rect r1, rect r2, branching_rule rule){
    int dist_x = std::min(r1.xmax-r2.xmin, r2.xmax-r1.xmin);
    int dist_y = std::min(r1.ymax-r2.ymin, r2.ymax-r1.ymin);
    assert(dist_x > 0 and dist_y > 0);
    int height = r1.get_height() + r2.get_height();
    int width  = r1.get_width()  + r2.get_width();
    switch(rule){
      case AREA:
        return rect::intersection(r1, r2).get_area();
      case LMIN:
        return std::min(dist_x, dist_y);
      case LMAX:
        return std::max(dist_x, dist_y);
      case LAVG:
        return dist_x+dist_y;
      case WMIN:
        return std::min(height, width);
      case WMAX:
        return std::max(height, width);
      case WAVG:
        return height + width;
      default:
        abort();
    }
}
开发者ID:Coloquinte,项目名称:Amaranth,代码行数:25,代码来源:placement_problem.cpp


示例8: hotspot

void ExtObject::Draw()
{
	const point hotspot(info.HotSpotX, info.HotSpotY);
	const rect r  = cr::rect_xywh(info.x, info.y, info.w, info.h);
	const rect r2 = cr::rect_xywh(info.x + 0.5f, info.y + 0.5f, info.w - 1.0f, info.h - 1.0f);	

	const cr::color& c = info.pInfo->filter;

	quad q ((r2 - hotspot).rotate_to_quad(cr::to_radians(info.angle), r2.topleft()));

	if (!transparent)
		renderer->Fill(r, cr_colors.fill * c, info.angle, hotspot);

	// Draw
	if (smoothLines) {
		renderer->SmoothLine(q.tr, q.tl, cr_colors.c1 * c, 1.0);
		renderer->SmoothLine(q.tl, q.bl, cr_colors.c1 * c, 1.0);
		renderer->SmoothLine(q.bl, q.br, cr_colors.c2 * c, 1.0);
		renderer->SmoothLine(q.br, q.tr, cr_colors.c2 * c, 1.0);
	}
	else {	
		renderer->Line(q.tr, q.tl, cr_colors.c1 * c);
		renderer->Line(q.tl, q.bl, cr_colors.c1 * c);
		renderer->Line(q.bl, q.br, cr_colors.c2 * c);
		renderer->Line(q.br, q.tr, cr_colors.c2 * c);
	}
}
开发者ID:segafan,项目名称:Construct-classic,代码行数:27,代码来源:Drawing.cpp


示例9: update_geometry

bool window::update_geometry( rect &r )
{
	SetWindowPos( _hwnd, NULL, r.x(), r.y(), r.width(), r.height(),
				  SWP_NOOWNERZORDER | SWP_NOZORDER );
	r = query_geometry();
	return true;
}
开发者ID:kdt3rd,项目名称:gecko,代码行数:7,代码来源:window.cpp


示例10: reset_clip

void context::reset_clip( const rect &r )
{
    glEnable( GL_SCISSOR_TEST );
    glScissor( static_cast<GLint>( r.x() ),
			   static_cast<GLint>( _last_vp[3] - ( r.y() + r.height() ) ),
			   static_cast<GLsizei>( r.width() ),
			   static_cast<GLsizei>( r.height() ) );
}
开发者ID:kdt3rd,项目名称:gecko,代码行数:8,代码来源:context.cpp


示例11: button

 bool button(const rect & r, const std::string & label)
 {
     fill_rect(r, { 1, 1, 1 });
     fill_rect(r.shrink(2), r.contains(cursor) ? (mouse_down ? color{ 0.3f, 0.3f, 0.3f } : color{ 0.4f, 0.4f, 0.4f }) : color{ 0.5f, 0.5f, 0.5f });
     glColor3f(1, 1, 1);
     draw_text(r.x0 + 4, r.y1 - 8, label.c_str());
     return click && r.contains(cursor);
 }
开发者ID:miguelinux,项目名称:librealsense,代码行数:8,代码来源:cpp-config-ui.cpp


示例12: Intersect

bool rect::Intersect( const rect& ref ) const
{
	if( Left() > ref.Right() ) return false;
	if( Right() < ref.Left() ) return false;
	if( Top() > ref.Bottom() ) return false;
	if( Bottom() < ref.Top() ) return false;
	return true;
}
开发者ID:MrGurken,项目名称:Boblin,代码行数:8,代码来源:maths.cpp


示例13: initialize

 inline void initialize(device_context* dc, rect pr)
 {
     dc_       =  dc;
     rect_     =  pr = pr.normalize();
     poffset_  = -pr.left_top();
     prect_    =  pr;
     mask_     =  nullptr;
     canvas_   =  std::make_shared<canvas_type>(pr.width(), pr.height());
 }
开发者ID:goalizc,项目名称:takisy,代码行数:9,代码来源:graphics.hpp


示例14: contains

	constexpr bool contains(
		rect< PositionType, SizeType > const& rect,
		point< DataType > const& point
	){
		return
			point.x() >= rect.left()  &&
			point.y() >= rect.top()   &&
			point.x() <  rect.right() &&
			point.y() <  rect.bottom();
	}
开发者ID:bebuch,项目名称:disposer_module,代码行数:10,代码来源:rect.hpp


示例15: solid_rect

point entity::midpoint() const
{
	if(solid()) {
		const rect r = solid_rect();
		return point(r.x() + r.w()/2, r.y() + r.h()/2);
	}

	const frame& f = current_frame();
	return point(x() + f.width()/2, y() + f.height()/2);
}
开发者ID:,项目名称:,代码行数:10,代码来源:


示例16: LONG

void window::submit_delayed_expose( const rect &r )
{
	/// \todo { Need to fix the local vs screen coordinates }
	RECT rect = { LONG( std::floor( r.x1() ) ), LONG( std::floor( r.y1() ) ), LONG( std::ceil( r.x2() ) ), LONG( std::ceil( r.y2() ) ) };
	if ( rect.left == rect.top &&
		 rect.left == rect.right &&
		 rect.left == rect.bottom )
		RedrawWindow( _hwnd, NULL, NULL, RDW_INTERNALPAINT|RDW_UPDATENOW );
	else
		RedrawWindow( _hwnd, &rect, NULL, RDW_INVALIDATE|RDW_UPDATENOW );
}
开发者ID:kdt3rd,项目名称:gecko,代码行数:11,代码来源:window.cpp


示例17: jitts

 jitter::jitter(rect<float> &context, rect<float> &jit, int spatial_norm)
   : jitts(JITTERS) {
   h = jit.hcenter() - context.hcenter();
   w = jit.wcenter() - context.wcenter();
   r = 0;
   s = context.height / (float) jit.height;
   jitts.set(s, 0);
   jitts.set(h / (float) spatial_norm, 1);
   jitts.set(w / (float) spatial_norm, 2);
   jitts.set(r, 3);
 }
开发者ID:2php,项目名称:eblearn,代码行数:11,代码来源:dataset.cpp


示例18: construct

void dark_style::slider_button( const std::shared_ptr<draw::canvas> &c, const rect &r, bool pressed, coord val )
{
	construct( c );

	coord rad = 9.0; //r.radius();
	rect tmp( rad * 2, rad * 2 );
	tmp.set_center( { r.x( val, rad ), r.y( 0.5, rad ) } );

	_slider_button->set( c, tmp );
	_slider_button->draw( *c );
}
开发者ID:kdt3rd,项目名称:gecko,代码行数:11,代码来源:dark_style.cpp


示例19: checkbox

 bool checkbox(const rect & r, bool & value)
 {
     bool changed = false;
     if (click && r.contains(cursor))
     {
         value = !value;
         changed = true;
     }
     fill_rect(r, { 1, 1, 1 });
     fill_rect(r.shrink(1), { 0.5, 0.5, 0.5 });
     if (value) fill_rect(r.shrink(3), { 1, 1, 1 });
     return changed;
 }
开发者ID:miguelinux,项目名称:librealsense,代码行数:13,代码来源:cpp-config-ui.cpp


示例20: Intersects

bool rect::Intersects(const rect& r)
{
    if (Intersects(r.x, r.y)) return true;
    if (Intersects(r.x + r.w-1, r.y + r.h-1)) return true;
    if (Intersects(r.x, r.y + r.h-1)) return true;
    if (Intersects(r.x + r.w-1, r.y)) return true;

    if (r.Intersects(x, y)) return true;
    if (r.Intersects(x + w-1, y + h-1)) return true;
    if (r.Intersects(x, y + h-1)) return true;
    if (r.Intersects(x + w-1, y)) return true;

    return false;
}
开发者ID:McManning,项目名称:fro_client,代码行数:14,代码来源:Rect.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rectangle类代码示例发布时间:2022-05-31
下一篇:
C++ realvec类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap