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

C++ create_rect函数代码示例

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

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



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

示例1: draw_rectangle

void draw_rectangle(int x, int y, int w, int h, Uint32 color, surface target)
{

	SDL_Rect top = create_rect(x, y, w, 1);
	SDL_Rect bot = create_rect(x, y + h - 1, w, 1);
	SDL_Rect left = create_rect(x, y, 1, h);
	SDL_Rect right = create_rect(x + w - 1, y, 1, h);

	sdl::fill_rect(target,&top,color);
	sdl::fill_rect(target,&bot,color);
	sdl::fill_rect(target,&left,color);
	sdl::fill_rect(target,&right,color);
}
开发者ID:8680-wesnoth,项目名称:wesnoth-fork-old,代码行数:13,代码来源:rect.cpp


示例2: image_fg

void mouse_action::set_terrain_mouse_overlay(editor_display& disp, t_translation::t_terrain fg,
		t_translation::t_terrain bg)
{
	surface image_fg(image::get_image("terrain/"
		+ disp.get_map().get_terrain_info(fg).editor_image() + ".png"));
	surface image_bg(image::get_image("terrain/"
		+ disp.get_map().get_terrain_info(bg).editor_image() + ".png"));

	if (image_fg == NULL || image_bg == NULL) {
		ERR_ED << "Missing terrain icon\n";
		disp.set_mouseover_hex_overlay(NULL);
		return;
	}

	// Create a transparent surface of the right size.
	surface image = create_compatible_surface(image_fg, image_fg->w, image_fg->h);
	sdl_fill_rect(image,NULL,SDL_MapRGBA(image->format,0,0,0, 0));

	// For efficiency the size of the tile is cached.
	// We assume all tiles are of the same size.
	// The zoom factor can change, so it's not cached.
	// NOTE: when zooming and not moving the mouse, there are glitches.
	// Since the optimal alpha factor is unknown, it has to be calculated
	// on the fly, and caching the surfaces makes no sense yet.
	static const Uint8 alpha = 196;
	static const int size = image_fg->w;
	static const int half_size = size / 2;
	static const int quarter_size = size / 4;
	static const int offset = 2;
	static const int new_size = half_size - 2;
	const int zoom = static_cast<int>(size * disp.get_zoom_factor());

	// Blit left side
	image_fg = scale_surface(image_fg, new_size, new_size);
	SDL_Rect rcDestLeft = create_rect(offset, quarter_size, 0, 0);
	sdl_blit ( image_fg, NULL, image, &rcDestLeft );

	// Blit left side
	image_bg = scale_surface(image_bg, new_size, new_size);
	SDL_Rect rcDestRight = create_rect(half_size, quarter_size, 0, 0);
	sdl_blit ( image_bg, NULL, image, &rcDestRight );

	//apply mask so the overlay is contained within the mouseover hex
	image = mask_surface(image, image::get_hexmask());

	// Add the alpha factor and scale the image
	image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);

	// Set as mouseover
	disp.set_mouseover_hex_overlay(image);
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:51,代码来源:mouse_action.cpp


示例3: inner_location

