void GUIDropDown::Draw(SDL_Surface *dst){ boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFFF); rectangleColor(dst,posX1,posY1,posX2,posY2,BORDER); selectedText.Blit(dst,posX1+3,posY1+2,posX2-posX1-3,posY2-posY1-2,false,true); if(isPressed)boxColor(dst,arrX1,arrY1,arrX2,arrY2,CLICKABLE_DOWN); else boxColor(dst,arrX1,arrY1,arrX2,arrY2,CLICKABLE_UP); rectangleColor(dst,arrX1,arrY1,arrX2,arrY2,BORDER); filledTrigonColor(dst,triX1,triY1,triX2,triY2,triX3,triY3,0x00000080); if(listBox.doDraw&&!hasRegistered)listBox.Draw(dst); }
/* render time and bar remained till the end of the wave */ void render_wave_time() { char str[20]; Uint32 time_passed, one_percent, percents_passed; Uint32 color = 0x00FF00FF; /* green, 0xRRGGBBAA */ /* time passed from start of the wave */ time_passed = SDL_GetTicks() - waves[global.wave].start_time; one_percent = waves[global.wave].duration/100; //600ms percents_passed = time_passed / one_percent; /* word TIME */ render_text(12,"WAVE",WINDOW_WIDTH-155, WINDOW_HEIGHT-15,color); /* time bar. we assume TIME_BAR_W is 100 always ;) */ if (TIME_BAR_W > percents_passed) boxColor(global.screen, TIME_BAR_X, WINDOW_HEIGHT-15, TIME_BAR_X + TIME_BAR_W - percents_passed, WINDOW_HEIGHT-5, 0x32CD32FF); rectangleColor(global.screen, WINDOW_WIDTH - 120, WINDOW_HEIGHT-15, WINDOW_WIDTH - 20, WINDOW_HEIGHT-5, 0x008000FF); /* digits on the top of bar */ //sprintf(str,"%u",percents_passed); //render_text(12,str, WINDOW_WIDTH/2 + 25,WINDOW_HEIGHT-100,0xFFFFFFFF); }
void GUIListBox::Draw(SDL_Surface *dst){ boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFFF); if(showSelectionBox)boxColor(dst,selX1,selY1,selX2,selY2,0x6699FFFF); renderedText.Blit(dst,textX1,textY1,textX2-textX1,textY2-textY1,false,false,curOffX,curOffY); rectangleColor(dst,posX1,posY1,posX2,posY2,BORDER); scroll.Draw(dst); }
void RS232Console::render(Dashboard *dash, SDLColor color, SDLColor bg_color, int font_size) { int char_width, char_height, height, width, mid_height; getCharMetrics(dash, char_width, char_height); getMetrics(dash, width, mid_height, height); rectangleColor(dash->screen, x, y, x + width - 1, y + height - 1, color.toUInt32()); lineColor(dash->screen, x, y + mid_height - 1, x + width - 1, y + mid_height - 1, color.toUInt32()); int current_y = y + 2; int to_line = min((int)stored_text.size(), scroll_position + rows); for (int i = scroll_position; i < to_line; i++) { dash->putMonoText(x + 2, current_y, stored_text[i].substr(0, columns), font_size + 2, color); current_y += char_height; } if (scrollbar_persist_frames) { drawScrollbar(dash, color); scrollbar_persist_frames--; } }
void XListBox::draw() { XItem *Item; XPOSITION pos = list_item.find(top_item); //画背景 onDrawBackground(widget_rectF); while(!pos.isEmpty()) { Item=list_item.getNext(pos); Item->draw(divider_color,item_color); if(bottom_item == Item) { break; } } //画出选中项 if(pList== this && pItem) { Uint32 color = (Uint32)SELECT_ITEM_COLOR; pItem->draw(divider_color,color); } //滚动条 vScrollbar.paint(); //边框 rectangleColor(screen,widget_rect.x,widget_rect.y,widget_rectF.x2,widget_rectF.y2,0x7991c9ff); }
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; } } }
void RS232Console::drawScrollbar(Dashboard *dash, SDLColor color) { const int PADDING = 6; const int BAR_WIDTH = 12; if ((int)stored_text.size() <= rows) return; int height, width, mid_height; getMetrics(dash, width, mid_height, height); int bar_x = x + width - PADDING - BAR_WIDTH; int bar_y = y + PADDING; int bar_w = BAR_WIDTH; int bar_h = mid_height - 2 * PADDING; int thumb_y = bar_y + bar_h * scroll_position / stored_text.size(); int thumb_h = bar_h * rows / stored_text.size(); rectangleColor(dash->screen, bar_x, bar_y, bar_x + bar_w - 1, bar_y + bar_h - 1, color.toUInt32()); boxColor(dash->screen, bar_x, thumb_y, bar_x + bar_w - 1, thumb_y + thumb_h - 1, color.toUInt32()); }
SDL_Surface* limit_Selection(SDL_Surface* origin, Selection* select) { if(origin && select && select->active) { SDL_Rect left = {.x = 0, .y = 0, .w = select->area.x, .h = origin->h}; SDL_Rect right = {.x = select->area.x + select->area.w, .y=0, .w = origin->w - (select->area.x + select->area.w), .h=origin->h}; SDL_Rect upper = {.x = select->area.x, .y= 0, .w = select->area.w, .h= select->area.y}; SDL_Rect lower = {.x = select->area.x, .y= select->area.y + select->area.h, .w = select->area.w, .h= origin->h - (select->area.y + select->area.h)}; SDL_FillRect(origin, &left, intColor_fmt(c_trans,origin->format)); SDL_FillRect(origin, &right, intColor_fmt(c_trans,origin->format)); SDL_FillRect(origin, &upper, intColor_fmt(c_trans,origin->format)); SDL_FillRect(origin, &lower, intColor_fmt(c_trans,origin->format)); } return origin; } void draw_selection(SDL_Surface* where, Selection* select, Color c){ rectangleColor(where,select->area.x,select->area.y, select->area.x + select->area.w, select->area.y + select->area.h,intColor(c)); }
void draw_legend(SDL_Surface *ecran)//, SDL_Surface *rectangle, int x, int y) { rectangleColor(ecran, 1150, 400, 950, 500, 0xffffffff); stringColor(ecran, 1000, 430, "densite", 0xff3a2aff); stringColor(ecran, 1000, 460, "repartition", 0x3a3affff); SDL_Flip(ecran); }
void GUIButton::Draw(SDL_Surface *dst){ if(isPressed&&isHovered)boxColor(dst,posX1,posY1,posX2,posY2,CLICKABLE_DOWN); else boxColor(dst,posX1,posY1,posX2,posY2,CLICKABLE_UP); rectangleColor(dst,posX1,posY1,posX2,posY2,BORDER); renderedText.Blit(dst,posX1,posY1,posX2-posX1,posY2-posY1,true,true); if(isDisabled)boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFA0); }
void Rectangle3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } float alpha = getAlpha(); xColor color = getColor(); const float MAX_COLOR = 255.0f; glm::vec4 rectangleColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); glm::vec3 position = getPosition(); glm::vec2 dimensions = getDimensions(); glm::vec2 halfDimensions = dimensions * 0.5f; glm::quat rotation = getRotation(); auto batch = args->_batch; if (batch) { Transform transform; transform.setTranslation(position); transform.setRotation(rotation); batch->setModelTransform(transform); auto geometryCache = DependencyManager::get<GeometryCache>(); if (getIsSolid()) { glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, 0.0f); glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, 0.0f); geometryCache->bindSimpleProgram(*batch); geometryCache->renderQuad(*batch, topLeft, bottomRight, rectangleColor); } else { geometryCache->bindSimpleProgram(*batch, false, false, false, true, true); if (getIsDashedLine()) { glm::vec3 point1(-halfDimensions.x, -halfDimensions.y, 0.0f); glm::vec3 point2(halfDimensions.x, -halfDimensions.y, 0.0f); glm::vec3 point3(halfDimensions.x, halfDimensions.y, 0.0f); glm::vec3 point4(-halfDimensions.x, halfDimensions.y, 0.0f); geometryCache->renderDashedLine(*batch, point1, point2, rectangleColor); geometryCache->renderDashedLine(*batch, point2, point3, rectangleColor); geometryCache->renderDashedLine(*batch, point3, point4, rectangleColor); geometryCache->renderDashedLine(*batch, point4, point1, rectangleColor); } else { if (halfDimensions != _previousHalfDimensions) { QVector<glm::vec3> border; border << glm::vec3(-halfDimensions.x, -halfDimensions.y, 0.0f); border << glm::vec3(halfDimensions.x, -halfDimensions.y, 0.0f); border << glm::vec3(halfDimensions.x, halfDimensions.y, 0.0f); border << glm::vec3(-halfDimensions.x, halfDimensions.y, 0.0f); border << glm::vec3(-halfDimensions.x, -halfDimensions.y, 0.0f); geometryCache->updateVertices(_geometryCacheID, border, rectangleColor); _previousHalfDimensions = halfDimensions; } geometryCache->renderVertices(*batch, gpu::LINE_STRIP, _geometryCacheID); } } } }
inline void DrawBox(int x0, int y0, int x1, int y1, uint color, int is_fill) { if (is_fill) boxColor(screen, x0, y0, x1, y1, color); else rectangleColor(screen, x0, y0, x1, y1, color); }
int GeoLayer::rectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t col) { if(!surf) { error("%s can't run: layer not initialized", __PRETTY_FUNCTION__); return -1; } res = rectangleColor(surf, x1, y1, x2, y2, col); if(res < 0) error("error in %s", __PRETTY_FUNCTION__); return(res); }
void TEdit::disp(SDL_Surface *s, TFont *myfont, int x, int y, int w,int h, int fg, int bg, int xoptions) { font = myfont; font->set_utf(is_utf); if (*menu->label) { // Draw the static without a changing bg TStatic::disp(s,myfont,x,y,xoptions-x,h,mymakecol(255,255,255),0,xoptions); w -= xoptions - x; x = xoptions; } rectangleColor(s,x,y,x+maxw-1,y+h-1,mymakecol(255,255,255)); // boxColor(s,x+1,y+1,x+maxw-3,y+h-3,bg_color); if (field[0]) { int w,h; font->dimensions(field,&w,&h); // -8 for the size of the cursor in the end.. int max = (pos == strlen(field) ? maxw-8 : maxw); if (w > max) { unsigned int p; char old = 0; int end; for (p=0; p<strlen(field) && p<pos; p++) { font->dimensions(&field[p],&w,&h); if (w <= max) break; } if (w > max) { for (end=strlen(field)-1; end>=0; end--) { old = field[end]; field[end] = 0; font->dimensions(&field[p],&w,&h); if (w <= max) break; field[end] = old; } } font->surf_string(s,x+1,y+1,&field[p],fg_color,0,0); if (old) field[end] = old; old = field[pos]; field[pos] = 0; font->dimensions(&field[p],&curx,&curh); curx += x+1; field[pos] = old; } else { font->surf_string(s,x+1,y+1,field,fg_color,0,0); char old = field[pos]; field[pos] = 0; font->dimensions(field,&curx,&curh); curx += x+1; field[pos] = old; } } else { curx = x+1; curh = h; } cury = y; mys = s; if (bg && cursor_on) { update_cursor(); } }
/***************************************************************** 関数名 : DrawRectangle 機能 : メインウインドウに四角を表示する 引数 : int x : 四角の左上の x 座標 int y : 四角の左上の y 座標 int width : 四角の横幅 int height : 四角の高さ 出力 : なし *****************************************************************/ void DrawRectangle(int x,int y,int width,int height) { #ifndef NDEBUG printf("#####\n"); printf("DrawRectangle()\n"); printf("x=%d,y=%d,width=%d,height=%d\n",x,y,width,height); #endif rectangleColor(gMainWindow,x,y,x+width,y+height,0x000000ff); SDL_Flip(gMainWindow); }
CAMLprim value ml_rectangleColor(value dst,value p1,value p2, value col) { SDL_Surface *sur= SDL_SURFACE(dst); SDL_Rect rect1, rect2; int r; SDLRect_of_value(&rect1,p1); SDLRect_of_value(&rect2,p2); r=rectangleColor(sur,rect1.x,rect1.y,rect2.x,rect2.y,Int32_val(col)); return Val_bool(r); }
void GUIScrollBar::Draw(SDL_Surface *dst){ boxColor(dst,trackX1,trackY1,trackX2,trackY2,0xFFFFFFFF); rectangleColor(dst,trackX1,trackY1,trackX2,trackY2,BORDER); if(arrowW>0){ if(arrADown)boxColor(dst,arrAX1,arrAY1,arrAX2,arrAY2,CLICKABLE_DOWN); else boxColor(dst,arrAX1,arrAY1,arrAX2,arrAY2,CLICKABLE_UP); if(arrBDown) boxColor(dst,arrBX1,arrBY1,arrBX2,arrBY2,CLICKABLE_DOWN); else boxColor(dst,arrBX1,arrBY1,arrBX2,arrBY2,CLICKABLE_UP); rectangleColor(dst,arrBX1,arrBY1,arrBX2,arrBY2,BORDER); rectangleColor(dst,arrAX1,arrAY1,arrAX2,arrAY2,BORDER); filledTrigonColor(dst,triAX1,triAY1,triAX2,triAY2,triAX3,triAY3,0x00000080); filledTrigonColor(dst,triBX1,triBY1,triBX2,triBY2,triBX3,triBY3,0x00000080); } if(!isDisabled){ boxColor(dst,slidX1,slidY1,slidX2,slidY2,0xD4D0C8FF); rectangleColor(dst,slidX1,slidY1,slidX2,slidY2,0x404040FF); } }
void affichage(){ cpFloat timeStep = 1.0/60.0; SDL_Color white={255,255,255}; for(cpFloat time = 0; time < 25; time += timeStep){ SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format,0,0,0)); for(int i=0;i<50;i++){ if(lesBoules[i].del==FALSE){ cpVect pos = cpBodyGetPos(lesBoules[i].body); cpVect vel = cpBodyGetVel(lesBoules[i].body); rectangleColor(ecran,10, 0, 630, 420,SDL_MapRGB(ecran->format,255,255,255)); circleRGBA(ecran, pos.y, pos.x, lesBoules[i].radius, lesBoules[i].r,lesBoules[i].g,lesBoules[i].b,lesBoules[i].a); filledCircleRGBA(ecran,pos.y,pos.x,lesBoules[i].radius, lesBoules[i].r,lesBoules[i].g,lesBoules[i].b,lesBoules[i].a); //lettre SDL_Surface *lettre= TTF_RenderText_Solid(police, lesBoules[i].lettre, white); SDL_Rect position; position.y=pos.x; position.x=pos.y; lesBoules[i].x=pos.x; lesBoules[i].y=pos.y; SDL_BlitSurface(lettre, NULL, ecran, &position); } } SDL_Surface *pointsTexte=TTF_RenderText_Solid(police,"Score:" , white); SDL_Rect position_pointsTexte; position_pointsTexte.y=435; position_pointsTexte.x=10; SDL_BlitSurface(pointsTexte, NULL, ecran, &position_pointsTexte); char scoreChar[15]={"0"}; snprintf(scoreChar, 15, "%d", score); SDL_Surface *points=TTF_RenderText_Solid(police,scoreChar, white); SDL_Rect position_points; position_points.y=435; position_points.x=100; SDL_BlitSurface(points, NULL, ecran, &position_points); cpSpaceStep(espace, timeStep); SDL_Flip(ecran); } //affichage points SDL_Flip(ecran); }
void foldicon(int folded, int exposure_level, int x, int top, int height, int y, SDL_Surface *surface, style *st, int highlighted) { // x is a left edge, y is a centre SDL_Surface *icon; int colour_index; if(folded) icon = st->collapsedicon; else icon = st->expandedicon; colour_index = folded ? st->foldcollapsedcolour : st->foldexpandedcolour; if(highlighted) colour_index = st->highlightcolour; if(!folded) { Uint32 pen; exposure_level++; if(exposure_level == 1) pen = colour->pens->item(st->foldexposed1colour); else if(exposure_level == 2) pen = colour->pens->item(st->foldexposed2colour); else pen = colour->pens->item(st->foldexposed3colour); /* boxColor(surface, x + 7, y, x + 13, y + (st->text_ascent - st->text_descent), pen); */ boxColor(surface, x + 7, y, x + 13, top + height - 1, pen); } if(icon == NULL) { boxColor(surface, x, y - 10, x + 20, y + 10, colour->pens->item(colour_index)); rectangleColor(surface, x, y - 10, x + 20, y + 10, colour->black_pen); filledTrigonColor(surface, x + 3, y - 6, x + 17, y - 6, x + 10, y + 6, colour->white_pen); aatrigonColor(surface, x + 3, y - 6, x + 17, y - 6, x + 10, y + 6, colour->black_pen); } else { SDL_Rect dst; dst.x = x + 10 - (icon->w / 2); dst.y = y - (icon->h / 2); SDL_BlitSurface(icon, NULL, surface, &dst); } }
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); } }
void GUICheckBox::Draw(SDL_Surface *dst){ if(isCircle){ int rad = ((posX2-posX1<posY2-posY1)?(posX2-posX1):(posY2-posY1))-7; filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,0xFFFFFFFF); aacircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,BORDER); if(isChecked){ filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad-3,0x000000FF); aacircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad-3,0x000000FF); } }else{ boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFFF); rectangleColor(dst,posX1,posY1,posX2,posY2,BORDER); if(isChecked){ thickLineColor(dst,posX1+1,posY1+1,posX2-1,posY2-1,3,0x000000FF); thickLineColor(dst,posX1+1,posY2-1,posX2-1,posY1+1,3,0x000000FF); } } }
/* word shield, bar, digits */ void render_shield_energy() { char str[20]; Uint32 color = 0x4169E1FF; /* royal blue */ if (!bonus[BONUS_DEF_SHIELD].on_player) return; /* word SHIELD */ render_text(12,"SHIELD",WINDOW_WIDTH/2 -70 ,WINDOW_HEIGHT-15,color); /* energy bar */ boxColor(global.screen, SHIELD_BAR_X, WINDOW_HEIGHT-15, SHIELD_BAR_X + bonus_defshield.energy, WINDOW_HEIGHT-5,color); rectangleColor(global.screen, SHIELD_BAR_X, WINDOW_HEIGHT-15, SHIELD_BAR_X + SHIELD_BAR_W, WINDOW_HEIGHT-5, 0x0000FFFF); /* digits on the top of bar */ sprintf(str,"%u",bonus_defshield.energy); render_text(12,str, WINDOW_WIDTH/2 + 25,WINDOW_HEIGHT-15,0xFFFFFFFF); }
//****************************************** void XEditBox::draw() { char *p=(char *)text.c_str(); //背景 onDrawBackground(widget_rectF); rectangleColor(screen,widget_rect.x,widget_rect.y,widget_rectF.x2,widget_rectF.y2,box_color); if(widget_state == X_RELEASED) { //显示光标左半部分 if(cursor_postion>0) { SDL_Rect rect={widget_rect.x+2,text_rect.y,cursor_postion,text_rect.h}; string str; str.append(p,start_pointer,cursor_addr); font->displayRight(str.c_str(),font_color,rect); } // 显示光标右半部分 if(widget_rect.w-cursor_postion>0){ string str; SDL_Rect rect={cursor_postion+text_rect.x,text_rect.y, widget_rect.w-cursor_postion-2,text_rect.h}; str.append(p,cursor_addr,strlen(p) - cursor_addr); font->displayLeft(str.c_str(),font_color,rect); } }else if(widget_state == X_ORIGINAL) { text_rect.x=widget_rect.x+2; text_rect.y=(widget_rect.h - font->getFontHeight())/2+widget_rect.y; text_rect.w=widget_rect.w-3; text_rect.h=widget_rect.h; font->display(text.c_str(),font_color,text_rect); } }
void XListBox::initDraw() { int h=0; int i=0; widget_state = X_PRESSED; top_position=widget_rect.y; //顶部item的y1坐标 XPOSITION pos = list_item.getHeadPosition(); onDrawBackground(widget_rectF); //画item if( !list_item.isEmpty()) { top_item=list_item.getNext(pos); h=top_item->getHeight(); top_item->setLocation(widget_rect.x,widget_rect.y); top_item->draw(divider_color,item_color); while(!pos.isEmpty()) { bottom_item=list_item.getNext(pos); bottom_item->setLocation(widget_rect.x,widget_rect.y+h); h+=bottom_item->getHeight(); bottom_item->draw(divider_color,item_color); if(h>= widget_rect.h) { break; } } bottom_position=h+widget_rect.y; //底部item的y2坐标 } //画Border rectangleColor(screen,widget_rectF.x1,widget_rectF.y1,widget_rectF.x2,widget_rectF.y2,0x7991c9ff); vScrollbar.paint(); }
void NeuralNet::Draw(SDL_Surface *dst, int posX1, int posY1, int posX2, int posY2){ float spaceX = (float)(posX2-posX1)/nodeCount; float spaceY = (float)(posY2-posY1)/nodeCount; for(unsigned int x = 0; x<nodeCount; x++){ for(unsigned int y = 0; y<nodeCount; y++){ int px1 = posX1 + x*spaceX, px2 = px1 + spaceX; int py1 = posY1 + y*spaceY, py2 = py1 + spaceY; float w = 1.-weights[x][y], v = nodes[(x < y)?y:x].val; Uint8 r,g,b,a = 0xFF; if(v < 0.){ r = (176*w)+(-v*79); g = 176*w; b = 176*w; }else{ r = 176*w; g = 176*w; b = (176*w)+(v*79); } boxRGBA(dst,px1,py1,px2,py2,r,g,b,a); } } rectangleColor(dst,posX1,posY1,posX2,posY2,0x000000FF); }
static PyObject* _gfx_rectanglecolor (PyObject *self, PyObject* args) { PyObject *surface, *color, *rect; SDL_Rect sdlrect; Sint16 x1, x2, _y1, y2; pguint32 c; ASSERT_VIDEO_INIT (NULL); if (!PyArg_ParseTuple (args, "OOO:rectangle", &surface, &rect, &color)) return NULL; if (!PySDLSurface_Check (surface)) { PyErr_SetString (PyExc_TypeError, "surface must be a Surface"); return NULL; } if (!SDLRectFromRect (rect, &sdlrect)) return NULL; x1 = sdlrect.x; _y1 = sdlrect.y; x2 = (Sint16) (sdlrect.x + sdlrect.w); y2 = (Sint16) (sdlrect.y + sdlrect.h); if (!ColorFromObj (color, &c)) return NULL; if (rectangleColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, (Uint32)c) == -1) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
void draw (void) { double now, dt; struct unit *up; struct pathblock *pp; now = get_secs (); if (destimg.drawing) { dt = floor (10 * (now - destimg.lasttime)); if (dt < 8) { switch ((int) dt) { case 0: draw_blit (destimg.frames[0], destimg.x, destimg.y); break; case 1: draw_blit (destimg.frames[1], destimg.x, destimg.y); break; case 2: draw_blit (destimg.frames[2], destimg.x, destimg.y); break; case 3: draw_blit (destimg.frames[3], destimg.x, destimg.y); break; case 4: draw_blit (destimg.frames[4], destimg.x, destimg.y); break; case 5: draw_blit (destimg.frames[5], destimg.x, destimg.y); break; case 6: draw_blit (destimg.frames[6], destimg.x, destimg.y); break; case 7: draw_blit (destimg.frames[7], destimg.x, destimg.y); break; } } else { destimg.drawing = 0; } } for (pp = first_pathblock; pp; pp = pp->next) { boxColor (screen, pp->left, pp->top, pp->right, pp->bottom, pp->color); } for (up = first_unit; up; up = up->next) { boxColor (screen, up->left, up->top, up->right, up->bottom, up->color); if (up->selected == 1) { circleColor (screen, up->center_x, up->center_y, hypot (up->h / 2, up->w / 2) + 3, 0x00ff00ff); aacircleColor (screen, up->center_x, up->center_y, hypot (up->h / 2, up->w / 2) + 3, 0x00ff00ff); } } if (selectbox.drawing) { rectangleColor (screen, selectbox.x1, selectbox.y1, selectbox.x2, selectbox.y2, selectbox.color); } }
void Simulation::DrawInfoGUI(SDL_Surface *dst, int posX1, int posY1, int posX2, int posY2){ sprintf(buffer, "Casfire Artificial Life v1.1 - 2012\n" "http://casfire.com\n\n" "Critters: %u\n" "Food: %u\n" "Frame: %"PRIu64 ,critCount ,foodCount ,frameCount ); if(critSelected){ infoText.Render(buffer,0x000000FF,13); infoText.Blit(dst,posX1,posY1,posX2-posX1,posY2-posY1,false,false); Critter *c = &critter[critSelect]; float xsize = (posX2 - posX1); Uint32 fillColor = 0x00AA00FF, badColor = 0xFF0000FF, goodColor = 0x00FF00FF; c->Draw(dst,posX1 + xsize*0.8,posY1 + xsize*0.2 - 10,xsize*0.2); int px1 = posX1 + 100, px2 = posX2, pxh = (px1+px2)/2; xsize = (px2 - px1); posY1 += 170; infoText.Render("Size:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); boxColor(dst,px1,posY1,px1+(xsize*c->in_size),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; infoText.Render("Hunger:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); boxColor(dst,px1,posY1,px1+(xsize*(1.-c->in_energy)),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; infoText.Render("Waste:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); boxColor(dst,px1,posY1,px1+(xsize*c->in_waste),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; infoText.Render("Age:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); boxColor(dst,px1,posY1,px1+(xsize*c->in_age),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; infoText.Render("Membrane:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); boxColor(dst,px1,posY1,px1+(xsize*(0.5*(c->out_expose+1.))),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; float val; infoText.Render("Mood:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); val = c->out_mood; if(val<0.)boxColor(dst,px1+(xsize*0.5*(val+1.)),posY1,pxh,posY1+15,badColor); else boxColor(dst,pxh,posY1,pxh+xsize*(val*0.5),posY1+15,goodColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; infoText.Render("Spin:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); val = c->out_spin; if(val<0.)boxColor(dst,px1+(xsize*0.5*(val+1.)),posY1,pxh,posY1+15,fillColor); else boxColor(dst,pxh,posY1,pxh+xsize*(val*0.5),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; infoText.Render("Speed:",0x000000FF,11); infoText.Blit(dst,posX1,posY1,posX2-posX1,15,false,true); val = c->out_move; if(val<0.)boxColor(dst,px1+(xsize*0.5*(val+1.)),posY1,pxh,posY1+15,fillColor); else boxColor(dst,pxh,posY1,pxh+xsize*(val*0.5),posY1+15,fillColor); rectangleColor(dst,px1,posY1,px2,posY1+15,0x000000FF); posY1 += 20; }else{ infoText.Render(buffer,0x000000FF,13); infoText.Blit(dst,posX1,posY1,posX2-posX1,posY2-posY1,true,true); } }
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 Renderer::draw ( const Rectangle& ent ) { AABB aabb = ent.get_AABB(); rectangleColor( m_renderer, aabb.min.x, aabb.min.y, aabb.max.x, aabb.max.y, ent.get_colour() ); }