本文整理汇总了C++中create_rect函数的典型用法代码示例。如果您正苦于以下问题:C++ create_rect函数的具体用法?C++ create_rect怎么用?C++ create_rect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_rect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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_);
}
示例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();
}
示例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);
}