void SimpleBallGameWidget::paintGL() { glEnable(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glColor3f(1, 1, 1); // Draw background glPushMatrix(); const float BOX_WIDTH = 130.0f; const float BOX_HEIGHT = 84.0f; glTranslatef(-BOX_WIDTH / 2, -BOX_HEIGHT / 2, -100.0); glBindTexture(GL_TEXTURE_2D, m_backgroundTexture); drawRectangle(0.0, 0.0, BOX_WIDTH, BOX_HEIGHT); glPopMatrix(); // Draw ball glPushMatrix(); const float RADIUS = 11.0f; // Ball point is in logical units, let's convert it to OpenGL units. const float yPixel = ((m_ballPoint.ry()/MAX_LOGICAL) * MAX_BALL_Y_PX) + MIN_BALL_Y_PX; glTranslatef(0, -35.0 + yPixel, -90.0); glBindTexture(GL_TEXTURE_2D, m_ballTexture); drawRectangle(-RADIUS, -RADIUS, RADIUS, RADIUS); glPopMatrix(); glFlush(); glDisable(GL_TEXTURE_2D); }
int movePaddle(int padDir, float* topY, float MOVE_DISTANCE, int PAD_HEIGHT, bool** ledArray, float LEFT_X, int PAD_WIDTH, float TOP_MARGIN, float BOT_END) { if(padDir != 1 && padDir != 5) { padDir = 0; return padDir; } else if(padDir == 1 && (int) (*topY + 0.5) - MOVE_DISTANCE < TOP_MARGIN) { padDir = 0; return padDir; } else if(padDir == 5 && (int) (*topY + 0.5) + PAD_HEIGHT - 1 + MOVE_DISTANCE > BOT_END) { padDir = 0; return padDir; } if(padDir == 1 && (int) (*topY) != (int) (*topY - MOVE_DISTANCE)) { drawRectangle(ledArray, false, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH); *topY -= MOVE_DISTANCE; drawRectangle(ledArray, true, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH); } else if(padDir == 5 && (int) (*topY) != (int) (*topY + MOVE_DISTANCE)) { drawRectangle(ledArray, false, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH); *topY += MOVE_DISTANCE; drawRectangle(ledArray, true, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH); } return padDir; }
void drawTopRotor(float r, float angle){ glPushMatrix(); glRotatef(angle,0.0f,1.0f,0.0f); drawRectangle(r,r/10.0f,r/20.0f); glRotatef(180.0f,0.0f,1.0f,0.0f); drawRectangle(r,r/10.0f,r/20.0f); glPopMatrix(); }
void SpaceShip::draw() const { drawRectangle(body, COLOR); drawRectangle(cannon, COLOR); for (int i = 0; i < bullets.size(); ++i) { if (bullets[i].isAlive()) { bullets[i].draw(); } } }
void DrawingContext::drawRectangleFilledWithBorder(GLfloat x, GLfloat y, GLfloat width, GLfloat height) { glLineWidth(0); glColor3f(fillR, fillG, fillB); drawRectangle(GL_QUADS, x, y, width, height); glLineWidth(lineWidth); glColor3f(lineR, lineG, lineB); drawRectangle(GL_LINE_LOOP, x, y, width, height); }
void createImage(){ int background = 0x1e5096; printf("P3\n"); printf("%i %i\n", WIDTH, HEIGHT); printf("255\n"); fillBackground(background); drawRectangle(0x1e8699, 10, 50, 100, 500, 400); drawRectangle(0x6EED1F, 20, 120, 120, 400, 500); drawImage(); }
void drawCube(float x1,float y1,float z1,float x2,float y2,float z2){ float z=z2-z1; float d=30,x3,y3,x4,y4; drawRectangle(x1,y1,x2,y2); x3=pres(x1,z,d); y3=pres(y1,z,d); x4=pres(x2,z,d); y4=pres(y2,z,d); drawRectangle(x3,y3,x4,y4); line(x1,y1,x3,y3); line(x2,y2,x4,y4); line(x1,y2,x3,y4); line(x2,y1,x4,y3); }
void drawSpectrum::draw(int result[9]){ for (int i = 0; i < 9; i++) { if (result[i] < previousFlow[i]) { int debutEffacement = (previousFlow[i]>8) ? 8 : previousFlow[i]; int x = 9 - debutEffacement; drawRectangle(i, debutEffacement, x, 1, 12); previousFlow[i] --; } else { drawRectangle(i, 0, result[i], 1, 60); previousFlow[i] = result[i]; } } }
void Draw::renderRect() { std::stack <int> tempPoints; std::stack <char *> tempColor; tempPoints=pointlist; tempColor=colorlist; if (pointlist.size()/4!=(colorlist.size())) std::cout<<"Error,mismatch between number of colors and points in the rectangle"<<std::endl; while(!tempPoints.empty()) { int x = tempPoints.top(); tempPoints.pop(); int y = tempPoints.top(); tempPoints.pop(); int width = tempPoints.top(); tempPoints.pop(); int height = tempPoints.top(); tempPoints.pop(); drawRectangle(x,y,width,height,tempColor.top()); tempColor.pop(); } }
void Button::draw ( int _x, int _y ) { std::pair< int, int > dimensions = calculateTextSize(); drawRectangle( _x, _y, dimensions.first + 2 * PADDING, dimensions.second + 2 * PADDING ); drawText( _x + PADDING, _y + PADDING ); }
void KoToolDockMoveManager::doMove( QWidget* _w ) { if (working) return; working=true; isDoMove = true; mirrorX=false; mirrorY=false; setWidget(_w); offX = rx - p.x(); offY = ry - p.y(); orig_x = p.x(); orig_y = p.y(); orig_w = w; orig_h = h; QApplication::setOverrideCursor(QCursor(sizeAllCursor)); movePause(false,false); drawRectangle(xp, yp, w, h); timer->disconnect(); connect(timer,SIGNAL(timeout()),SLOT(doMoveInternal())); timer->start(0); }
void DrawingSurface::drawFilledRectangle(const Color::RGBA<float>& frontColor, const Color::RGBA<float>& backColor, float x, float y, float width, float height, float lineWidth) { if (backColor.alpha > 0) { // Draw the back as a quad with the proper color pImpl->baseShader->bindUniform("Color", backColor); const float vertices[] = { x, y + height, x, y, x + width, y, x, y + height, x + width, y, x + width, y + height }; ::glEnableVertexAttribArray(Gfx3D::Vertex<>::vaPosition); ::glVertexAttribPointer(Gfx3D::Vertex<>::vaPosition, 2, GL_FLOAT, false, 0, vertices); // Draw ::glDrawArrays(GL_TRIANGLES, 0, 6); ::glDisableVertexAttribArray(Gfx3D::Vertex<>::vaPosition); } if (frontColor != backColor && lineWidth > 0) drawRectangle(frontColor, backColor, x, y, width, height, lineWidth); }
/* draw figure what was chosen from the buttons */ void mouse(int button, int state, int x, int y) { int new_y = mapState.window_height - y; int a; Point* new_point ; a = (x > PANEL_BORD_PADDING); initFlag(x, new_y); if (mapState.drawing_state == DRAWING_RECT && a) { drawRectangle(x, new_y); } else if (mapState.drawing_state == DRAWING_CIRCLE && a) { drawCircle(x, new_y, CIRCLE_DIAMETER); } else if (mapState.drawing_state == DRAWING_LINE && a) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { mapState.DrawingLine = START; mapState.new_point = createPoint(x, new_y, mapState.points_storage, mapState.marked_point); createEdge(mapState.edges_storage, mapState.new_point, mapState.marked_point, mapState.previous_point); mapState.previous_point = mapState.new_point; } draw(); } }
//处理图片的事件处理函数 void CRecognitionTextView::OnDeal() { // TODO: 在此添加命令处理程序代码 if(src == NULL) { if(filePath !="") { src = tools.deal(filePath,src,&outlineSs,&lines,outline,isCutted); if(src == NULL) { MessageBox(TEXT("加载失败!")); } else { Invalidate(); drawRectangle(0, m_nVScrollPos); OnPaint(); } } else { MessageBox(TEXT("未加载图片!")); } } else { MessageBox(TEXT("不能处理图片!")); } }
void main(void) { unsigned char tmp; unsigned char x = 0; P1_4 = 1; //P1_4 = 0; fb_init(); keyboard_init(); EA = 1; // enable global interrupts clearDisplay(); drawRectangle(0,0,13,19); while(1) { /* tmp = readBuf(); if(tmp == 0x34) { if(x == 0){ setPx(2,2); x = 1; } else { clearPx(2,2); x = 0; } } */ } }
void Frame::drawBorder() { glLineWidth(1.0f); glColor3f(0.3f, 0.3f, 0.3f); drawRectangle( posLeft, posTop, outerWidth, outerHeight); }
void OpenGLInterface::printHistogram(Histogram &histogram, FigureRectangle rectangle) { /* Put coursor back to (0, 0, 0) */ glLoadIdentity(); int numberOfBins = histogram.getNumberOfArguments(); int numberOfCharts = histogram.getNumberOfCharts(); double binWidth = 1 / double(numberOfBins); drawArgumentLabels(histogram.getMinArgument(), histogram.getMaxArgument(), 4, rectangle); drawValueLabels(histogram.getMinValue(), histogram.getMaxValue(), 4, rectangle); rectangle.resize(0.93, 0.93); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); double leftDownX = rectangle.getMiddleX() - rectangle.getSizeX() / 2; double leftDownY = rectangle.getMiddleY() - rectangle.getSizeY() / 2; double sizeX = rectangle.getSizeX(); double sizeY = rectangle.getSizeY(); double sideGap = configurator->getSideGap(); for(int j = 0; j < numberOfCharts; j++) { FigureRectangle histogramColumn; Color color = histogram.getColor(j); histogramColumn.setColor(color); for(int i = 0; i < numberOfBins; i++) { histogramColumn.setFigure(leftDownX + i * binWidth * sizeX, leftDownY, leftDownX + ((i + 1) * binWidth - binWidth * sideGap) * sizeX, leftDownY + histogram.getValue(j, i) / histogram.getMaxValue() * sizeY); drawRectangle(histogramColumn); } } glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); }
void Orbiter::render(){ if(orbit!=NULL){ orbit->fill=fill; orbit->render(); glRotatef(angle,0,0,1); glTranslatef(orbitrad,0,0); glGetFloatv(GL_MODELVIEW_MATRIX, buffer); x=buffer[12]; y=buffer[13]; if(staticOb) glRotatef(-angle,0,0,1); if(fill) glBegin(GL_POLYGON); else glBegin(GL_LINE_LOOP); glColor4f(0,1,1,1); glVertex2f(-radius/2,-radius/2); glVertex2f(-radius/2,radius/2); glColor4f(1,0,0,1); glVertex2f(radius/2,radius/2); glVertex2f(radius/2,-radius/2); glEnd(); if(!staticOb) glRotatef(-angle,0,0,1); } else{ glLoadIdentity(); glTranslatef(x,y,0); glRotatef(angle,0,0,1); glColor3f(1,0,1); drawRectangle(radius,radius,fill); } }
void Mwars::on_pbRectangle_clicked() { if(rectangleIsRunning) { QMessageBox::critical(this, "Error", "Rectangle is already running"); return; } workerThread = new QThread(); // instantiates ScannerDraw class and the QThread scannerDraw = new ScannerDraw(this, 33, 44); // on heap scannerDraw->moveToThread(workerThread); connect(workerThread, SIGNAL(started()), scannerDraw, SLOT(drawRectangle())); connect(scannerDraw, SIGNAL(finished()), workerThread, SLOT(quit()), Qt::DirectConnection); connect(scannerDraw, SIGNAL(finished()), scannerDraw, SLOT(deleteLater())); connect(scannerDraw, SIGNAL(finished()), workerThread, SLOT(deleteLater())); connect(workerThread, SIGNAL(finished()), this, SLOT(rectangleFinished())); connect(ui->pbStopRectangle, SIGNAL(clicked()), this, SLOT(stopRectangle())); // need these signals cause can't call sockets across threads connect(scannerDraw, SIGNAL(sendScannerMssg (ushort, ushort, ushort)), this, SLOT(sendScannerMssg(ushort, ushort, ushort))); connect(scannerDraw, SIGNAL (laserOn()), this, SLOT(laserOn())); connect(scannerDraw, SIGNAL (laserOff()), this, SLOT(laserOff())); connect(scannerDraw, SIGNAL (scannerOn()), this, SLOT(scannerOn())); connect(scannerDraw, SIGNAL (scannerOff()), this, SLOT(scannerOff())); workerThread->start(); rectangleIsRunning = true; ui->pbStopRectangle->setEnabled(true); }
void advanceGame(void* gameMemory, OOGameInput* input, OOGameOutput* output) { cbgame * game = (cbgame*) gameMemory; game->input = input; game->output = output; if( !game->initialised ) { initGame(game); } game->moveDelta = game->p1.x; updateGame(game); game->moveDelta -= game->p1.x; clearScreen(game); drawPlayer(game, &game->p2); drawPlayer(game, &game->p1); // draw a rectangle at the mouse position drawRectangle(game, (ooint)input->mouse.x, (ooint)input->mouse.y, 25, 25, 0xffff0000); outputSine(game); game->time += game->input->dt; }
struct IplImage *framescompare(struct IplImage *curr, struct IplImage *prev) { int x, y, h, w; struct IplImage *res; unsigned char *pvdata, *cvdata; struct rct rectangle; h = curr->height; w = curr->width; cvdata = getvals(curr); pvdata = getvals(prev); res = ipl_cloneimg(prev); for(y = 0; y < h; y++) { for(x = 0; x < w; x++) { if(abs(cvdata[y * w + x] - pvdata[y * w + x]) > 20) { rectangle.x1 = x; rectangle.y1 = y; rectangle.x2 = x; rectangle.y2 = y; getobj(cvdata, pvdata, x, y, w, h, &rectangle); } if((rectangle.x2 - rectangle.x1) * (rectangle.y2 - rectangle.y1) > 50) { drawRectangle(res, rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2); } } } free(pvdata); free(cvdata); return res; }
void drawEntity(Game* game, Entity* entity) { if(entity->texture) { Pointf location = createPointf( entity->position.x - entity->origin.x, entity->position.y - entity->origin.y); drawTexture(game, entity->texture, location, entity->depth); } if(entity->drawRectangle) { Rectanglei rectangle = createRectanglei( (int)entity->position.x - entity->origin.x + entity->offset.x, (int)entity->position.y - entity->origin.y + entity->offset.y, entity->size.x, entity->size.y ); drawRectangle(game, rectangle, entity->color); } if(entity->sprite.alive) { drawSprite(game, &entity->sprite); } }
void GfxMgr::rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset) { int len = strlen(s); int x1, y1, x2, y2; x1 = x - 3; y1 = y - 3; x2 = x + CHAR_COLS * len + 2; y2 = y + CHAR_LINES + 2; // Draw a filled rectangle that's larger than the button. Used for drawing // a border around the button as the button itself is drawn after this. drawRectangle(x1, y1, x2, y2, border ? BUTTON_BORDER : MSG_BOX_COLOR); while (*s) { putTextCharacter(0, x + textOffset, y + textOffset, *s++, fgcolor, bgcolor, false, _vm->getFontData()); x += CHAR_COLS; } x1 -= 2; y1 -= 2; x2 += 2; y2 += 2; flushBlock(x1, y1, x2, y2); }
//在指定图层的指定位置显示指定颜色的指定文字 void displayStrings_atLayer(LAYER *layer, int x, int y, int color, int bg_color, char *strings) { int length = strlen(strings); drawRectangle(layer->buffer, layer->length, bg_color, x, y, 8 * length,15); displayStrings_CS(layer->buffer, layer->length, x, y, color,strings); layer_refresh(layer, x, y, x + length * 8, y + 16); }
/* * The rountine display() gets called each time the window is redrawn. */ void display() { glClear(GL_COLOR_BUFFER_BIT); switch(shapeType) { case S_TRIANGLE: drawTriangle(-100,0,0,250,100,0); break; case S_RECTANGLE: drawRectangle(0,0,500,500); break; case S_CIRCLE: drawCircle(0,0,250,40,2,0); break; case S_SMILEY: drawSmileyFace(0,0,250); break; case S_PACMAN: drawPacMan(0,0,250); break; default: break; } glutSwapBuffers(); }
void MainWindow::setArrowObjects(std::vector<std::shared_ptr<Object>> object) { mArrowObjects = object; std::sort(mArrowObjects.begin(), mArrowObjects.end(), [](std::shared_ptr<Object> a, std::shared_ptr<Object> b) { return b->x() > a->x(); }); std::ofstream out("result.txt"); for (auto& i : mArrowObjects) { i->resize(33, 33); drawRectangle(i->x(), i->y(), i->width(), i->height()); out << " Object: " << i->x() << "->" << i->width() << ":" << i->y() << "->" << i->height() << std::endl; out << i->printImage(); } // clear x min // clear x max updateImageLabel(mCurrentImage, mImageLabel, 0, 0); out << "End" << std::endl; out.close(); if (mSegmentationForm != nullptr) { disconnect(mSegmentationForm.get(), SIGNAL(getArrowObjects(std::vector<std::shared_ptr<Object>>)), this, SLOT(setArrowObjects(std::vector<std::shared_ptr<Object>>))); } }
//制作输入框背景的函数 void create_textbox(LAYER *layer, int x, int y, int length, int width, int color) { drawRectangle(layer->buffer, layer->length, COL8_848484, x - 2, y - 3, length + 4, 1); drawRectangle(layer->buffer, layer->length, COL8_848484, x - 3, y - 3, 1, width + 5); drawRectangle(layer->buffer, layer->length, COL8_FFFFFF, x - 3, y + width + 2, length + 5, 1); drawRectangle(layer->buffer, layer->length, COL8_FFFFFF, x + length + 2, y - 3, 1, width + 6); drawRectangle(layer->buffer, layer->length, COL8_000000, x - 1, y - 2, length + 2, 1); drawRectangle(layer->buffer, layer->length, COL8_000000, x - 2, y - 2, 1, width + 3); drawRectangle(layer->buffer, layer->length, COL8_C6C6C6, x - 2, y + width + 1, length + 3, 1); drawRectangle(layer->buffer, layer->length, COL8_C6C6C6, x + length + 1, y - 2, 1,width + 4); drawRectangle(layer->buffer, layer->length, color, x - 1, y - 1, length + 2, width + 2); return ; }
/* * Implementation of move rectangle */ void moveRectangle( Shape *s, int x, int y ) { /* Move the rectangle */ printf("This function should have moved a rectangle\n"); eraseRectangle( s ); s->x_pos = x; s->y_pos = y; drawRectangle( s ); }
void CAP::display() { for (int i = 0; i < 30; i++) { glTranslated(0.01, 0.01, 0); drawRectangle(); drawCircle(); } glFlush(); }
void christmasTree(int pieces, int flying){ int count; int maxCols = getConsoleWidth(); // (2*(pieces + 3)) -1 + for(count = 0; count <= pieces; count++){ drawTriangle(count + 3, maxCols, flying); } drawRectangle(4,4,maxCols); }