void image_rect_bevel(image *img, int x, int y, int w, int h, color ctop, color cright, color cbottom, color cleft) { image_line(img, x, y, x+w, y, ctop); image_line(img, x, y+h, x+w, y+h, cbottom); image_line(img, x+w, y, x+w, y+h, cright); image_line(img, x, y, x, y+h, cleft); }
void menu_background_create(texture *tex, int w, int h) { image img; image_create(&img, w, h); image_clear(&img, COLOR_MENU_BG); for(int x = 7; x < w; x += 8) { image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE); } for(int y = 7; y < h; y += 8) { image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE); } image_rect(&img, 0, 0, w-1, h-1, COLOR_MENU_BORDER); texture_create_from_img(tex, &img); image_free(&img); }
// the *other* style menu background void menu_background2_create(texture *tex, int w, int h) { image img; image_create(&img, w, h); image_clear(&img, COLOR_MENU_BG); for(int x = 5; x < w; x += 5) { image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE2); } for(int y = 4; y < h; y += 5) { image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE2); } image_rect(&img, 1, 1, w-2, h-2, COLOR_MENU_BORDER2); image_rect(&img, 0, 0, w-2, h-2, COLOR_MENU_BORDER1); texture_create_from_img(tex, &img); image_free(&img); }
void switch_render(item_t* item, v2d_t camera_position) { switch_t *me = (switch_t*)item; if(level_editmode() && me->partner != NULL) { v2d_t p1, p2, offset; offset = v2d_subtract(camera_position, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2)); p1 = v2d_subtract(item->actor->position, offset); p2 = v2d_subtract(me->partner->actor->position, offset); image_line(video_get_backbuffer(), (int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y, image_rgb(255, 0, 0)); } actor_render(item->actor, camera_position); }
void render(objectmachine_t *obj, v2d_t camera_position) { objectdecorator_t *dec = (objectdecorator_t*)obj; objectmachine_t *decorated_machine = dec->decorated_machine; if(level_editmode()) { objectdecorator_lockcamera_t *me = (objectdecorator_lockcamera_t*)obj; actor_t *act = obj->get_object_instance(obj)->actor; uint32 color = image_rgb(255, 0, 0); int x1, y1, x2, y2; x1 = (act->position.x + me->_x1) - (camera_position.x - VIDEO_SCREEN_W/2); y1 = (act->position.y + me->_y1) - (camera_position.y - VIDEO_SCREEN_H/2); x2 = (act->position.x + me->_x2) - (camera_position.x - VIDEO_SCREEN_W/2); y2 = (act->position.y + me->_y2) - (camera_position.y - VIDEO_SCREEN_H/2); image_line(video_get_backbuffer(), x1, y1, x2, y1, color); image_line(video_get_backbuffer(), x2, y1, x2, y2, color); image_line(video_get_backbuffer(), x2, y2, x1, y2, color); image_line(video_get_backbuffer(), x1, y2, x1, y1, color); } decorated_machine->render(decorated_machine, camera_position); }
void image_rect(image *img, int x, int y, int w, int h, color c) { image_line(img, x, y, x+w, y, c); image_line(img, x, y+h, x+w, y+h, c); image_line(img, x+w, y, x+w, y+h, c); image_line(img, x, y, x, y+h, c); }
static void egd_drv_output(ErlDrvData handle, char *buffer, int n) { egd_data* d = (egd_data*)handle; int command = 0; unsigned char error_code[4]; /* Error Control */ /* get command */ command = decode(&buffer); n -= 2; switch(command) { case IM_CREATE: image_create(d, buffer, n); break; case IM_PIXEL: image_pixel(d, buffer, n); break; case IM_LINE: image_line(d, buffer, n); break; case IM_RECTANGLE: image_rectangle(d, buffer, n); break; case IM_FILLEDRECTANGLE: image_filled_rectangle(d, buffer, n); break; case IM_POLYGON: image_polygon(d, buffer, n); break; case IM_FILLEDPOLYGON: image_filled_polygon(d, buffer, n); break; case IM_COLOR: image_color(d, buffer, n); break; case IM_ARC: image_arc(d, buffer, n); break; case IM_FILLEDARC: image_filled_arc(d, buffer, n); break; case IM_FILLEDELLIPSE: image_filled_ellipse(d, buffer, n); break; case IM_TEXT: image_text(d, buffer, n); break; case IM_TEXTUP: image_text_up(d, buffer, n); break; case IM_FONT_SIZE: image_font_size(d, buffer, n); break; case IM_FILL: image_fill(d, buffer, n); break; /* Resampling och Rotate */ case IM_RESAMPLE: image_resample(d, buffer, n); break; case IM_ROTATE: image_rotate(d, buffer, n); break; /* Fetching images */ case IM_GIF: image_gif(d,buffer,n); break; case IM_JPEG: image_jpeg(d,buffer,n); break; case IM_PNG: image_png(d,buffer,n); break; default: driver_output(d->port, (char *)encode((char *)error_code, 1), 4); break; } }