void textbox::draw_contents()
{
	SDL_Rect const &loc = inner_location();

	surface surf = video().getSurface();
	draw_solid_tinted_rectangle(loc.x,loc.y,loc.w,loc.h,0,0,0,
				    focus(NULL) ? alpha_focus_ : alpha_, surf);

	SDL_Rect src;

	if(text_image_ == NULL) {
		update_text_cache(true);
	}

	if(text_image_ != NULL) {
		src.y = yscroll_;
		src.w = std::min<size_t>(loc.w,text_image_->w);
		src.h = std::min<size_t>(loc.h,text_image_->h);
		src.x = text_pos_;
		SDL_Rect dest = screen_area();
		dest.x = loc.x;
		dest.y = loc.y;

		// Fills the selected area
		if(is_selection()) {
			const int start = std::min<int>(selstart_,selend_);
			const int end = std::max<int>(selstart_,selend_);
			int startx = char_x_[start];
			int starty = char_y_[start];
			const int endx = char_x_[end];
			const int endy = char_y_[end];

			while(starty <= endy) {
				const size_t right = starty == endy ? endx : text_image_->w;
				if(right <= size_t(startx)) {
					break;
				}

				SDL_Rect rect = create_rect(loc.x + startx
						, loc.y + starty - src.y
						, right - startx
						, line_height_);

				const clip_rect_setter clipper(surf, &loc);

				Uint32 color = SDL_MapRGB(surf->format, 0, 0, 160);
				fill_rect_alpha(rect, color, 140, surf);

				starty += int(line_height_);
				startx = 0;
			}
		}

		sdl_blit(text_image_, &src, surf, &dest);
	}

	draw_cursor((cursor_pos_ == 0 ? 0 : cursor_pos_ - 1), video());

	update_rect(loc);
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:60,代码来源:textbox.cpp


示例4: draw_normal_geom

static void draw_normal_geom(SkCanvas* canvas, const SkPoint& offset, int geom, bool useAA) {
    SkPaint p;
    p.setAntiAlias(useAA);
    p.setColor(SK_ColorBLACK);

    switch (geom) {
    case kRect_Geometry:                // fall thru
    case kRectAndRect_Geometry:
        canvas->drawRect(create_rect(offset), p);
        break;
    case kRRect_Geometry:               // fall thru
    case kRectAndRRect_Geometry:
        canvas->drawRRect(create_rrect(offset), p);
        break;
    case kCircle_Geometry:
        canvas->drawRRect(create_circle(offset), p);
        break;
    case kConvexPath_Geometry:          // fall thru
    case kRectAndConvex_Geometry:
        canvas->drawPath(create_convex_path(offset), p);
        break;
    case kConcavePath_Geometry:         // fall thru
    case kRectAndConcave_Geometry:
        canvas->drawPath(create_concave_path(offset), p);
        break;
    } 
}
开发者ID:Crawping,项目名称:chromium_extract,代码行数:27,代码来源:SampleClipDrawMatch.cpp


示例5: set_use_drag

// ---------------------------------------------------------------------------
// 
// -----------
void bToolShape::end_clic(){
	bStdToolGeom::end_clic();
	if(!get_use_drag()){
		return;
	}
	if(!get_active()){
		return;
	}
	set_use_drag(false);
	set_use_track(false);

CGPoint	pa,pb;
	get_clic(&pa);
	get_cur(&pb);
CGFloat	d=CGPointsDist(&pa,&pb);
	if(d<=sqrt(2)){
		return;
	}
	
	clearTempPathContext(true);
	validTempPathContext();
	if(get_mnu_cmd()==kShapeRect){
		create_rect();
	}
	else{
		create_circle();
	}
}
开发者ID:CarteBlancheConseil,项目名称:MacMap,代码行数:31,代码来源:bToolShape.cpp


示例6: image

void slider::draw_contents()
{
	surface image(state_ != NORMAL ? highlightedImage_ : image_);
	if (image == NULL)
		return;
	SDL_Color line_color = font::NORMAL_COLOR;
	if (!enabled()) {
		image = greyscale_image(image);
		line_color = font::DISABLED_COLOR;
	}

	SDL_Rect const &loc = location();
	if (image->w >= loc.w)
		return;

	surface screen = video().getSurface();

	SDL_Rect line_rect = create_rect(loc.x + image->w / 2
			, loc.y + loc.h / 2
			, loc.w - image->w
			, 1);

	sdl_fill_rect(screen, &line_rect, SDL_MapRGB(screen->format,
		line_color.r, line_color.g, line_color.b));

	SDL_Rect const &slider = slider_area();
	video().blit_surface(slider.x, slider.y, image);
}
开发者ID:blackberry,项目名称:Wesnoth,代码行数:28,代码来源:slider.cpp


示例7: draw_solid_tinted_rectangle

void draw_solid_tinted_rectangle(int x, int y, int w, int h,
								 int r, int g, int b,
								 double alpha, surface target)
{

	SDL_Rect rect = create_rect(x, y, w, h);
	fill_rect_alpha(rect,SDL_MapRGB(target->format,r,g,b),Uint8(alpha*255),target);
}
开发者ID:8680-wesnoth,项目名称:wesnoth-fork-old,代码行数:8,代码来源:rect.cpp


示例8: target

void CVideo::blit_surface(int x, int y, surface surf, SDL_Rect* srcrect, SDL_Rect* clip_rect)
{
	surface target(getSurface());
	SDL_Rect dst = create_rect(x, y, 0, 0);

	const clip_rect_setter clip_setter(target, clip_rect, clip_rect != NULL);
	sdl_blit(surf,srcrect,target,&dst);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:8,代码来源:video.cpp


示例9: test

void test(void){

   struct point p1 = create_point(1,3);
   struct point p2 = create_point(3,6);
   struct point p3 = create_point(5,0);
   struct point p4 = create_point(7,1);

   checkit_int(p1.x,1);
   checkit_int(p2.y,6);

   struct rect r1 = create_rect(p1, 3,2);
   struct rect r2 = create_rect(p2, 4,1);
   struct rect r3 = create_rect(p3,1,1);
   struct rect r4 = create_rect(p4,1,1);
      
   checkit_int(r1.w, 3);
   checkit_int(r2.h, 1);

   checkit_double(distance(p1,p3),5);
   
   struct rect r[3] = {r1,r2,r3};
   checkit_int(largest_rect(r,3),0);
   
   struct point p[2];
   closest_corners(r1,r2,p);
   checkit_int(p[0].x,4);
   checkit_int(p[0].y,5);   
   checkit_int(p[1].x,3);
   checkit_int(p[1].y,6);

   struct point pt[2];
   closest_corners(r2,r3,pt);
   checkit_int(pt[0].x,3);
   checkit_int(pt[0].y,6);
   checkit_int(pt[1].x,5);
   checkit_int(pt[1].y,1);

   struct point pts[2];
   closest_corners(r3,r4,pts);
   checkit_int(pts[0].x,6);
   checkit_int(pts[0].y,1);
   checkit_int(pts[1].x,7);
   checkit_int(pts[1].y,1);


}
开发者ID:bsugiarto24,项目名称:CPE-101,代码行数:46,代码来源:test.c


示例10: make_map

internal void 
make_map()
{
    // Fill map with blocked tiles
    for (i32 x = 0; x < MAP_WIDTH; x++) {
        for (i32 y = 0; y < MAP_HEIGHT; y++) {
            map[x][y].blockMovement = true;
            map[x][y].blockSight = true;
        }
    }

    // Create two rooms
    map_rect room1 = create_rect(20, 15, 10, 15);
    map_rect room2 = create_rect(50, 15, 10, 15);
    create_room(room1);
    create_room(room2);
}
开发者ID:pdetagyos,项目名称:RoguelikeTutorial,代码行数:17,代码来源:game.c


示例11: mask_surface

surface mask_modification::operator()(const surface& src) const
{
	if(src->w == mask_->w &&  src->h == mask_->h && x_ == 0 && y_ == 0)
		return mask_surface(src, mask_);
	SDL_Rect r = create_rect(x_, y_, 0, 0);
	surface new_mask = create_neutral_surface(src->w, src->h);
	blit_surface(mask_, NULL, new_mask, &r);
	return mask_surface(src, new_mask);
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:9,代码来源:image_modifications.cpp


示例12: make_neutral_surface

surface blit_function::operator()(const surface& src) const
{
	//blit_surface want neutral surfaces
	surface nsrc = make_neutral_surface(src);
	surface nsurf = make_neutral_surface(surf_);
	SDL_Rect r = create_rect(x_, y_, 0, 0);
	sdl_blit(nsurf, NULL, nsrc, &r);
	return nsrc;
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:9,代码来源:image_function.cpp


示例13: create_rect

void ttexture::draw(SDL_Renderer& renderer, const int x, const int y)
{
	SDL_Rect dstrect = create_rect(x, y, clip_.w * hscale_, clip_.h * vscale_);

	SDL_SetTextureAlphaMod(texture_, alpha_);
	SDL_SetTextureColorMod(texture_, mod_r_, mod_g_, mod_b_);
	SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, smooth_scaling_ ? "linear" : "nearest");
	SDL_RenderCopyEx(&renderer, texture_, &clip_, &dstrect,
					 rotation_, NULL, flip_);
}
开发者ID:m06x,项目名称:wesnoth,代码行数:10,代码来源:texture.cpp


示例14: create_rect

void loadscreen::clear_screen()
{
	int scrx = screen_.getx();                     //< Screen width.
	int scry = screen_.gety();                     //< Screen height.
	SDL_Rect area = create_rect(0, 0, scrx, scry); // Screen area.
	surface disp(screen_.getSurface());      // Screen surface.
	// Make everything black.
	sdl_fill_rect(disp,&area,SDL_MapRGB(disp->format,0,0,0));
	screen_.flip();
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:10,代码来源:loadscreen.cpp


示例15: location

SDL_Rect slider::slider_area() const
{
	static const SDL_Rect default_value = {0,0,0,0};
	SDL_Rect const &loc = location();
	if (image_.null() || image_->w >= loc.w)
		return default_value;

	int xpos = loc.x + (value_ - min_) *
		static_cast<int>(loc.w - image_->w) / (max_ - min_);
	return create_rect(xpos, loc.y, image_->w, image_->h);
}
开发者ID:blackberry,项目名称:Wesnoth,代码行数:11,代码来源:slider.cpp


示例16: groove_area

SDL_Rect scrollbar::grip_area() const
{
	SDL_Rect const &loc = groove_area();
	if (full_height_ == grip_height_)
		return loc;
	int h = static_cast<int>(loc.h) * grip_height_ / full_height_;
	if (h < minimum_grip_height_)
		h = minimum_grip_height_;
	int y = loc.y + (static_cast<int>(loc.h) - h) * grip_position_ / (full_height_ - grip_height_);
	return create_rect(loc.x, y, loc.w, h);
}
开发者ID:RushilPatel,项目名称:BattleForWesnoth,代码行数:11,代码来源:scrollbar.cpp


示例17: create_rect

void textbox::draw_cursor(int pos, CVideo &video) const
{
	if(show_cursor_ && editable_) {
		SDL_Rect rect = create_rect(location().x + pos
				, location().y
				, 1
				, location().h);

		surface frame_buffer = video.getSurface();
		sdl_fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
	}
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:12,代码来源:textbox.cpp


示例18: SDL_CreateTextureFromSurface

void ttexture::initialise_from_surface(SDL_Renderer& renderer, const int access)
{
	if(access == SDL_TEXTUREACCESS_STATIC) {
		texture_ = SDL_CreateTextureFromSurface(&renderer, source_surface_);

		if(texture_ == NULL) {
			throw texception("Failed to create SDL_Texture object.", true);
		}

		clip_ = create_rect(0, 0, source_surface_->w, source_surface_->h);
		SDL_FreeSurface(source_surface_);
		source_surface_ = NULL;
	} else if(access == SDL_TEXTUREACCESS_STREAMING) {
		texture_ = SDL_CreateTexture(&renderer,
									 source_surface_->format->format,
									 SDL_TEXTUREACCESS_STREAMING,
									 source_surface_->w,
									 source_surface_->h);

		if(texture_ == NULL) {
			throw texception("Failed to create SDL_Texture object.", true);
		}

		clip_ = create_rect(0, 0, source_surface_->w, source_surface_->h);
		const int update = SDL_UpdateTexture(texture_,
											 NULL,
											 source_surface_->pixels,
											 source_surface_->pitch);
		if(update != 0) {
			throw texception("Failed to update the SDL_Texture object during "
							 "its construction.",
							 true);
		}
	} else {
		throw texception("Unknown texture access mode.", false);
	}
	SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
}
开发者ID:m06x,项目名称:wesnoth,代码行数:38,代码来源:texture.cpp


示例19: flabel

	void floating_textbox::update_location(game_display& gui)
	{
		if (box_ == NULL)
			return;

		const SDL_Rect& area = gui.map_outside_area();

		const int border_size = 10;

		const int ypos = area.y+area.h-30 - (check_ != NULL ? check_->height() + border_size : 0);

		if (label_ != 0)
			font::remove_floating_label(label_);

		font::floating_label flabel(label_string_);
		flabel.set_color(font::YELLOW_COLOR);
		flabel.set_position(area.x + border_size, ypos);
		flabel.set_alignment(font::LEFT_ALIGN);
		flabel.set_clip_rect(area);

		label_ = font::add_floating_label(flabel);

		if (label_ == 0)
			return;

		const SDL_Rect& label_area = font::get_floating_label_rect(label_);
		const int textbox_width = area.w - label_area.w - border_size*3;

		if(textbox_width <= 0) {
			font::remove_floating_label(label_);
			return;
		}

		if(box_ != NULL) {
			box_->set_volatile(true);
			const SDL_Rect rect = create_rect(
				  area.x + label_area.w + border_size * 2
				, ypos
				, textbox_width
				, box_->height());

			box_->set_location(rect);
		}

		if(check_ != NULL) {
			check_->set_volatile(true);
			check_->set_location(box_->location().x,box_->location().y + box_->location().h + border_size);
		}
	}
开发者ID:RushilPatel,项目名称:BattleForWesnoth,代码行数:49,代码来源:floating_textbox.cpp


示例20: drawClippedGeom

    void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) {

        int count = canvas->save();

        switch (fGeom) {
        case kRect_Geometry:
            canvas->clipRect(create_rect(offset), SkRegion::kReplace_Op, useAA);
            break;
        case kRRect_Geometry:
            canvas->clipRRect(create_rrect(offset), SkRegion::kReplace_Op, useAA);
            break;
        case kCircle_Geometry:
            canvas->clipRRect(create_circle(offset), SkRegion::kReplace_Op, useAA);
            break;
        case kConvexPath_Geometry:
            canvas->clipPath(create_convex_path(offset), SkRegion::kReplace_Op, useAA);
            break;
        case kConcavePath_Geometry:
            canvas->clipPath(create_concave_path(offset), SkRegion::kReplace_Op, useAA);
            break;
        case kRectAndRect_Geometry: {
            SkRect r = create_rect(offset);
            r.offset(fSign * kXlate, fSign * kXlate);
            canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
            canvas->clipRect(create_rect(offset), SkRegion::kIntersect_Op, useAA);
            } break;
        case kRectAndRRect_Geometry: {
            SkRect r = create_rect(offset);
            r.offset(fSign * kXlate, fSign * kXlate);
            canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
            canvas->clipRRect(create_rrect(offset), SkRegion::kIntersect_Op, useAA);
            } break;
        case kRectAndConvex_Geometry: {
            SkRect r = create_rect(offset);
            r.offset(fSign * kXlate, fSign * kXlate);
            canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
            canvas->clipPath(create_convex_path(offset), SkRegion::kIntersect_Op, useAA);
            } break;
        case kRectAndConcave_Geometry: {
            SkRect r = create_rect(offset);
            r.offset(fSign * kXlate, fSign * kXlate);
            canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
            canvas->clipPath(create_concave_path(offset), SkRegion::kIntersect_Op, useAA);
            } break;
        } 

        SkISize size = canvas->getDeviceSize();
        SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar(size.height()));

        SkPaint p;
        p.setColor(SK_ColorRED);

        canvas->drawRect(bigR, p);
        canvas->restoreToCount(count);
    }
开发者ID:Crawping,项目名称:chromium_extract,代码行数:55,代码来源:SampleClipDrawMatch.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ create_request函数代码示例发布时间:2022-05-30
下一篇:
C++ create_queue函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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