static void hlines_3(SDL_Surface *s, int x0, int x1, int y0, int ym, int y1, uint32_t fg) { hlineColor(s, x0, x1, y0, fg); hlineColor(s, x0, x1, ym, fg); hlineColor(s, x0, x1, y1, fg); }
void GUIDrawBorder(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 outLeft, Uint32 inLeft, Uint32 outRight, Uint32 inRight, bool topLeft){ if(outLeft!=0){ vlineColor(dst,x1,y1,y2-1,outLeft); hlineColor(dst,x1,x2-1,y1,outLeft); } if(inLeft!=0){ vlineColor(dst,x1+1,y1+1,y2-2,inLeft); hlineColor(dst,x1+1,x2-2,y1+1,inLeft); } if(outRight!=0){ vlineColor(dst,x2,y1+1,y2,outRight); hlineColor(dst,x1+1,x2-1,y2,outRight); } if(inRight!=0){ vlineColor(dst,x2-1,y1+2,y2-1,inRight); hlineColor(dst,x1+2,x2-2,y2-1,inRight); } if(topLeft){ outRight=outLeft; inRight=inLeft; } pixelColor(dst,x2,y1,outRight); pixelColor(dst,x1,y2,outRight); pixelColor(dst,x1+1,y2-1,inRight); pixelColor(dst,x2-1,y1+1,inRight); }
void digit(SDL_Surface *s, int n, int x0, int x1, int y0, int ym, int y1, uint32_t fg) { switch (n) { case 8: hlineColor(s, x0, x1, ym, fg); /* fall through */ case 0: hlineColor(s, x0, x1, y0, fg); vlineColor(s, x0, y0, y1, fg); /* fall through */ case 7: hlineColor(s, x0, x1, y1, fg); vlineColor(s, x1, y0, y1, fg); break; case 1: lineColor(s, x0, ym, x1, y1, fg); vlineColor(s, x1, y0, y1, fg); break; case 2: hlines_3(s, x0, x1, y0, ym, y1, fg); vlineColor(s, x0, y0, ym, fg); vlineColor(s, x1, ym, y1, fg); break; case 9: vlineColor(s, x0, ym, y1, fg); /* fall through */ case 3: hlines_3(s, x0, x1, y0, ym, y1, fg); vlineColor(s, x1, y0, y1, fg); break; case 4: hlineColor(s, x0, x1, ym, fg); vlineColor(s, x0, ym, y1, fg); vlineColor(s, x1, y0, y1, fg); break; case 6: hlines_3(s, x0, x1, y0, ym, y1, fg); vlineColor(s, x0, y0, y1, fg); vlineColor(s, x1, y0, ym, fg); break; case 5: hlines_3(s, x0, x1, y0, ym, y1, fg); vlineColor(s, x0, ym, y1, fg); vlineColor(s, x1, y0, ym, fg); break; default: abort(); } }
static void fillQuad(ScummEngine *scumm, Common::Point v[4], int color) { const int N = 4; int i; int y; int miny, maxy; Common::Point pt1, pt2; int polyInts[N]; // Determine Y maxima miny = maxy = v[0].y; for (i = 1; i < N; i++) { if (v[i].y < miny) { miny = v[i].y; } else if (v[i].y > maxy) { maxy = v[i].y; } } // Draw, scanning y for (y = miny; y <= maxy; y++) { int ints = 0; for (i = 0; i < N; i++) { int ind1 = i; int ind2 = (i + 1) % N; pt1 = v[ind1]; pt2 = v[ind2]; if (pt1.y > pt2.y) { SWAP(pt1, pt2); } if (pt1.y <= y && y <= pt2.y) { if (y == pt1.y && y == pt2.y) { hlineColor(scumm, pt1.x, pt2.x, y, color); } else if ((y >= pt1.y) && (y < pt2.y)) { polyInts[ints++] = (y - pt1.y) * (pt2.x - pt1.x) / (pt2.y - pt1.y) + pt1.x; } else if ((y == maxy) && (y > pt1.y) && (y <= pt2.y)) { polyInts[ints++] = (y - pt1.y) * (pt2.x - pt1.x) / (pt2.y - pt1.y) + pt1.x; } } } qsort(polyInts, ints, sizeof(int), gfxPrimitivesCompareInt); for (i = 0; i < ints; i += 2) { hlineColor(scumm, polyInts[i], polyInts[i + 1], y, color); } } return; }
/* Here we draw the vectorscope layout */ void make_vectorscope_layout() { int i, p1_x, p1_y, p2_x, p2_y; double temp; char text[4]; boxColor(screen, vector_x-130, vector_y+130, vector_x+130, vector_y-130, black); hlineColor(screen, vector_x-20, vector_x-128, vector_y, white); hlineColor(screen, vector_x+20, vector_x+128, vector_y, white); vlineColor(screen, vector_x, vector_y-20, vector_y-128, white); vlineColor(screen, vector_x, vector_y+20, vector_y+128, white); circleColor(screen,vector_x, vector_y, 20, white); circleColor(screen,vector_x, vector_y, 50, white); circleColor(screen,vector_x, vector_y, 80, white); circleColor(screen,vector_x, vector_y,112, white); for (i =0; i<36; i++) { /* Here we draw the degree scale */ temp = 112* cos (i*(10/57.3)) ; /* sin & cos only accept radiant */ p1_x = round(temp); /* and not degree input */ temp = 112* sin (i*(10/57.3) ); p1_y = round(temp); temp = 117* cos (i*(10/57.3) ); p2_x = round(temp); temp = 117* sin (i*(10/57.3) ); p2_y = round(temp); lineColor(screen, vector_x + p1_x, vector_y + p1_y, vector_x + p2_x, vector_y + p2_y, white); } sprintf(text, "0"); /* Creating the grad description */ stringColor(screen, vector_x + 135 , vector_y - 3, text, white); sprintf(text, "90"); stringColor(screen, vector_x - 7 , vector_y - 145, text, white); sprintf(text, "180"); stringColor(screen, vector_x - 155 , vector_y - 3, text, white); sprintf(text, "270"); stringColor(screen, vector_x - 10 , vector_y + 135, text, white); makepoint( 90, 60); /* length, arc, for purple */ makepoint( 96, 104); /* length, arc, for red */ makepoint( 67, 166); /* length, arc, for yellow */ makepoint( 90, 241); /* length, arc, for green */ makepoint( 96, 283); /* length, arc, for cyan */ makepoint( 67, 346); /* length, arc, for blue */ }
void GUITextBox::Draw(SDL_Surface *dst){ boxColor(dst,posX1,posY1,posX2,posY2,fontBackColor); renderedText.Blit(dst,textX1,textY1,textX2-textX1,textY2-textY1,false,false,curOffX,curOffY); rectangleColor(dst,posX1,posY1,posX2,posY2,BORDER); if(CursorBlink())boxColor(dst,curDrawX,curDrawY,curDrawX,curDrawY+curDrawH,0x330000FF); if(showScroll){ scrollX.Draw(dst); scrollY.Draw(dst); } if(showPointer){ vlineColor(dst,mouseX,mouseY-6,mouseY+6,0x00000080); hlineColor(dst,mouseX-3,mouseX+3,mouseY-7,0x00000080); hlineColor(dst,mouseX-3,mouseX+3,mouseY+7,0x00000080); } }
static PyObject* _gfx_hlinecolor (PyObject *self, PyObject* args) { PyObject *surface, *color; int x1, x2, y; pguint32 c; ASSERT_VIDEO_INIT (NULL); if (!PyArg_ParseTuple (args, "OiiiO:hline", &surface, &x1, &x2, &y, &color)) return NULL; if (!PySDLSurface_Check (surface)) { PyErr_SetString (PyExc_TypeError, "surface must be a Surface"); return NULL; } if (!ColorFromObj (color, &c)) return NULL; if (hlineColor (((PySDLSurface*)surface)->surface, (Sint16)x1, (Sint16)x2, y, (Uint32)c) == -1) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
static void draw_real_spectrum(SDL_Surface *surface, int size, fftw_complex * spectrum, int v_position, int height, const char * title, Uint32 pixel) { int i; float step; char spectrum_title[255]; step = (((float)surface->w / 2) / (size)); sprintf(spectrum_title, "%s Real Spectrum", title); stringColor(surface, 10, v_position - height + (height / 10), spectrum_title, 0xffffffff); hlineColor(surface, 0, surface->w, v_position, 0xffffffff); for (i=1; i < size; i++) { aalineColor(surface, (int)((surface->w / 2) + ((i-1)*step)), ((int)(spectrum[0][i-1] * height) + v_position), (int)((surface->w / 2) + (i*step)), ((int)(spectrum[0][i] * height) + v_position), pixel); aalineColor(surface, (int)((surface->w / 2) - ((i-1)*step)), ((int)(spectrum[0][i-1] * height) + v_position), (int)((surface->w / 2) - (i*step)), ((int)(spectrum[0][i] * height) + v_position), pixel); } }
static void label_wlan_channels(SDL_Surface *s, int sx, int x0, int y0) { int x, xb, y, i, c; xb = x0; y = s->h-y0+4; for (i = 0; i != wlan_channels(); i++) { c = i+1; /* Japan special channel: 22 MHz from channel 13 */ if (c == 14) xb += X_STEP*12/5-X_STEP; if (c > 9) { x = xb; digit(s, c/10, CWLAN(0)); } else { x = xb-3; } digit(s, c % 10, CWLAN(1)); if (show_wlan_channel(c)) { hlineColor(s, xb-WLAN_XR, xb+WLAN_XR, y-WLAN_YH, WLAN_RGBA); vlineColor(s, xb, y-2, y-WLAN_YH+1, WLAN_RGBA); } xb += sx; } }
static void draw_sound(SDL_Surface *surface, int size, int16_t * left_channel, int16_t * right_channel, int v_position, int height, Uint32 pixel) { int i; float step; /* Here as in the other plotting functions we need to compute the step for each data, the only * problem was that, if we computed it as an integer then, for higher value of size (That are the * frames for each period) then all the values would have collapsed, since the "step" would have * been 0. */ step = (((float)surface->w / 2) / size); stringColor(surface, 10, v_position - height + (height / 10), "Amplitude", 0xffffffff); stringColor(surface, (surface->w / 2) - 20, v_position - height + (height / 10), "L", 0xffffffff); stringColor(surface, (surface->w / 2) + 10, v_position - height + (height / 10), "R", 0xffffffff); hlineColor(surface, 0, surface->w, v_position, 0xffffffff); // We plot directly both channels, by going from left to right. for (i=1; i<size; i++) { aalineColor(surface, (int)((surface->w / 2) + ((i-1)*step)), ((int)(right_channel[i-1] * height / (float)DAMP_FACTOR) + v_position), (int)((surface->w / 2) + (i*step)), ((int)(right_channel[i] * height / (float)DAMP_FACTOR) + v_position), pixel); aalineColor(surface, (int)((surface->w / 2) - ((i-1)*step)), ((int)(left_channel[i-1] * height / (float)DAMP_FACTOR) + v_position), (int)((surface->w / 2) - (i*step)), ((int)(left_channel[i] * height / (float)DAMP_FACTOR) + v_position), pixel); } }
void Draw_Geometry() { int flag = 1; SDL_FillRect(WINDOW, NULL, 0xffffffff); while( flag ){ switch( rand() % 7 ){ case 0: hlineColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break; case 1: vlineColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break; case 2: rectangleColor(WINDOW, AXIS, AXIS, AXIS, AXIS, COLOR); break; case 3: lineColor(WINDOW, AXIS, AXIS, AXIS, AXIS, COLOR); break; case 4: circleColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break; case 5: pieColor(WINDOW, AXIS, AXIS, AXIS, THETA, THETA, COLOR); break; case 6: trigonColor(WINDOW, AXIS, AXIS, AXIS, AXIS, AXIS, AXIS, COLOR); break; default: break; } SDL_UpdateRect(WINDOW, 0, 0, 0, 0); printf("again->'a' reset->'r' exit->'e'\n"); char ch = getchar(), c = getchar(); switch( ch ){ case 'a': flag = 1; break; case 'r': SDL_FillRect(WINDOW, NULL, 0xffffffff); break; case 'e': flag = 0; break; default : flag = 1; break; } } }
int GeoLayer::hline(int16_t x1, int16_t x2, int16_t y, uint32_t col) { if(!surf) { error("%s can't run: layer not initialized", __PRETTY_FUNCTION__); return -1; } res = hlineColor(surf, x1, x2, y, col); if(res < 0) error("error in %s", __PRETTY_FUNCTION__); return(res); }
/* Here we draw the layout of the histogram */ void draw_histogram_layout(int x_off, int y_off) { int i, offset; char text[3]; hlineColor(screen, x_off, x_off+257, y_off+101 , white); vlineColor(screen, x_off-1, y_off, y_off+101, white); vlineColor(screen, x_off+257,y_off,y_off+101, white); if (scalepercent == 0) { for (i = 0; i < 15; i++) { offset = i*16+ 16; vlineColor(screen, x_off+offset, y_off+101, y_off+105, white); } vlineColor(screen, x_off+128, y_off+106, y_off+110, white); /* Description of the axis */ stringColor(screen, x_off-5 +16 , y_off+115, "16", white); stringColor(screen, x_off-9 +128, y_off+115, "128", white); stringColor(screen, x_off-9 +240, y_off+115, "240", white); } else { for (i =0; i< 11;i++) { offset = (int)i*21.9 + 16; vlineColor(screen, x_off+offset, y_off+101, y_off+105, white); } } for (i = 0; i < 6; i++) /*Labeling the y axis in percent */ { hlineColor(screen, x_off-5, x_off, y_off+ i*20, white); offset = 100- i*20; sprintf(text, "%i", offset); stringColor(screen, x_off-30 , y_off+ i*20 -3 , text, white); } }
//------------------------------------------------------------ ShowFixation() // void ShowFixation() { hlineColor(screen, (int)(FIXATION_X - FIXATION_WIDTH / 2), \ (int)(FIXATION_X + FIXATION_WIDTH / 2), \ FIXATION_Y, RGBA_White); vlineColor(screen, FIXATION_X, (int)(FIXATION_Y - FIXATION_HEIGHT / 2), \ (int)(FIXATION_Y + FIXATION_HEIGHT / 2), \ RGBA_White); }
/* * vykresluje mrizku hraciho pole */ int drawBorder(SDL_Surface *screen) { SDL_FillRect(screen, NULL, BLACK); for(int i = 1; i < MAXX+1; ++i) { hlineColor(screen, 0, MAXY * FIELD_SIZE, i * FIELD_SIZE, 0xffffff50); } for(int i = 1; i < MAXY; ++i) { vlineColor(screen, i * FIELD_SIZE, 0, MAXX * FIELD_SIZE, 0xffffff50); } SDL_UpdateRect(screen, 0,0,0,0); return 0; }
//------------------------------------------------------------ ShowFixation() // void ShowFixation() { //-TODO- Sustituir este metodo por uno basado en pintar rectángulos // de ancho configurable por una constante en ior.h hlineColor(screen, (int)(FIXATION_X - FIXATION_WIDTH / 2), \ (int)(FIXATION_X + FIXATION_WIDTH / 2), \ FIXATION_Y, RGBA_White); vlineColor(screen, FIXATION_X, (int)(FIXATION_Y - FIXATION_HEIGHT / 2), \ (int)(FIXATION_Y + FIXATION_HEIGHT / 2), \ RGBA_White); }
void input_show_centered(int move_y) { if (input_text != NULL) { apply_surface( (screen_width - input_text->w) / 2, (screen_height - input_text->h) / 2 + move_y, input_text, screen ); } hlineColor( screen, screen_width * 0.1, screen_width * 0.9, screen_height / 2 + font_size + move_y, 0xFFFFFFFF ); }
void render_decorations(slide *sl) { int x1, y1; int below, above; SDL_Rect dst; style *st = sl->st; Uint32 border_pen = colour->pens->item(st->bordercolour); free_decorations(sl); below = sl->deck_size - sl->card; above = sl->card - 1; if(below > 0) { sl->decor.top = alloc_surface(sl->scr_w, CARD_EDGE * below); sl->decor.right = alloc_surface(CARD_EDGE * below, sl->scr_h + CARD_EDGE * below); clear_surface(sl->decor.top, colour->grey_fill); clear_surface(sl->decor.right, colour->grey_fill); for(int i = 0; i < below; i++) { // Top edge: x1 = CARD_EDGE * (i + 1); y1 = CARD_EDGE * (below - i - 1); dst.x = x1; dst.y = y1; dst.w = sl->scr_w - x1; dst.h = CARD_EDGE; SDL_FillRect(sl->decor.top, &dst, st->enablebar ? colour->fills->item(st->barcolour) : colour->fills->item(st->bgcolour)); for(int j = 0; j < st->slideborder; j++) { hlineColor(sl->decor.top, x1 + j, sl->scr_w - 1, y1 + j, border_pen); vlineColor(sl->decor.top, x1 + j, y1 + j, y1 + CARD_EDGE - 1, border_pen); } // Top-right corner: x1 = 0; y1 = CARD_EDGE * (below - i - 1); dst.x = x1; dst.y = y1; dst.w = CARD_EDGE * i; dst.h = CARD_EDGE; SDL_FillRect(sl->decor.right, &dst, st->enablebar ? colour->fills->item(st->barcolour) : colour->fills->item(st->bgcolour)); for(int j = 0; j < st->slideborder; j++) { hlineColor(sl->decor.right, 0, CARD_EDGE * (i + 1) - 1, y1 + j, border_pen); } // Right edge: x1 = CARD_EDGE * i; y1 = CARD_EDGE * (below - i - 1); dst.x = x1; dst.y = y1 + st->slideborder; dst.w = CARD_EDGE; dst.h = sl->scr_h - st->slideborder; SDL_FillRect(sl->decor.right, &dst, colour->fills->item(st->bgcolour)); for(int j = 0; j < st->slideborder; j++) { vlineColor(sl->decor.right, x1 + CARD_EDGE - 1 - j, y1, y1 + sl->scr_h - 1, border_pen); hlineColor(sl->decor.right, x1, x1 + CARD_EDGE - 1, y1 + sl->scr_h - 1 - j, border_pen); } // Titlebar area: if(st->enablebar) { x1 = CARD_EDGE * i; y1 = CARD_EDGE * (below - i - 1) + st->slideborder; dst.x = x1; dst.y = y1; dst.w = CARD_EDGE - st->slideborder; dst.h = to_screen_coords(st->titlespacing - TITLE_EDGE) - st->slideborder; SDL_FillRect(sl->decor.right, &dst, colour->fills->item(st->barcolour)); } // Dividing line below bar: x1 = CARD_EDGE * i; y1 = CARD_EDGE * (below - i - 1); if(st->enablebar) { for(int j = 0; j < st->barborder; j++) { hlineColor(sl->decor.right, x1, x1 + CARD_EDGE - 1, y1 + to_screen_coords(st->titlespacing - TITLE_EDGE - 1) + j, colour->pens->item(st->bordercolour)); } } } } if(above > 0) { sl->decor.left = alloc_surface(CARD_EDGE * above, sl->scr_h + CARD_EDGE * above); sl->decor.bottom = alloc_surface(sl->scr_w, CARD_EDGE * above); clear_surface(sl->decor.left, colour->grey_fill); clear_surface(sl->decor.bottom, colour->grey_fill); for(int i = 0; i < above; i++) { // Bottom edge: x1 = 0; y1 = CARD_EDGE * i; dst.x = x1; dst.y = y1; dst.w = sl->scr_w - CARD_EDGE * (i + 1); dst.h = CARD_EDGE; SDL_FillRect(sl->decor.bottom, &dst, colour->light_grey_fill); for(int j = 0; j < st->slideborder; j++) { hlineColor(sl->decor.bottom, 0, sl->scr_w - CARD_EDGE * (i + 1) - 1, y1 + CARD_EDGE - 1 - j, border_pen); vlineColor(sl->decor.bottom, sl->scr_w - CARD_EDGE * (i + 1) - 1 - j, y1, y1 + CARD_EDGE - 1, border_pen); } // Bottom-left corner: x1 = CARD_EDGE * (above - i - 1); y1 = sl->scr_h + CARD_EDGE * i; dst.x = x1; dst.y = y1; dst.w = (i + 1) * CARD_EDGE; dst.h = CARD_EDGE; SDL_FillRect(sl->decor.left, &dst, colour->light_grey_fill); // Left edge: x1 = CARD_EDGE * (above - i - 1); y1 = CARD_EDGE * (i + 1); dst.x = x1; dst.y = y1; dst.w = CARD_EDGE; dst.h = sl->scr_h; SDL_FillRect(sl->decor.left, &dst, colour->light_grey_fill); for(int j = 0; j < st->slideborder; j++) { hlineColor(sl->decor.left, x1, x1 + CARD_EDGE - 1, y1 + j, border_pen); hlineColor(sl->decor.left, x1, x1 + (i + 1) * CARD_EDGE - 1, y1 + sl->scr_h - 1 - j, border_pen); vlineColor(sl->decor.left, x1 + j, y1, y1 + sl->scr_h - 1, border_pen); } } } }
void render_background(slide *sl, SDL_Surface *surface) { SDL_Rect dst; style *st = sl->st; // Set slide area to the background colour: dst.x = 0; dst.y = 0; dst.w = sl->des_w; dst.h = sl->des_h; SDL_FillRect(surface, &dst, colour->fills->item(st->bgcolour)); // Fill in the titlebar area: if(st->enablebar) { dst.h = st->titlespacing - TITLE_EDGE; SDL_FillRect(surface, &dst, colour->fills->item(st->barcolour)); } // Draw background image or texture: if(st->background != NULL) { int src_w, src_h, dst_w, dst_h; SDL_Surface *scaled; SDL_Rect dst; // Scale background image to fit this slide: src_w = st->background->w; src_h = st->background->h; dst_w = sl->des_w; if(st->bgbar || !st->enablebar) { dst_h = sl->des_h; dst.y = 0; } else { dst_h = sl->des_h - (st->titlespacing - TITLE_EDGE); dst.y = st->titlespacing - TITLE_EDGE; } scaled = zoomSurface(st->background, (double)dst_w / (double)src_w, (double)dst_h / (double)src_h, 1); // Blit: dst.x = 0; SDL_BlitSurface(scaled, NULL, surface, &dst); SDL_FreeSurface(scaled); } else if(st->texture != NULL) { SDL_Rect dst; int w, h; int xrepeats, yrepeats; int vert_offset; w = st->texture->w; h = st->texture->h; if(st->bgbar || !st->enablebar) vert_offset = 0; else vert_offset = st->titlespacing - TITLE_EDGE; xrepeats = SCREEN_WIDTH / w; if(SCREEN_WIDTH % w > 0) xrepeats++; yrepeats = (SCREEN_HEIGHT - vert_offset) / h; if((SCREEN_HEIGHT - vert_offset) % h > 0) yrepeats++; for(int x = 0; x < xrepeats; x++) { for(int y = 0; y < yrepeats; y++) { dst.x = x * w; dst.y = vert_offset + y * h; SDL_BlitSurface(st->texture, NULL, surface, &dst); } } } // Draw the slide border: for(int i = 0; i < st->slideborder; i++) { rectangleColor(surface, i, i, sl->des_w - 1 - i, sl->des_h - 1 - i, colour->pens->item(st->bordercolour)); } // Draw dividing line between titlebar and slide body, and the slide title: if(st->enablebar) { char *title = sl->content->line; int xbase = st->leftmargin + st->foldmargin; for(int i = 0; i < st->barborder; i++) { hlineColor(surface, 1, sl->des_w - 2, st->titlespacing - TITLE_EDGE - 1 + i, colour->pens->item(st->bordercolour)); } render_text(title, st->title_font, colour->inks->item(st->titlecolour), surface, xbase, (st->titlespacing - TITLE_EDGE - (st->title_ascent - st->title_descent)) / 2 - 1 + st->topmargin); } }
void highlight(slide *sl, int viewx, int viewy, int scale) { int x1, y1, x2, y2; int clearance, extent, thickness; if(scale == 1) { thickness = 5; clearance = 9; extent = 90; } else if(scale == 3) { thickness = 3; clearance = 5; extent = 40; } else if(scale == 9) { thickness = 2; clearance = 2; extent = 20; } else { error("Impossible case in highlight()"); exit(-1); } if(extent > sl->scr_w / scale) extent = sl->scr_w / scale; if(extent > sl->scr_h / scale) extent = sl->scr_h / scale; x1 = (sl->x - viewx) / scale - clearance; x2 = (sl->x + sl->scr_w - 1 - viewx) / scale + clearance; y1 = (sl->y - viewy) / scale - clearance; y2 = (sl->y + sl->scr_h - 1 - viewy) / scale + clearance; for(int i = 0; i < thickness; i++) { // Top left: hlineColor(screen, x1 - i, x1 + extent + i, y1 - i, colour->red_pen); vlineColor(screen, x1 - i, y1 - i, y1 + extent + i, colour->red_pen); // Top right: hlineColor(screen, x2 - extent - i, x2 + i, y1 - i, colour->red_pen); vlineColor(screen, x2 + i, y1 - i, y1 + extent + i, colour->red_pen); // Bottom left: hlineColor(screen, x1 - i, x1 + extent + i, y2 + i, colour->red_pen); vlineColor(screen, x1 - i, y2 - extent - i, y2 + i, colour->red_pen); // Bottom right: hlineColor(screen, x2 - extent - i, x2 + i, y2 + i, colour->red_pen); vlineColor(screen, x2 + i, y2 - extent - i, y2 + i, colour->red_pen); } }
void WaveDrawBox_vrefresh(void *vthis) { WaveDrawBox *this = WAVE_DRAW_BOX(vthis); if ((! this->sample_freq) || (! this->bunch)) { fprintf(stderr, "WaveDrawBox_vrefresh: Failed on assertion ((! this->sample_freq) || (! this->bunch)) == true\n%s\n", toString(this)); WIDGET(this)->visible = false; return; } this->xrange = this->sample_freq / this->bunch + 1; this->zero_x = this->padx; this->zero_y = WIDGET(this)->pos.h >> 1; WIDGET(this)->pos.w = this->xrange + (this->padx << 1); WIDGET(this)->maxx = WIDGET(this)->pos.x + WIDGET(this)->pos.w; WIDGET(this)->maxy = WIDGET(this)->pos.y + WIDGET(this)->pos.h; if (DEBUG) fprintf(stderr, "WaveDrawBox_vrefresh: [1] %s\n", toString(this)); if (WIDGET(this)->surf) { if (DEBUG) fprintf(stderr, "WaveDrawBox_vrefresh: [2] Surface exists filling with BGCOLOR\n"); if (SDL_FillRect(WIDGET(this)->surf, NULL, WDB_BGCOLOR)) { fprintf(stderr, "WaveDrawBox_vrefresh: [1] Failed to fill background surface (FillRect) %s\n", SDL_GetError()); WIDGET(this)->visible = false; return; } } else { if (DEBUG) fprintf(stderr, "WaveDrawBox_vrefresh: [2] Surface not exists creating\n"); if (! (WIDGET(this)->surf = Static_newSurface(WIDGET(this)->pos.w, WIDGET(this)->pos.h))) { fprintf(stderr, "WaveDrawBox_vrefresh: Failed to fill create background surface (SDL_CreateRGBSurface) %s\n", SDL_GetError()); WIDGET(this)->visible = false; return; } if (DEBUG) fprintf(stderr, "WaveDrawBox_vrefresh: [2] Filling created surface with BGCOLOR\n"); if (SDL_FillRect(WIDGET(this)->surf, NULL, WDB_BGCOLOR)) { fprintf(stderr, "WaveDrawBox_vrefresh: [2] Failed to fill background surface (FillRect) %s\n", SDL_GetError()); WIDGET(this)->visible = false; return; } } /* Draw axes */ u16 y1 = WIDGET(this)->pos.h - this->pady - this->my; u16 x1 = this->padx + this->xrange; this->relx_min = this->zero_x; this->relx_max = x1-1; this->rely_min = this->pady + this->my; this->rely_max = y1; hlineColor(WIDGET(this)->surf, this->padx, x1, WIDGET(this)->pos.h >> 1, WDB_AXES_COLOR); hlineColor(WIDGET(this)->surf, this->padx, x1, this->rely_min, WDB_MAXY_COLOR); hlineColor(WIDGET(this)->surf, this->padx, x1, y1, WDB_MAXY_COLOR); y1 += this->my; vlineColor(WIDGET(this)->surf, this->padx, this->pady, y1, WDB_AXES_COLOR); vlineColor(WIDGET(this)->surf, x1, this->pady, y1, WDB_AXES_COLOR); this->yrange = this->rely_max - this->rely_min; if (this->xrange != (this->relx_max - this->relx_min + 1)) { fprintf(stderr, "WaveDrawBox_vrefresh: Failed on assertion (this->xrange != (this->relx_max - this->relx_min + 1)) == true\n%s\n", toString(this)); WIDGET(this)->visible = false; return; } if ((this->xrange == 0) || (this->xrange >= this->sample_freq)) { fprintf(stderr, "WaveDrawBox_vrefresh: Failed on assertion ((this->xrange == 0) || (this->xrange >= this->sample_freq)) == true\n%s\n", toString(this)); WIDGET(this)->visible = false; return; } if (! this->points) { this->points = calloc(this->xrange, sizeof(wdb_point)); this->afg->points = this->points; this->afg->points_size = this->xrange; } if (! this->samples) { this->samples = calloc(this->sample_freq, sizeof(float)); this->afg->samples = this->samples; this->afg->samples_size = this->sample_freq; } if (DEBUG) { fprintf(stderr, "WaveDrawBox_vrefresh: Final: %s\n", toString(this)); fprintf(stderr, "WaveDrawBox_vrefresh: Surface: %s\n", Static_surfaceToString(WIDGET(this)->surf)); } WIDGET(this)->visible = true; }
/** * Desenhador de RectNoScrolling retirado da SDL_gfx mais nova. */ int Sprite::drawRoundRectNoScrolling(Rectangle rect, int r, int g, int b, int a, int rad, Screen *screen) { SDL_Surface * dst; Sint16 x1, y1, x2, y2; Uint32 color; int result; dst = screen->getTopScreen(); x1 = rect.x; x2 = rect.x + rect.w; y1 = rect.y; y2 = rect.y + rect.h; color = ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a; Sint16 w, h, tmp; Sint16 xx1, xx2, yy1, yy2; /* * Check destination surface */ if (dst == NULL) { return -1; } /* * Check radius vor valid range */ if (rad < 0) { return -1; } /* * Special case - no rounding */ if (rad == 0) { return rectangleColor(dst, x1, y1, x2, y2, color); } /* * Check visibility of clipping rectangle */ if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) { return 0; } /* * Test for special cases of straight lines or single point */ if (x1 == x2) { if (y1 == y2) { return (pixelColor(dst, x1, y1, color)); } else { return (vlineColor(dst, x1, y1, y2, color)); } } else { if (y1 == y2) { return (hlineColor(dst, x1, x2, y1, color)); } } /* * Swap x1, x2 if required */ if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; } /* * Swap y1, y2 if required */ if (y1 > y2) { tmp = y1; y1 = y2; y2 = tmp; } /* * Calculate width&height */ w = x2 - x1; h = y2 - y1; /* * Maybe adjust radius */ if ((rad * 2) > w) { rad = w / 2; } if ((rad * 2) > h) { rad = h / 2; } /* * Draw corners */ result = 0; xx1 = x1 + rad; xx2 = x2 - rad; yy1 = y1 + rad; yy2 = y2 - rad; result |= arcColor(dst, xx1, yy1, rad, 180, 270, color); result |= arcColor(dst, xx2, yy1, rad, 270, 360, color); result |= arcColor(dst, xx1, yy2, rad, 90, 180, color); result |= arcColor(dst, xx2, yy2, rad, 0, 90, color); /* * Draw lines */ if (xx1 <= xx2) { result |= hlineColor(dst, xx1, xx2, y1, color); result |= hlineColor(dst, xx1, xx2, y2, color); } if (yy1 <= yy2) { result |= vlineColor(dst, x1, yy1, yy2, color); result |= vlineColor(dst, x2, yy1, yy2, color); } return 1; }