/***************************************************************** 関数名 : DrawShot 機能 : 先輩こいつ玉とか描画しはじめましたよ 引数 : なし 出力 : なし *****************************************************************/ void DrawShot() { int i, j; double x, y; Pos spos; for(i=0; i<MAX_SHOT; i++){ if(gShot[i].state == LIVING){ if(gShot[i].type == LASER){ spos.x = gBoss.pos.x + gBoss.shotpos[gShot[i].id+MAX_BOSSGUN].x; //発射座標 spos.y = gBoss.pos.y + gBoss.shotpos[gShot[i].id+MAX_BOSSGUN].y; if(gShot[i].id >= 0){ lineColor(gMainWindow, gChara[gShot[i].id].pos.x+S_SIZE/2, gChara[gShot[i].id].pos.y+S_SIZE/2+1, gShot[i].pos.x, gShot[i].pos.y+1, gShot[i].color); } else{ for(j= -gShot[i].size/2; j<gShot[i].size/2+1; j++){ x = j; y = (double)j*j/gShot[i].size; lineColor(gMainWindow, spos.x + (x * cos(-gShot[i].dir * M_PI / 180) - y * sin(-gShot[i].dir * M_PI / 180)), spos.y - (x * sin(-gShot[i].dir * M_PI / 180) + y * cos(-gShot[i].dir * M_PI / 180)), gShot[i].pos.x + (x * cos(-gShot[i].dir * M_PI / 180) - gShot[i].size / 4 * sin(-gShot[i].dir * M_PI / 180)), gShot[i].pos.y - (x * sin(-gShot[i].dir * M_PI / 180) + gShot[i].size / 4 * cos(-gShot[i].dir * M_PI / 180)), gShot[i].color); } } } else{ filledCircleColor(gMainWindow, gShot[i].pos.x, gShot[i].pos.y, gShot[i].size, gShot[i].color); } } } }
void StyleHelper::horizontalHeader( QPainter* painter, const QRect& r ) { painter->save(); QRect upperHalf( 0, 0, r.width(), r.height() / 2 ); QRect lowerHalf( 0, upperHalf.height(), r.width(), r.height() ); painter->fillRect( upperHalf, StyleHelper::headerUpperColor() ); painter->fillRect( lowerHalf, StyleHelper::headerLowerColor() ); { QColor lineColor( 100, 100, 100 ); QLine line( 0, 0, r.width(), 0 ); painter->setPen( lineColor ); painter->drawLine( line ); } { QColor lineColor( 30, 30, 30 ); QLine line( 0, r.height() - 1, r.width(), r.height() - 1 ); painter->setPen( lineColor ); painter->drawLine( line ); } painter->restore(); }
/** * Show a properties dialog for a BoxWidget. */ void BoxWidget::showPropertiesDialog() { QColor newColor = QColorDialog::getColor(lineColor()); // krazy:exclude=qclasses if (newColor != lineColor()) { setLineColor(newColor); setUsesDiagramLineColor(false); umlDoc()->setModified(true); } }
/* * vykresluje znacky do hraciho pole */ int drawTurn(SDL_Surface *screen, TCoord c, int player) { if(player == CROSS) { lineColor(screen, c.y * FIELD_SIZE + 2, c.x * FIELD_SIZE + 2, c.y * FIELD_SIZE + FIELD_SIZE - 2, c.x * FIELD_SIZE + FIELD_SIZE - 2, 0xff0000ff); lineColor(screen, c.y * FIELD_SIZE + FIELD_SIZE - 2, c.x * FIELD_SIZE + 2, c.y * FIELD_SIZE + 2, c.x * FIELD_SIZE + FIELD_SIZE - 2, 0xff0000ff); } else { circleColor(screen, c.y * FIELD_SIZE + FIELD_SIZE / 2, c.x * FIELD_SIZE + FIELD_SIZE / 2, FIELD_SIZE / 2 - 2, 0xffff00ff); } SDL_UpdateRect(screen, 0,0,0,0); return 0; }
std::string packLineData(LineData lineData) { rapidjson::Document document; document.SetObject(); rapidjson::Value startPt(rapidjson::kObjectType); startPt.AddMember("x", lineData.startPoint.x, document.GetAllocator()); startPt.AddMember("y", lineData.startPoint.y, document.GetAllocator()); rapidjson::Value endPt(rapidjson::kObjectType); endPt.AddMember("x", lineData.endPoint.x, document.GetAllocator()); endPt.AddMember("y", lineData.endPoint.y, document.GetAllocator()); rapidjson::Value lineColor(rapidjson::kObjectType); lineColor.AddMember("r", lineData.color.r, document.GetAllocator()); lineColor.AddMember("g", lineData.color.g, document.GetAllocator()); lineColor.AddMember("b", lineData.color.b, document.GetAllocator()); lineColor.AddMember("a", lineData.color.a, document.GetAllocator()); document.AddMember("startPoint", startPt, document.GetAllocator()); document.AddMember("endPoint", endPt, document.GetAllocator()); document.AddMember("radius", lineData.radius, document.GetAllocator()); document.AddMember("color", lineColor, document.GetAllocator()); rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); document.Accept(writer); return std::string(buffer.GetString(), buffer.GetSize()); }
void Decorator::drawLines(Picture& dstpic, NColor color, const Lines& lines) { for( const auto& line : lines ) lineColor( dstpic.surface(), line.begin.x(), line.begin.y(), line.end.x(), line.end.y(), color.rgba() ); }
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; } } }
/** * Reimplemented from UMLWidget::paint. Draws a rectangle. */ void DatatypeWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { painter->setBrush(brush()); painter->setPen(QPen(lineColor(), lineWidth())); painter->drawRect(rect()); }
void DataSourceControlWidget::initiazeStyleWidgets() { disconnectStyleWidgets(); auto graphStyle = mDataSource->graphStyle(); auto pen = graphStyle->pen(); ui->lineWidthDoubleSpinBox->setValue(pen.widthF()); for (auto i = 0; i != lineStyleMap.size(); i++) if (std::get<0>(lineStyleMap[i]) == pen.style()) { ui->lineStyleComboBox->setCurrentIndex(i); break; } auto interpolation = graphStyle->lineInterpolation(); for (auto i = 0; i != lineInterpolationMap.size(); i++) if (std::get<0>(lineInterpolationMap[i]) == interpolation) { ui->lineInterpolationComboBox->setCurrentIndex(i); break; } auto scatter = graphStyle->scatterStyle(); ui->scatterSizeDoubleSpinBox->setValue(scatter.size()); ui->scatterDecimationSpinBox->setValue(scatter.decimation()); for (auto i = 0; i != scatterShapeMap.size(); i++) if (std::get<0>(scatterShapeMap[i]) == scatter.shape()) { ui->scatterShapeComboBox->setCurrentIndex(i); break; } ui->isColorFixedCheckBox->setChecked(graphStyle->isColorFixed()); ui->lineColorWidget->setColor(graphStyle->lineColor()); ui->lineColorWidget->setEnabled(ui->isColorFixedCheckBox->isChecked()); connectStyleWidgets(); }
/** * Draws a rectangle. */ void BoxWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o, QWidget *) { Q_UNUSED(o); painter->setPen(QPen(lineColor(), lineWidth())); painter->setBrush(Qt::NoBrush); painter->drawRect(rect()); }
/** * Reimplemented form UMLWidget::paint to draw * ClassifierWidget. */ void ClassifierWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget *) { QPen pen(lineColor(), lineWidth()); if (shouldDrawAsCircle()) { painter->setPen(pen); painter->setBrush(brush()); // m_classifierRect represents circle geometry when shouldDrawAsCircle is true. painter->drawEllipse(m_classifierRect); } else { // The elements not to be drawn will have null dimension and // hence it effectively is not drawn. (automatic ;) ) painter->setPen(pen); painter->setBrush(brush()); painter->drawRoundedRect(m_classifierRect, 2, 2); painter->drawLines(m_classifierLines, 2); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(awesomeHeaderBrush()); Uml::Corners corners(Uml::corner_TopLeft | Uml::corner_TopRight); Widget_Utils::drawRoundedRect(painter, textItemGroupAt(HeaderGroupIndex)->groupGeometry(), 2, 2, corners); pen.setStyle(Qt::DotLine); painter->setPen(pen); painter->setBrush(brush()); painter->drawRect(m_templateRect); } }
void Interconexao::draw(SDL_Renderer* gRenderer, SDL_Surface* screen_sf, TTF_Font* font, Elemento::Posicao spacing, Elemento::Posicao min_x_y) { assert(spacing.x < 600 && spacing.y < 600); const char* string = NULL; SDL_Color preto = {00, 00, 00, 0xFF}; // Superfície com o texto. SDL_Surface *text_sf = NULL; // Posição do canto superior esquerdo do quadrado. // Os elementos são impressos em escala logarítmica. Por isso esses "logs". // Se quiser deslocar a posição a ser impressa é só somar ou diminuir a quantidade // de pixels de pos_x ou pos_y. int pos_ini_x = log(1 + this->getPosicaoInicial().x - min_x_y.x) * spacing.x + 30; int pos_ini_y = log(1 + this->getPosicaoInicial().y - min_x_y.y) * spacing.y + 30; int pos_fi_x = log(1 + this->getPosicaoFinal().x - min_x_y.x) * spacing.x + 30; int pos_fi_y = log(1 + this->getPosicaoFinal().y - min_x_y.y) * spacing.y + 30; uint32_t color = 0xFF00FF00; if (this->isWorking() == false) color = 0xFF0000FF; lineColor(gRenderer, pos_ini_x, pos_ini_y, pos_fi_x, pos_fi_y, color); string = (this->getNome() + "-> " + to_string(this->getCarga())).c_str(); text_sf = TTF_RenderText_Solid(font, string, preto); SDL_Rect rect = { (pos_ini_x + pos_fi_x - 30) / 2, (pos_ini_y + pos_fi_y) / 2, 0, 0 }; SDL_BlitSurface(text_sf, NULL, screen_sf, &rect); SDL_FreeSurface(text_sf); }
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 TSketcher::lineC(int x1,int y1,int x2,int y2,int coul) { x1 = x1*w/mw+ox; y1 = y1*h/mh+oy; x2 = x2*w/mw+ox; y2 = y2*h/mh+oy; lineColor(sf,x1,y1,x2,y2,coul); }
/** * Implementation of paint. */ void NoteWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { painter->setPen(QPen(lineColor(), lineWidth())); painter->setBrush(brush()); QSizeF triSize(10, 10); Widget_Utils::drawTriangledRect(painter, rect(), triSize); }
/* Here we draw the souroundings for the color points */ void makepoint(int laeng, int winkel) { int p1_x, p1_y, p2_x, p2_y; int sm,la; sm = 5; la = 10; /* That 57,3 makes the conversation from Grad to radiant */ p1_x = round ( (laeng+la) * cos ((winkel-10) /57.3) ); p1_y = round ( (laeng+la) * sin ((winkel-10) /57.3) ); p2_x = round ( (laeng+sm) * cos ((winkel-10) /57.3) ); p2_y = round ( (laeng+sm) * sin ((winkel-10) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p2_x = round ( (laeng+la) * cos ((winkel-5) /57.3) ); p2_y = round ( (laeng+la) * sin ((winkel-5) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p1_x = round ( (laeng-la) * cos ((winkel-10) /57.3) ); p1_y = round ( (laeng-la) * sin ((winkel-10) /57.3) ); p2_x = round ( (laeng-sm) * cos ((winkel-10) /57.3) ); p2_y = round ( (laeng-sm) * sin ((winkel-10) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p2_x = round ( (laeng-la) * cos ((winkel-5) /57.3) ); p2_y = round ( (laeng-la) * sin ((winkel-5) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p1_x = round ( (laeng+la) * cos ((winkel+10) /57.3) ); p1_y = round ( (laeng+la) * sin ((winkel+10) /57.3) ); p2_x = round ( (laeng+sm) * cos ((winkel+10) /57.3) ); p2_y = round ( (laeng+sm) * sin ((winkel+10) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p2_x = round ( (laeng+la) * cos ((winkel+5) /57.3) ); p2_y = round ( (laeng+la) * sin ((winkel+5) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p1_x = round ( (laeng-la) * cos ((winkel+10) /57.3) ); p1_y = round ( (laeng-la) * sin ((winkel+10) /57.3) ); p2_x = round ( (laeng-sm) * cos ((winkel+10) /57.3) ); p2_y = round ( (laeng-sm) * sin ((winkel+10) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); p2_x = round ( (laeng-la) * cos ((winkel+5) /57.3) ); p2_y = round ( (laeng-la) * sin ((winkel+5) /57.3) ); lineColor(screen, vector_x + p1_x, vector_y - p1_y, vector_x + p2_x, vector_y - p2_y,blue); //mjpeg_debug(" 1x %i, 1y %i, 2x %i, 2y %i", p1_x, p1_y, p2_x, p2_y); }
int GeoLayer::line(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 = lineColor(surf, x1, y1, x2, y2, col); if(res < 0) error("error in %s", __PRETTY_FUNCTION__); return(res); }
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(); } }
void Render(SDL_Surface *srf,uint32_t rej,uint32_t wi,uint32_t hi, uint32_t dx) { FillRect(srf,0,0,600,524,0); int ddX=dx; int ii; int jj; int tmp,tmp2; if (wi<151) ddX=0; else if (dx>(wi-150)) ddX=(wi-150); if (Offs>=Max) Offs=Max-1; else if (Offs<0) Offs=0; int off=ddX+Offs; tmp=0; switch (rej) { case 1: ii=0; jj=0; while (ii<wi*hi) { if (((ii/8)+off)>=Max) break; if ((ii % wi)< 150) { fseek(fl,(ii/8)+off,SEEK_SET); fread(&tmp,1,1,fl); for (int kl=0; kl<8; kl++) { tmp2=(tmp >> kl) & 1; if (tmp2==1) tmp2=0x7F7F7F; jj= ii/wi; if ((ii % wi)< 150) FillRect(srf,(ii % wi)*4,jj*4,4,4,tmp2); ii++; } if (setka) { jj= (ii-8)/wi; lineColor (srf,((ii-8) % wi)*4,jj*4,((ii-8) % wi)*4,jj*4+4,0xFF0000FF); } } else ii+=8; }
int main() { SDL_Init(SDL_INIT_VIDEO); srand(time(NULL)); SDL_Surface *screen = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF); if (screen == NULL) return -1; atexit(SDL_Quit); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0x38, 0x1a, 0x0e)); printf("%x\n",SDL_MapRGBA(screen->format, 0x61, 0xc6, 0xd0, 0xff)); boxRGBA(screen, 100, 100, 500, 500, 0x61, 0xc6, 0xd0, 0xff); for (int i = 0; i<2; i++) { rectangleRGBA(screen, 100+i,100+i, 500-i, 500-i, 0x00,0x00,0x00,0xdd-(rand()%3)); } for (int i = 0; i<30; i++) { lineColor(screen, 100+i, 100, 100+i, 500, 0x00000096 -(5*i)); } for (int i = 0; i<30; i++) { lineColor(screen, 100,100+i,500, 100+i, 0x00000096 -(5*i)); } for (int i = 0; i<30; i++) { lineColor(screen, 100, 500-i,500, 500-i, 0x00000096 -(5*i)); } for (int i = 0; i<30; i++) { lineColor(screen, 500-i,100,500-i, 500, 0x00000096 -(5*i)); } SDL_Flip(screen); getchar(); return 0; }
void ASSISTANT::Oval::Draw(CDC *pDC, float _zoomFactor, double dOffX, double dOffY) { if (!visible) return; if (m_dWidth == 0 && m_dHeight == 0) return; Gdiplus::Graphics graphics(pDC->m_hDC); graphics.TranslateTransform(dOffX, dOffY); graphics.ScaleTransform(_zoomFactor, _zoomFactor); // there are problems if circles have netagive width and height double dX = m_dX; double dY = m_dY; double dWidth = m_dWidth; double dHeight = m_dHeight; if (m_dWidth < 0) { dX = m_dX + m_dWidth; dWidth = -m_dWidth; } if (m_dHeight < 0) { dY = m_dY + m_dHeight; dHeight = -m_dHeight; } graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); bool bDrawLine = true; if (m_argbFillColor != 0) { Gdiplus::Color fillColor(m_argbFillColor); Gdiplus::SolidBrush fillBrush(fillColor); if (m_argbFillColor == m_argbLineColor) { graphics.FillEllipse(&fillBrush, (Gdiplus::REAL)(dX-lineWidth/2), (Gdiplus::REAL)(dY-lineWidth/2), (Gdiplus::REAL)(dWidth+lineWidth), (Gdiplus::REAL)(dHeight+lineWidth)); bDrawLine = false; } else { graphics.FillEllipse(&fillBrush, (Gdiplus::REAL)(dX+lineWidth/2), (Gdiplus::REAL)(dY+lineWidth/2), (Gdiplus::REAL)(dWidth-lineWidth+1), (Gdiplus::REAL)(dHeight-lineWidth+1)); } } if (bDrawLine) { Gdiplus::Color lineColor(m_argbLineColor); Gdiplus::Pen pen(lineColor, lineWidth); pen.SetDashStyle(m_gdipLineStyle); graphics.DrawEllipse(&pen, (Gdiplus::REAL)dX, (Gdiplus::REAL)dY, (Gdiplus::REAL)dWidth, (Gdiplus::REAL)dHeight); } }
void RenderableLineEntityItem::updateGeometry() { auto geometryCache = DependencyManager::get<GeometryCache>(); if (_lineVerticesID == GeometryCache::UNKNOWN_ID) { _lineVerticesID = geometryCache ->allocateID(); } if (_pointsChanged) { glm::vec4 lineColor(toGlm(getXColor()), getLocalRenderAlpha()); geometryCache->updateVertices(_lineVerticesID, getLinePoints(), lineColor); _pointsChanged = false; } }
/** * Draw line from one model to second model. */ void RopeDecor::drawOnScreen(const View *view, SDL_Surface *screen) { V2 loc1 = view->getScreenPos(m_model1).plus(m_shift1); V2 loc2 = view->getScreenPos(m_model2).plus(m_shift2); //NOTE: steel color Uint32 colorRGBA = 0x30404eff; lineColor(screen, loc1.getX(), loc1.getY(), loc2.getX(), loc2.getY(), colorRGBA); }
CAMLprim value ml_lineColor(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=lineColor(sur,rect1.x,rect1.y,rect2.x,rect2.y,Int32_val(col)); return Val_bool(r); }
ModelRenderer::ModelRenderer(QQuickItem *parent) : QQuickItem(parent) , m_window( nullptr ) , m_useProgram2( false ) , m_shaderProgram( nullptr ) , m_shaderProgram2( nullptr ) , m_rotateX(0.0) , m_rotateY(0.0) , m_rotateZ(0.0) , m_eyeDistance(4.0) , m_eyeAngleX(0.0) , m_eyeAngleY(0.0) , m_lightDistance(8.0) , m_lightAngleX(0.0) , m_lightAngleY(0.0) , m_ambientBrightness(0.5) , m_diffuseBrightness(0.75) , m_specularBrightness(1.0) , m_ambientReflection(0.5) , m_diffuseReflection(0.5) , m_specularReflection(0.5) , m_shininess(100.0) , m_spotExponent(1.0) , m_cutoffAngle(180.0) { LOG_ENTER(); QVector4D lineColor( 0.0, 0.0, 0.0, 1.0 ); // QVector4D lineColor( 1.0, 1.0, 1.0, 1.0 ); for( int i = 0; i < NUM_VERTICE * NUM_FACES; i++ ){ m_lineColorArray[i] = lineColor; } for( int i = 0; i < NUM_FACES; i ++ ){ QVector3D normal = createPolygonNormal( m_positionArray[NUM_VERTICE * i].toVector3D(), m_positionArray[NUM_VERTICE * i + 1].toVector3D(), m_positionArray[NUM_VERTICE * i + 2].toVector3D() ); for( int j = 0; j < NUM_VERTICE; j++ ){ m_normalArray[NUM_VERTICE * i + j] = normal; } } updateEyePosition(); updateLightPosition(); connect( this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(windowChanged(QQuickWindow *)), Qt::DirectConnection ); LOG_LEAVE(); }
void drawResults(cv::Mat& image, const float* pix_label, const float* reg_label, bool predict_depth, double scaling, int num_regression, int quad_height, int quad_width, int grid_dim){ // draw ground truth and predictions on image. int grid_length = grid_dim*grid_dim; int label_height = quad_height*grid_dim; int label_width = quad_width*grid_dim; int img_width = image.cols; int img_height = image.rows; double thresh=0.4; // retrieve labels and predictions for (int z=0; z<grid_length;++z){ for (int qy = 0; qy < quad_height; ++qy) { for (int qx = 0; qx < quad_width; ++qx) { int dx = z%grid_dim; int dy = z/grid_dim; int x = qx*grid_dim+dx; int y = qy*grid_dim+dy; double label_prob = (double)(*(pix_label+((z*quad_height+qy)*quad_width+qx))); label_prob = 1. / (1. + exp(-label_prob)); //std::cout<<label_prob<<" "; // draw pixel label/pred double x1 = x-0.5<0? 0:x-0.5; double y1 = y-0.5<0? 0:y-0.5; double w = scaling - (x<0.5? 0.5-x:0) - (x1+scaling>img_width? x1+scaling-img_width:0); double h = scaling - (y<0.5? 0.5-y:0) - (y1+scaling>img_height? y1+scaling-img_height:0); cv::Mat roi = image(cv::Rect(x1*scaling, y1*scaling, w, h)); cv::Mat color(roi.size(), CV_8UC3, cv::Scalar(0, 255, 0)); cv::addWeighted(color, label_prob, roi, 1.0 - label_prob , 0.0, roi); if (label_prob > thresh) { // draw reg label/pred float x_adj = (qx*grid_dim + grid_dim / 2) * scaling; float y_adj = (qy*grid_dim + grid_dim / 2) * scaling; float x_min = *(reg_label+((z*quad_height+qy)*quad_width+qx))+x_adj; float y_min = *(reg_label+(((z+grid_length)*quad_height+qy)*quad_width+qx))+y_adj; float x_max = *(reg_label+(((z+grid_length*2)*quad_height+qy)*quad_width+qx))+x_adj; float y_max = *(reg_label+(((z+grid_length*3)*quad_height+qy)*quad_width+qx))+y_adj; cv::Point p1(x_min, y_min); cv::Point p2(x_max, y_max); cv::Scalar lineColor(100,100,200); if(predict_depth){ float min_depth = *(reg_label+(((z+grid_length*4)*quad_height+qy)*quad_width+qx)); float max_depth = *(reg_label+(((z+grid_length*5)*quad_height+qy)*quad_width+qx)); lineColor = dist2color((min_depth+max_depth)/2.); } // draw label and predictions on image. cv::line(image,p1,p2,lineColor, 2); } } } } }
void draw_func_densite(SDL_Surface *ecran, SDL_Surface *rectangle, double a) { int t; double tmp; double tmp2; SDL_Rect position; Sint16 vx[1000]; Sint16 vy[1000]; Sint16 vz[1000]; double total = 0; for (t = 0; t < 1000; t++) { position.x = 50 + t; vx[t] = 50 + t; tmp = f(a, (t * 0.01)); position.y = (WIN_HEIGHT - 166) - tmp * 600; vy[t] = (WIN_HEIGHT - 166) - tmp * 600; total += vy[t]; pixelColor(ecran, vx[t], vy[t], 0xff3a2aff); if (t > 0) lineColor(ecran, vx[t - 1], vy[t - 1], vx[t], vy[t], 0xff3a2aff); SDL_FillRect(rectangle, NULL, SDL_MapRGB(ecran->format, 255, 100, 25)); // polygonColor(ecran, vx, vy, 1000, 0xffa02aff); // SDL_BlitSurface(rectangle, NULL, ecran, &position); } for (t = 0; t < 1000; t++) { vx[t] = 50 + t; // tmp2 = fonc_test(0, 1000, 1, 1000, a, total); tmp2 = fonc_rep(0, t, a); vz[t] = (WIN_HEIGHT - 166) - tmp2 * 600; pixelColor(ecran, vx[t], vz[t], 0x3a3affff); if (t > 0) lineColor(ecran, vx[t - 1], vz[t - 1], vx[t], vz[t], 0x3a3affff); } SDL_Flip(ecran); }
/* 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 */ }
//------------------------------------------------------------ update() // static void update() { int i; static int contador=0; static int g_bufferx[MAXPUNTOS]; static int g_buffery[MAXPUNTOS]; if (gAbsState[WACOMFIELD_PRESSURE].nValue == 0) { contador=0; return; } if (contador<MAXPUNTOS-1) { for (i=1; i<contador-1; i++) { g_bufferx[i-1]=g_bufferx[i]; g_buffery[i-1]=g_buffery[i]; } g_bufferx[contador]=gAbsState[WACOMFIELD_POSITION_X].nValue * X_FACTOR; g_buffery[contador]=gAbsState[WACOMFIELD_POSITION_Y].nValue * Y_FACTOR; contador++; return; } for (i=1; i<MAXPUNTOS; i++) { g_bufferx[i-1]=g_bufferx[i]; g_buffery[i-1]=g_buffery[i]; } g_bufferx[contador]=gAbsState[WACOMFIELD_POSITION_X].nValue * X_FACTOR; g_buffery[contador]=gAbsState[WACOMFIELD_POSITION_Y].nValue * Y_FACTOR; fprintf(data,"%d \t %d \t %d \t %d \t %d \t %d \n", g_bufferx[contador], g_buffery[contador], gAbsState[WACOMFIELD_POSITION_X].nValue, gAbsState[WACOMFIELD_POSITION_Y].nValue, gAbsState[WACOMFIELD_PRESSURE].nValue, SDL_GetTicks()); //SDL_FillRect(screen, NULL, 0); for (i=0; i<MAXPUNTOS-2; i++) lineColor(screen, (Sint16)g_bufferx[i], (Sint16)g_buffery[i],(Sint16)g_bufferx[i+1], (Sint16)g_buffery[i+1], 5000); SDL_Flip(screen); }
void eletter_draw(SDL_Surface *screen,int **eletter,Pont screensize, Pont size,int cellsize, int menu_width, int color, int correction){ int x, y; // a padding úgy számítódik ki, hogy kb a képernyő közepére rajzolja az életteret Pont padding; padding.x=(screensize.x-menu_width-(cellsize*(size.x-correction*2)))/2; padding.y=(screensize.y-(cellsize*(size.y-correction*2)))/2; // a correction mindenhol a nem kirajzolandó sorok és oszlopok száma for(y=correction; y<size.y-correction; ++y){ for(x=correction; x<size.x-correction; ++x){ if(eletter[y][x]) // négyzeteket rajzol, az első négyzet úgy alakhul hog boxColor(screen, menu_width+padding.x-correction*cellsize + 1/*+1 hogy ne fedje a vonalakat*/+x*cellsize, -correction*cellsize + 1 + y*cellsize+padding.y, -correction*cellsize+ -1 +menu_width+(x+1)*cellsize+padding.x, -correction*cellsize+-1+(y+1)*cellsize+padding.y, color); else //fehér színnel ugyanez boxColor(screen, menu_width+padding.x-correction*cellsize + 1/*+1 hogy ne fedje a vonalakat*/+x*cellsize, -correction*cellsize + 1 + y*cellsize+padding.y, -correction*cellsize+ -1 +menu_width+(x+1)*cellsize+padding.x, -correction*cellsize+-1+(y+1)*cellsize+padding.y, 0xffffffff); } } for(y=0; y<size.y-correction*2; ++y){ for(x=0; x<size.x-correction*2; ++x){ lineColor(screen, padding.x+menu_width+x*cellsize, padding.y+y*cellsize, padding.x+menu_width+(x+1)*cellsize, padding.y+y*cellsize, 0x000000ff); lineColor(screen, padding.x+menu_width+x*cellsize, padding.y+y*cellsize, padding.x+menu_width+x*cellsize, padding.y+(y+1)*cellsize, 0x000000ff); } } lineColor(screen, padding.x+(size.x-correction*2)*cellsize+menu_width, padding.y, padding.x+(size.x-correction*2)*cellsize+menu_width, padding.y+(size.y-correction*2)*cellsize, 0x000000ff); lineColor(screen, padding.x+menu_width, padding.y+(size.y-correction*2)*cellsize, padding.x+(size.x-correction*2)*cellsize+menu_width, padding.y+(size.y-correction*2)*cellsize, 0x000000ff); }