/** * Get the brush color for certain pressure. * @param pressure pen pressure. Range is [0..1] * @return color * @pre 0 <= pressure <= 1 */ QColor Brush::color(qreal pressure) const { return QColor( qRound(interpolate(color1().red(), color2().red(), pressure)), qRound(interpolate(color1().green(), color2().green(), pressure)), qRound(interpolate(color1().blue(), color2().blue(), pressure)) ); }
void ZClickableTransferFunctionLabel::paintEvent(QPaintEvent */*e*/) { QPainter painter(this); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); QColor color1(0, 0, 0); QColor color2(255, 255, 255); qreal width = contentsRect().width() / 20.; qreal height = contentsRect().height() / 4.; for (int i=0; i<20; i++) { if (i%2==0) { painter.fillRect(QRectF(contentsRect().left()+i*width, contentsRect().top(), width, height), color2); painter.fillRect(QRectF(contentsRect().left()+i*width, 0.25*(contentsRect().top()+contentsRect().bottom()), width, height), color1); } else { painter.fillRect(QRectF(contentsRect().left()+i*width, contentsRect().top(), width, height), color1); painter.fillRect(QRectF(contentsRect().left()+i*width, 0.25*(contentsRect().top()+contentsRect().bottom()), width, height), color2); } } if (m_transferFunction) { for(int x = contentsRect().left(); x <= contentsRect().right(); ++x) { double fraction = (x*1.-contentsRect().left()) / contentsRect().width(); QColor color = m_transferFunction->get().getMappedQColor(fraction); painter.setPen(color); painter.drawLine(x, contentsRect().top(), x, contentsRect().bottom() * 0.5); color.setAlpha(255); painter.setPen(color); painter.drawLine(x, contentsRect().bottom() * 0.5, x, contentsRect().bottom()); } } }
void PhysicsDebugDraw_Impl::DrawSolidPolygon(const b2Vec2* vertices, int32 k_segments, const b2Color& color) { Colorf color1(0.5f*color.r,0.5f*color.g,0.5f*color.b,0.5f); Colorf color2(color.r,color.g,color.b,1.0f); int i; for(i=0;i<k_segments-3;i++) { used_canvas->fill_triangle(Pointf(vertices[i].x*physic_scale,vertices[i].y*physic_scale), Pointf(vertices[i+1].x*physic_scale, vertices[i+1].y*physic_scale), Pointf(vertices[i+2].x*physic_scale, vertices[i+2].y*physic_scale), color1); } used_canvas->fill_triangle(Pointf(vertices[0].x*physic_scale,vertices[0].y*physic_scale), Pointf(vertices[k_segments-2].x*physic_scale, vertices[k_segments-2].y*physic_scale), Pointf(vertices[k_segments-1].x*physic_scale, vertices[k_segments-1].y*physic_scale), color1); for(i=0;i<k_segments-1;i++) { used_canvas->draw_line(vertices[i].x*physic_scale,vertices[i].y*physic_scale, vertices[i+1].x*physic_scale,vertices[i+1].y*physic_scale, color2); } used_canvas->draw_line(vertices[0].x*physic_scale,vertices[0].y*physic_scale, vertices[k_segments-1].x*physic_scale,vertices[k_segments-1].y*physic_scale, color2); }
void Board::fillGouraudTriangle( const Point & p1, const float brightness1, const Point & p2, const float brightness2, const Point & p3, const float brightness3, unsigned char divisions, int depth /* = -1 */ ) { Color color1( _state.penColor ); Color color2( _state.penColor ); Color color3( _state.penColor ); color1.red( static_cast<unsigned char>( std::min( 255.0f, color1.red() * brightness1 ) ) ); color1.green( static_cast<unsigned char>( std::min( 255.0f, color1.green() * brightness1 ) ) ); color1.blue( static_cast<unsigned char>( std::min( 255.0f, color1.blue() * brightness1 ) ) ); color2.red( static_cast<unsigned char>( std::min( 255.0f, color2.red() * brightness2 ) ) ); color2.green( static_cast<unsigned char>( std::min( 255.0f, color2.green() * brightness2 ) ) ); color2.blue( static_cast<unsigned char>( std::min( 255.0f, color2.blue() * brightness2 ) ) ); color3.red( static_cast<unsigned char>( std::min( 255.0f, color3.red() * brightness3 ) ) ); color3.green( static_cast<unsigned char>( std::min( 255.0f, color3.green() * brightness3 ) ) ); color3.blue( static_cast<unsigned char>( std::min( 255.0f, color3.blue() * brightness3 ) ) ); fillGouraudTriangle( Point( _state.unit(p1.x), _state.unit(p1.y) ), color1, Point( _state.unit(p2.x), _state.unit(p2.y) ), color2, Point( _state.unit(p3.x), _state.unit(p3.y) ), color3, divisions, depth ); }
void SWidgetManager::paintEvent( QPaintEvent * ) { const QList<QWidget*> & visible_widgets = p->widgets_status.keys(true); SColor color1( palette().window().color() ); SColor color2( palette().window().color() ); color2 = color2 * 0.6; color1 = color1 * 0.9; QPainter painter( this ); painter.setRenderHint( QPainter::Antialiasing ); bool left_side_bar = visible_widgets.count() != 0; bool right_side_bar = visible_widgets.count() != p->widgets.count(); if( left_side_bar ) painter.fillRect( 0 , 0 , p->sidebar_width , height() , color2 ); if( right_side_bar ) painter.fillRect( width()-p->sidebar_width , 0 , p->sidebar_width , height() , color2 ); for( int i=0 ; i<p->sidebar_width-MOVE_POINTS_WIDTH ; i+= MOVE_POINTS_WIDTH+1 ) for( int j=((i/((int)MOVE_POINTS_WIDTH+1))%2)*(MOVE_POINTS_WIDTH+1)/2 ; j<height()-MOVE_POINTS_WIDTH ; j+= MOVE_POINTS_WIDTH+1 ) { QPainterPath path; if( left_side_bar ) path.addEllipse( i , j , MOVE_POINTS_WIDTH , MOVE_POINTS_WIDTH ); if( right_side_bar ) path.addEllipse( i+(width()-p->sidebar_width) , j , MOVE_POINTS_WIDTH , MOVE_POINTS_WIDTH ); painter.fillPath( path , color1 ); } }
void CScreenBox::Init() { Shaders=new SShaders; if (!Shaders->ShaderVertex.LoadFile("../shader/menu.vs")) std::cout << "-----------------------------------\nErreur vertex shader :\n" << Shaders->ShaderVertex.GetLog() << std::endl << "--------------------------" << std::endl; if (!Shaders->ShaderFragment.LoadFile("../shader/menu.fs")) std::cout << "-----------------------------------\nErreur fragment shader :\n" << Shaders->ShaderFragment.GetLog() << std::endl << "--------------------------" << std::endl; if (!Shaders->RenderingShader.LinkProgram()) std::cout << "-----------------------------------\nErreur shader program :\n" << Shaders->RenderingShader.GetLog() << std::endl << "--------------------------" << std::endl; OpenUtility::RGBAd color1(0.8,0.8,0.8,1.0),color2(0.6,0.6,0.6,1.0); Background=new OpenUtility::CQuad(DimX[0]/2,DimY[0]/2,-DimX[0]/2,-DimY[0]/2,color1,color1,color2,color2,false); glGenBuffers(1,&VBObufferBackground); glBindBuffer(GL_ARRAY_BUFFER,VBObufferBackground); glBufferData(GL_ARRAY_BUFFER,4*2*2*sizeof(GLfloat),NULL,GL_STATIC_DRAW); UpdateTexData(); Font=new OpenUtility::CFontLoader("../content/verdana.ttf",50); Title=new OpenUtility::C3DText(Font,0.0,0.28,0.46,1.0,0.5); Title->SetAlignement(OpenUtility::CFontLoader::IFontEngine::EHAlignLeft,OpenUtility::CFontLoader::IFontEngine::EVAlignBaseligne); Title->UpdateText(Screen->GetName()); ForceRender=true; State=ESDisplayMenu; }
void Previewer::paintEvent( QPaintEvent * ) { QSize input_size = INPUT_SIZE; const QRect & rct = rect(); QPainter painter(this); painter.setRenderHint( QPainter::Antialiasing , true ); QColor color1( BASE_COLOR_1 ); QColor color2( BASE_COLOR_2 ); QColor shadow_color( "#000000" ); color1.setAlpha( MAGNIFIER_ALPHA ); color2.setAlpha( MAGNIFIER_ALPHA ); QLinearGradient gradiant(QPointF(0, rct.y()), QPointF(0,rct.y()+rct.height())); gradiant.setColorAt(0, color1); gradiant.setColorAt(1, color2); painter.fillPath( magnifierPath( input_size , rct , SHADOW_SIZE ) , gradiant ); for( int i=SHADOW_SIZE-1 ; i>=0 ; i-- ) { QSize top_size( input_size.width() + 2*(SHADOW_SIZE-i) , input_size.height() ); shadow_color.setAlpha( ((double)i/SHADOW_SIZE)*MAGNIFIER_ALPHA/2 ); painter.setPen( shadow_color ); painter.drawPath( magnifierPath(top_size , rct , i) ); } }
TYPED_TEST(ColorTest, ShouldInplaceAdd) { Color<TypeParam> color1(0.3, 0.1, 0.4), color2(0.1, 0.1, 0.2); color1 += color2; Color<TypeParam> expected(0.4, 0.2, 0.6); ASSERT_COLOR_NEAR(expected, color1, 0.0001); }
TYPED_TEST(ColorTest, ShouldSubtract) { Color<TypeParam> color1(0.3, 0.1, 0.4), color2(0.1, 0.1, 0.2); Color<TypeParam> color3 = color1 - color2; Color<TypeParam> expected(0.2, 0, 0.2); ASSERT_COLOR_NEAR(expected, color3, 0.0001); }
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { if (bgPixmap.isNull()) painter->fillRect(boundingRect(), QColor(0, 0, 100)); else painter->fillRect(boundingRect(), QBrush(bgPixmap)); painter->setPen(QColor(255, 255, 255, 40)); qreal separatorY = 2 * (CARD_HEIGHT + 20 + paddingY) + boxLineWidth - paddingY / 2; if (isInverted()) separatorY = height - separatorY; painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY)); if (active) { QColor color1(255, 255, 255, 150); QColor color2(255, 255, 255, 0); QLinearGradient grad1(0, 0, 0, 1); grad1.setCoordinateMode(QGradient::ObjectBoundingMode); grad1.setColorAt(0, color1); grad1.setColorAt(1, color2); painter->fillRect(QRectF(0, 0, width, boxLineWidth), QBrush(grad1)); grad1.setFinalStop(1, 0); painter->fillRect(QRectF(0, 0, boxLineWidth, height), QBrush(grad1)); grad1.setStart(0, 1); grad1.setFinalStop(0, 0); painter->fillRect(QRectF(0, height - boxLineWidth, width, boxLineWidth), QBrush(grad1)); grad1.setStart(1, 0); painter->fillRect(QRectF(width - boxLineWidth, 0, boxLineWidth, height), QBrush(grad1)); } }
void TriMeshModel::addTriangleWithFace(Eigen::Vector3f& vertex1, Eigen::Vector3f& vertex2, Eigen::Vector3f& vertex3, Eigen::Vector4f& vertexColor1, Eigen::Vector4f& vertexColor2, Eigen::Vector4f& vertexColor3) { Eigen::Vector3f normal = TriMeshModel::CreateNormal(vertex1, vertex2, vertex3); VisualizationFactory::Color color1(vertexColor1(0), vertexColor1(1), vertexColor1(2), vertexColor1(4)); VisualizationFactory::Color color2(vertexColor2(0), vertexColor2(1), vertexColor2(2), vertexColor2(4)); VisualizationFactory::Color color3(vertexColor3(0), vertexColor3(1), vertexColor3(2), vertexColor3(4)); addTriangleWithFace(vertex1, vertex2, vertex3, normal, color1, color2, color3); }
void LegendGroup::updateModel() { QList<QGraphicsItem*> pool; for (auto l : legends) { removeFromGroup(l); pool.append(l); } for (auto t : texts) { removeFromGroup(t); pool.append(t); } for (auto l : pool) delete l; legends.clear(); texts.clear(); for (int i=0; i<model->rowCount(); i++) { auto marker = model->at(i); QString l = marker->label() + "\t: " + QString::number(marker->count()); QColor color1 = marker->color1(); QColor color2 = marker->color2(); int type = marker->activeType(); if (0 == type) { QRectF r = MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize); QLineF l(r.topLeft(), r.bottomRight()); auto marker = new ArrowItem(l); marker->setArrowhead(ArrowHead::Start); marker->setColor1(color1); marker->setColor2(color2); marker->setPenWidth(myPenWidth); legends.append(marker); addToGroup(marker); } else if (1 == type) { auto marker = new RectItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize)); marker->setColor1(color1); marker->setColor2(color2); marker->setPenWidth(myPenWidth); legends.append(marker); addToGroup(marker); } else { auto marker = new EllipseItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize)); marker->setColor1(color1); marker->setColor2(color2); marker->setPenWidth(myPenWidth); legends.append(marker); addToGroup(marker); } auto label = new RichTextItem(l); label->setFont(myFont); label->setFontSize(myFontSize); label->setKeyPressFunc([this](QKeyEvent* event) { updateRect(); }); label->setTextInteractionFlags(Qt::TextEditorInteraction); label->setFlag(QGraphicsItem::ItemIsFocusable); QPointF textPos = legends.at(i)->boundingRect().center() + QPointF(legends.at(i)->boundingRect().width()/2+20, -label->boundingRect().height()*0.5); label->setPos(textPos); label->setZValue(1000); texts.append(label); addToGroup(label); } calculatePos(); }
int main(int argc, char ** argv) { size_t grid_size = WIDTH * HEIGHT * sizeof(float); // pedir memoria float * current; float * next; float * result; CHECK_CUDA_CALL(cudaMalloc(¤t, grid_size)); CHECK_CUDA_CALL(cudaMalloc(&next, grid_size)); CHECK_CUDA_CALL(cudaMallocHost(&result, grid_size)); // inicializar con la fuente de calor CHECK_CUDA_CALL(cudaMemset(current, 0, grid_size)); CHECK_CUDA_CALL(cudaMemcpy(¤t[idx(HEAT_X, HEAT_Y)], &HEAT_TEMP, sizeof(float), cudaMemcpyHostToDevice)); CHECK_CUDA_CALL(cudaMemcpy(next, current, grid_size, cudaMemcpyDeviceToDevice)); // correr las actualizaciones for (unsigned int step = 0; step < STEPS; ++step) { update_cuda(WIDTH, 1, WIDTH-1, 1, HEIGHT-1, HEAT_X, HEAT_Y, current, next); float * swap = current; current = next; next = swap; } CHECK_CUDA_CALL(cudaGetLastError()); CHECK_CUDA_CALL(cudaDeviceSynchronize()); // copiar el resultado al host para graficar CHECK_CUDA_CALL(cudaMemcpy(result, current, grid_size, cudaMemcpyDeviceToHost)); // graficos sdls_init(WIDTH, HEIGHT); rgba * gfx = (rgba *) calloc(WIDTH * HEIGHT, sizeof(rgba)); for (unsigned int y = 0; y < HEIGHT; ++y) { for (unsigned int x = 0; x < WIDTH; ++x) { gfx[idx(x, y)] = color1(result[idx(x, y)] / HEAT_TEMP); } } sdls_blitrectangle_rgba(0, 0, WIDTH, HEIGHT, gfx); sdls_draw(); printf("Presione ENTER para salir\n"); getchar(); sdls_cleanup(); CHECK_CUDA_CALL(cudaFree(current)); CHECK_CUDA_CALL(cudaFree(next)); CHECK_CUDA_CALL(cudaFreeHost(result)); free(gfx); return 0; }
MarkerContainer::MarkerContainer() { auto s = Settings("MarkerL"); myColor1 = s.color1(); myColor2 = s.color2(); myPenWidth = s.penWidth(); myFont = s.font(); myFontSize = s.fontSize(); mySize = s.size(); myHasBackground = s.hasBackground(); myType = 0; visible = true; }
void Jogo::encerramento() { gui.musicaFundo.stop(); gui.success.play(); sf::Color color1(255,255,255,255); sf::Color color2(100,100,100,255); sf::Color color3(255,0,0,255); while(gui.tela.isOpen()) { gui.limpaTela(); gui.desenhaFundo(this->level); gui.desenhaTexto("Você venceu!", 60, color1, gui.getWidth()/2, gui.getHeigth()/1.8, true); gui.desenhaTexto("Tempo: " + to_string(antesVirgula) + "." + to_string(depoisVirgula), 40, color3, gui.getWidth()/2, gui.getHeigth()/1.23, true); gui.desenhaTexto("ESPAÇO - Jogar novamente", 25, color2, gui.getWidth()/20, gui.getHeigth()/1.3, false); gui.desenhaTexto("ESC - Encerrar o jogo", 25, color2, gui.getWidth()/20, gui.getHeigth()/1.2, false); sf::Event evento; while (gui.tela.pollEvent(evento)) { switch(evento.type) { case(sf::Event::Closed): gui.tela.close(); break; case(sf::Event::KeyPressed): { if(evento.key.code == sf::Keyboard::Escape) { gui.tela.close(); } else if(evento.key.code == sf::Keyboard::Space) { this->level = 0; for(int i = 0; i < 5; i++) this->lixeiras[i].zera(); run(); } break; } default: break; } } gui.renderiza(); } }
DiffuseCheckerBoardMaterial::DiffuseCheckerBoardMaterial(float r1, float g1, float b1, float r2, float g2, float b2) : Material() { RGBColor color1(r1, g1, b1); RGBColor color2(r2, g2, b2); setAlbedo([color1, color2, this](const RayIntersection & isect) { return (bool(int(floorf(isect.position.x / gridSize)) % 2) ^ //bool(int(floorf(isect.position.y / gridSize)) % 2) ^ bool(int(floorf(isect.position.z / gridSize)) % 2)) ? color1 : color2; }); }
bool Brush::operator==(const Brush& brush) const { return radius1() == brush.radius1() && radius2() == brush.radius2() && qAbs(hardness1() - brush.hardness1()) <= 1.0/256.0 && qAbs(hardness2() - brush.hardness2()) <= 1.0/256.0 && qAbs(opacity1() - brush.opacity1()) <= 1.0/256.0 && qAbs(opacity2() - brush.opacity2()) <= 1.0/256.0 && color1() == brush.color1() && color2() == brush.color2() && spacing() == brush.spacing() && subpixel() == brush.subpixel() && incremental() == brush.incremental() && blendingMode() == brush.blendingMode(); }
Tree::Tree( int id, float value ) : m_id( id ), m_value( value ), m_texturePosition( QVector3D( 0, 0, 0 ) ), m_parent( 0 ) { QColor color1( 255, 0, 0 ); QColor color2( 128, 128, 128 ); m_colors.push_back( color1 ); m_colors.push_back( color2 ); m_colors.push_back( color2 ); m_colors.push_back( color2 ); }
// ************************************************************* // SetTransparency() // ************************************************************* void ImageHelper::SetTransparency(Gdiplus::ImageAttributes& attributes, bool useTransparency, OLE_COLOR clr1, OLE_COLOR clr2) { // setting range of colors which will be transparent if (useTransparency) { Gdiplus::Color color1(MIN(GetRValue(clr1), GetRValue(clr2)), MIN(GetGValue(clr1), GetGValue(clr2)), MIN(GetBValue(clr1), GetBValue(clr2))); Gdiplus::Color color2(MAX(GetRValue(clr1), GetRValue(clr2)), MAX(GetGValue(clr1), GetGValue(clr2)), MAX(GetBValue(clr1), GetBValue(clr2))); attributes.SetColorKey(color1, color2); } }
QVector<QPair<QColor, int> > *MainWindow::makeColors() { QVector<QPair<QColor, int> > *colors = new QVector<QPair<QColor, int > >(); QColor color1(128,0,0); QColor color2(255,0,0); QColor color3(0,128,0); QColor color4(0,255,0); QColor color5(0,0,128); QColor color6(0,0,255); colors->push_back(QPair<QColor, int>(color1, 2)); colors->push_back(QPair<QColor, int>(color2, 2)); colors->push_back(QPair<QColor, int>(color3, 2)); colors->push_back(QPair<QColor, int>(color4, 2)); colors->push_back(QPair<QColor, int>(color5, 2)); colors->push_back(QPair<QColor, int>(color6, 2)); return colors; }
void QmaxButton::createSideButton(QPainter &painter) { QRect scaledRect; scaledRect = matrix.mapRect(QRect(0,0,this->logicalSize.width(),this->logicalSize.height())); QColor color1(80,85,85,255); QColor color(189,198,198,255); QColor color2(155,150,158,255); QPoint start(0,40); QPoint end(40,80); QLinearGradient gradient(start,end); QLinearGradient brush1(0,0,0,scaledRect.height()); QPen pen(QBrush(color),2); if(m_nPressed) { painter.setPen(pen); gradient.setColorAt(0,color); gradient.setColorAt(1,color2); } else { painter.setPen(Qt::NoPen); gradient.setColorAt(0,color1); gradient.setColorAt(1,color1); } painter.setBrush(gradient); painter.drawRect(0,0,100,80); painter.drawPixmap(0, 0, this->m_strImage); QFont font( "DejaVu Sans" ); font.setPointSize( 12 ); painter.setFont( font ); brush1.setColorAt(1.0f,QColor(255,255,255,255)); if(this->isEnabled()==false) { brush1.setColorAt(1.0f,QColor(200,200,200,100)); } painter.setPen(QPen(brush1,1)); painter.setBrush(brush1); QFontMetrics fMetrics = painter.fontMetrics(); QSize sz = fMetrics.size( Qt::TextWordWrap, m_strText ); QRectF txtRect( scaledRect.center(), sz ); int xPoint = (scaledRect.width()/2)- ((m_strText.count()/2)); int yPoint = scaledRect.height()/2; painter.drawText(xPoint,yPoint,m_strText); }
static QPixmap& checkeredPixmap() { static QPixmap* pixmap; if (!pixmap) { pixmap = new QPixmap(checkerSize, checkerSize); QPainter painter(pixmap); QColor color1(checkerColor1); QColor color2(checkerColor2); for (unsigned y = 0; y < checkerSize; y += checkerSize / 2) { bool alternate = y % checkerSize; for (unsigned x = 0; x < checkerSize; x += checkerSize / 2) { painter.fillRect(x, y, checkerSize / 2, checkerSize / 2, alternate ? color1 : color2); alternate = !alternate; } } } return *pixmap; }
QString LinearColorMap::toXmlString() { QString s = "<ColorMap>\n"; s += "\t<Mode>" + QString::number(mode()) + "</Mode>\n"; s += "\t<MinColor>" + color1().name() + "</MinColor>\n"; s += "\t<MaxColor>" + color2().name() + "</MaxColor>\n"; if (d_range.isValid()) s += "\t<Range>" + QString::number(d_range.minValue(), 'g', 15) + "\t" + QString::number(d_range.maxValue(), 'g', 15) + "</Range>\n"; QwtArray <double> colors = colorStops(); int stops = (int)colors.size(); s += "\t<ColorStops>" + QString::number(stops - 2) + "</ColorStops>\n"; for (int i = 1; i < stops - 1; i++){ s += "\t<Stop>" + QString::number(colors[i], 'g', 15) + "\t"; s += color(i).name(); s += "</Stop>\n"; } return s += "</ColorMap>\n"; }
bool CScreenBox::UdateAnimCoord(unsigned long long timeUnit) { double timeRatio=std::min(1.0,(timeUnit-Animation.AnimStartTime)/double(Animation.Duration)); float p[5]; Animation.AnimCoord.GetPoint(timeRatio,p); RotX[1]=p[0]; RotY[1]=p[1]; PosX[1]=p[2]; PosY[1]=p[3]; PosZ[1]=p[4]; if (DimX[1]!=p[5] || DimY[1]!=p[6]) { DimX[1]=p[5]; DimY[1]=p[6]; OpenUtility::RGBAd color1(0.8,0.8,0.8,1.0),color2(0.6,0.6,0.6,1.0); Background->UpdateCoord(DimX[1]/2,DimY[1]/2,-DimX[1]/2,-DimY[1]/2,color1,color1,color2,color2); } return(timeRatio==1.0); }
antPlane::antPlane ( float width, float depth, int nColumns, int nRows, int nVbo, bool genColors, bool genNormals, bool genTexCoords ) : antDrawable( nVbo, ATTR_POSITION ), m_width( width ), m_depth( depth ), m_nColumns( nColumns ), m_nRows( nRows ) { m_nVertices = ( m_nColumns * m_nRows * 6 ); antRGBA color1( 0.f, 0.f, 0.f, 1.f ); antRGBA color2( 1.f, 1.f, 1.f, 1.f ); generateVertices(); if ( genColors ) { generateColors( color1, color2 ); } if ( genNormals ) { generateNormals(); } if ( genTexCoords ) { generateTexCoords(); } }
void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics, FX_FLOAT fx1, FX_FLOAT fy1, FX_FLOAT fx2, FX_FLOAT fy2, FX_ARGB beginColor, FX_ARGB endColor, CFX_Path* path, int32_t fillMode, CFX_Matrix* pMatrix) { if (!pGraphics || !path) return; CFX_PointF begPoint(fx1, fy1); CFX_PointF endPoint(fx2, fy2); CFX_Shading shading(begPoint, endPoint, false, false, beginColor, endColor); pGraphics->SaveGraphState(); CFX_Color color1(&shading); pGraphics->SetFillColor(&color1); pGraphics->FillPath(path, fillMode, pMatrix); pGraphics->RestoreGraphState(); }
void PhysicsDebugDraw_Impl::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) { const int k_segments = 16; const float32 k_increment = 2.0f * b2_pi / (float)k_segments; float32 radiuss = radius * physic_scale; float32 theta = 0.0f; GraphicContext gc = used_canvas->get_gc(); Vec2f CLaxis(axis.x,axis.y); Vec2f CLcenter(center.x*physic_scale,center.y*physic_scale); Vec2f *positions= new Vec2f[k_segments]; //delete id 3 Colorf color1(0.5f*color.r,0.5f*color.g,0.5f*color.b,0.5f); Colorf color2(color.r,color.g,color.b,1.0f); used_canvas->fill_circle(Pointf(CLcenter.x, CLcenter.y), radiuss, Colorf(color.r,color.g,color.b,0.5f)); int i; for(i=0;i<k_segments;i++) { positions[i]= (Vec2f(cosf(theta),sinf(theta)) * radiuss) + CLcenter; theta+= k_increment; } for(i=0;i<k_segments;i++) { used_canvas->draw_line(positions[i].x*physic_scale,positions[i].y*physic_scale, positions[i+1].x*physic_scale,positions[i+1].y*physic_scale, color2); } used_canvas->draw_line(positions[0].x*physic_scale,positions[0].y*physic_scale, positions[k_segments-1].x*physic_scale,positions[k_segments-1].y*physic_scale, color2); delete positions; //delete id 3 }
void MainWindow::createActions() { openAct = new QAction("&Open", this); connect(openAct, SIGNAL(triggered()), this, SLOT(openAndReadFile())); exitAct = new QAction("E&xit", this); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction("&About", this); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); statAct = new QAction("&Stat", this); connect(statAct, SIGNAL(triggered()), this, SLOT(showStat())); resetAct = new QAction("&Reset position", this); resetAct->setStatusTip("Reset the position"); connect(resetAct, SIGNAL(triggered()), this, SLOT(reset())); reseteffectAct = new QAction("&Reset", this); reseteffectAct->setStatusTip("Reset all material"); connect(reseteffectAct, SIGNAL(triggered()), this, SLOT(reseteffect())); //ANIMATION----------------------------------------------------- animationShownAct = new QAction("&Shown", this); animationShownAct->setStatusTip("Show animation"); animationShownAct->setCheckable(true); connect(animationShownAct, SIGNAL(triggered()), this, SLOT(showAnimation())); animationHiddenAct = new QAction("&Hidden", this); animationHiddenAct->setStatusTip("Hide animation"); animationHiddenAct->setCheckable(true); connect(animationHiddenAct, SIGNAL(triggered()), this, SLOT(hideAnimation())); animationGroup = new QActionGroup(this); animationGroup->addAction(animationShownAct); animationGroup->addAction(animationHiddenAct); animationHiddenAct->setChecked(true); //COLOR----------------------------------------------------- color0Act = new QAction("&No light",this); color0Act->setStatusTip("No light"); color0Act->setCheckable(true); connect(color0Act, SIGNAL(triggered()), this, SLOT(color0())); color1Act = new QAction("&Red",this); color1Act->setStatusTip("Red"); color1Act->setCheckable(true); connect(color1Act, SIGNAL(triggered()), this, SLOT(color1())); color2Act = new QAction("&Green",this); color2Act->setStatusTip("Green"); color2Act->setCheckable(true); connect(color2Act, SIGNAL(triggered()), this, SLOT(color2())); color3Act = new QAction("&Blue",this); color3Act->setStatusTip("Blue"); color3Act->setCheckable(true); connect(color3Act, SIGNAL(triggered()), this, SLOT(color3())); color10Act = new QAction("&White",this); color10Act->setStatusTip("White"); color10Act->setCheckable(true); connect(color10Act, SIGNAL(triggered()), this, SLOT(color10())); colorGroup = new QActionGroup(this); colorGroup->addAction(color0Act); colorGroup->addAction(color1Act); colorGroup->addAction(color2Act); colorGroup->addAction(color3Act); colorGroup->addAction(color10Act); color10Act->setChecked(true); //EFFECT----------------------------------------------------- effect0Act = new QAction("&No effect",this); effect0Act->setStatusTip("No effect"); effect0Act->setCheckable(true); connect(effect0Act, SIGNAL(triggered()), this, SLOT(effect0())); effect1Act = new QAction("&Ambient",this); effect1Act->setStatusTip("Ambient"); effect1Act->setCheckable(true); connect(effect1Act, SIGNAL(triggered()), this, SLOT(effect1())); effect2Act = new QAction("&Diffuse",this); effect2Act->setStatusTip("Diffuse"); effect2Act->setCheckable(true); connect(effect2Act, SIGNAL(triggered()), this, SLOT(effect2())); effect10Act = new QAction("&All",this); effect10Act->setStatusTip("All effect"); effect10Act->setCheckable(true); connect(effect10Act, SIGNAL(triggered()), this, SLOT(effect10())); effectGroup = new QActionGroup(this); effectGroup->addAction(effect0Act); effectGroup->addAction(effect1Act); effectGroup->addAction(effect2Act); effectGroup->addAction(effect10Act); effect10Act->setChecked(true); //AMBIENT----------------------------------------------------- ambient0Act = new QAction("&No Ambient",this); ambient0Act->setStatusTip("No Ambient"); ambient0Act->setCheckable(true); connect(ambient0Act, SIGNAL(triggered()), this, SLOT(ambient0())); ambient1Act = new QAction("&Ambient",this); ambient1Act->setStatusTip("Ambient"); ambient1Act->setCheckable(true); connect(ambient1Act, SIGNAL(triggered()), this, SLOT(ambient1())); ambient2Act = new QAction("&Ambient Color",this); ambient2Act->setStatusTip("Ambient Color"); ambient2Act->setCheckable(true); connect(ambient2Act, SIGNAL(triggered()), this, SLOT(ambient2())); ambientGroup = new QActionGroup(this); ambientGroup->addAction(ambient0Act); ambientGroup->addAction(ambient1Act); ambientGroup->addAction(ambient2Act); ambient0Act->setChecked(true); //DIFFUSE----------------------------------------------------- diffuse0Act = new QAction("&No Diffuse",this); diffuse0Act->setStatusTip("No Diffuse"); diffuse0Act->setCheckable(true); connect(diffuse0Act, SIGNAL(triggered()), this, SLOT(diffuse0())); diffuse1Act = new QAction("&Diffuse",this); diffuse1Act->setStatusTip("Diffuse"); diffuse1Act->setCheckable(true); connect(diffuse1Act, SIGNAL(triggered()), this, SLOT(diffuse1())); diffuseGroup = new QActionGroup(this); diffuseGroup->addAction(diffuse0Act); diffuseGroup->addAction(diffuse1Act); diffuse0Act->setChecked(true); //SPECULAR----------------------------------------------------- specular0Act = new QAction("&No Specular",this); specular0Act->setStatusTip("No Specular"); specular0Act->setCheckable(true); connect(specular0Act, SIGNAL(triggered()), this, SLOT(specular0())); specular1Act = new QAction("&Specular",this); specular1Act->setStatusTip("Specular"); specular1Act->setCheckable(true); connect(specular1Act, SIGNAL(triggered()), this, SLOT(specular1())); specularGroup = new QActionGroup(this); specularGroup->addAction(specular0Act); specularGroup->addAction(specular1Act); specular0Act->setChecked(true); //SPECULAR----------------------------------------------------- shininess0Act = new QAction("&No Shininess",this); shininess0Act->setStatusTip("No Shininess"); shininess0Act->setCheckable(true); connect(shininess0Act, SIGNAL(triggered()), this, SLOT(shininess0())); shininess1Act = new QAction("&Low Shininess",this); shininess1Act->setStatusTip("Low Shininess"); shininess1Act->setCheckable(true); connect(shininess1Act, SIGNAL(triggered()), this, SLOT(shininess1())); shininess2Act = new QAction("&High Shininess",this); shininess2Act->setStatusTip("High Shininess"); shininess2Act->setCheckable(true); connect(shininess2Act, SIGNAL(triggered()), this, SLOT(shininess2())); shininessGroup = new QActionGroup(this); shininessGroup->addAction(shininess0Act); shininessGroup->addAction(shininess1Act); shininessGroup->addAction(shininess2Act); shininess0Act->setChecked(true); //EMISSION----------------------------------------------------- emission0Act = new QAction("&No Emission",this); emission0Act->setStatusTip("No Emission"); emission0Act->setCheckable(true); connect(emission0Act, SIGNAL(triggered()), this, SLOT(emission0())); emission1Act = new QAction("&Emission",this); emission1Act->setStatusTip("eEmission"); emission1Act->setCheckable(true); connect(emission1Act, SIGNAL(triggered()), this, SLOT(emission1())); emissionGroup = new QActionGroup(this); emissionGroup->addAction(emission0Act); emissionGroup->addAction(emission1Act); emission0Act->setChecked(true); //SHADING------------------------------------------------- shading0Act = new QAction("&No shading", this); shading0Act->setStatusTip("No shading"); shading0Act->setCheckable(true); connect(shading0Act, SIGNAL(triggered()), this, SLOT(shading0())); shading1Act = new QAction("&Flat shading", this); shading1Act->setStatusTip("Flat shading"); shading1Act->setCheckable(true); connect(shading1Act, SIGNAL(triggered()), this, SLOT(shading1())); shading2Act = new QAction("&Smooth shading", this); shading2Act->setStatusTip("Smooth shading"); shading2Act->setCheckable(true); connect(shading2Act, SIGNAL(triggered()), this, SLOT(shading2())); shadingGroup = new QActionGroup(this); shadingGroup->addAction(shading0Act); shadingGroup->addAction(shading1Act); shadingGroup->addAction(shading2Act); shading0Act->setChecked(true); //NORMAL---------------------------------------------------- normal0Act = new QAction("&No normal",this); normal0Act->setStatusTip("No normal"); normal0Act->setCheckable(true); connect(normal0Act, SIGNAL(triggered()), this, SLOT(normal0())); normal1Act = new QAction("&normal",this); normal1Act->setStatusTip("Has normal"); normal1Act->setCheckable(true); connect(normal1Act, SIGNAL(triggered()), this, SLOT(normal1())); normalGroup = new QActionGroup(this); normalGroup->addAction(normal0Act); normalGroup->addAction(normal1Act); normal0Act->setChecked(true); }
int main(int argc, const char * argv[]) { // ========= Declare and initialize variables ========== BikeShed bike_shed; Color color1(4.5, 6.0 ,7.0); Color color2(0.0, 0.0, 3.0); Color color3(0.0, 8.4 ,0.0); Bike john_bike("John", color1); Bike jane_bike("Jane", color1); Bike sean_bike("Sean", color2); Bike andrea_bike("Andrea", color2); Bike peter_bike("Peter", color3); Bike mohammed_bike("Mohammed", color3); Bike hong_bike("Hong", color3); // ========= END Declare and initialize variables ========== // ========= Set the bike values of each person ========== john_bike.setBell(true); john_bike.setReflector(true); john_bike.setNLight(1); jane_bike.setBell(true); jane_bike.setNLight(2); sean_bike.setBell(true); sean_bike.setReflector(true); sean_bike.setNLight(7); andrea_bike.setBell(true); peter_bike.setBell(true); peter_bike.setReflector(true); mohammed_bike.setBell(true); mohammed_bike.setReflector(true); mohammed_bike.setNLight(3); hong_bike.setReflector(true); hong_bike.setNLight(20); // ========= END Set the bike values of each person ========== // ========= Performing different checks on the bikes ========== bike_shed.park(john_bike); std::cout << "Bikes in shed after John parks:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.park(jane_bike); std::cout << "Bikes in shed after Jane parks:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.park(sean_bike); std::cout << "Bikes in shed after Sean parks:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.park(andrea_bike); std::cout << "Bikes in shed after Andrea parks:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.park(peter_bike); std::cout << "Bikes in shed after Peter parks:" << "\n\n"; bike_shed.print(); std::cout << "\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; std::cout << "Illegal bikes:" << "\n\n"; bike_shed.checkLegal(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; std::cout << "Removing bikes:" << "\n\n"; bike_shed.remove("Peter", 1).print(); std::cout << "Bikes in shed after Peter's bike is removed:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.remove("John", 1).print(); std::cout << "Bikes in shed after John's bike is removed:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.remove("Andrea", 1).print(); std::cout << "Bikes in shed after Andrea's bike is removed:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.park(mohammed_bike); std::cout << "Bikes in shed after Mohammed parks:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; bike_shed.park(hong_bike); std::cout << "Bikes in shed after Hong parks:" << "\n\n"; bike_shed.print(); std::cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =" << "\n\n"; std::cout << "Remaining bikes:" << "\n\n"; bike_shed.print(); std::cout << "\n"; // ========= END Performing different checks on the bikes ========== return 0; }
void Check_Copter(Copter& copter) { bool Flag_1 = false; bool Flag_2 = false; Mat YUV; Mat color1(copter.height , copter.width , CV_8UC1); Mat color2(copter.height , copter.width , CV_8UC1); Mat color3(copter.height , copter.width , CV_8UC1); Mat color1_2(copter.height , copter.width , CV_8UC1); Mat color1_3(copter.height , copter.width , CV_8UC1); Mat color2_2(copter.height , copter.width , CV_8UC1); Mat color2_3(copter.height , copter.width , CV_8UC1); Mat Temp_roi; vector<vector<Point> > contours1; vector<vector<Point> > contours2; vector<vector<Point> > contours3; vector<Vec4i> hierarchy1; vector<Vec4i> hierarchy2; vector<Vec4i> hierarchy3; Rect copter_box1; Rect copter_box2; Rect copter_box3; Rect copter_box4; int max_contour1=0; int max_contour2=0; int max_contour3=0; int min_num1 =0x7fffff; int min_num2 =0x7fffff; int min_num3 =0x7fffff; int x1, x2, y1, y2; int min_diff =0x7fffff; int min_diff2 =0x7fffff; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; double start,end,t1; pthread_mutex_lock(&mutex); cvtColor(copter.Copter_Layer,YUV,CV_RGB2YCrCb); pthread_mutex_unlock(&mutex); vector<Mat> yuv; split(YUV,yuv); // start=(double)cvGetTickCount(); threshold(yuv[0],yuv[0],copter.Y_MAX,255,THRESH_TOZERO_INV); threshold(yuv[0],(color1),copter.Y_MIN,255,THRESH_BINARY); threshold(yuv[1],yuv[1],copter.Cb_MAX,255,THRESH_TOZERO_INV); threshold(yuv[1],(color1_2),copter.Cb_MIN,255,THRESH_BINARY); threshold(yuv[2],yuv[2],copter.Cr_MAX,255,THRESH_TOZERO_INV); threshold(yuv[2],(color1_3),copter.Cr_MIN,255,THRESH_BINARY); bitwise_and(color1,color1_2,color1_2); bitwise_and(color1_2,color1_3,color1); split(YUV,yuv); threshold(yuv[0],yuv[0],copter.Y_MAX2,255,THRESH_TOZERO_INV); threshold(yuv[0],(color2),copter.Y_MIN2,255,THRESH_BINARY); threshold(yuv[1],yuv[1],copter.Cb_MAX2,255,THRESH_TOZERO_INV); threshold(yuv[1],(color2_2),copter.Cb_MIN2,255,THRESH_BINARY); threshold(yuv[2],yuv[2],copter.Cr_MAX2,255,THRESH_TOZERO_INV); threshold(yuv[2],(color2_3),copter.Cr_MIN2,255,THRESH_BINARY); bitwise_and(color2,color2_2,color2_2); bitwise_and(color2_2,color2_3,color3); // end=(double)cvGetTickCount(); // t1 = (end-start)/((double)cvGetTickFrequency()*1000.); // printf("Threshold : %g ms\n",t1); #if DEBUG start=(double)cvGetTickCount(); #endif findContours(color1, contours1, hierarchy1, RETR_CCOMP, CHAIN_APPROX_TC89_KCOS); if(contours1.size() == 0 ) { cout <<copter.number <<": no color1 ! " << endl; } for(size_t idx = 0; idx < contours1.size(); idx++) { drawContours(color1,contours1,idx,Scalar(255,255,255),CV_FILLED,8); } bitwise_and(color1,color3,color2); findContours(color2, contours2,hierarchy2, RETR_CCOMP, CHAIN_APPROX_TC89_KCOS); if(contours2.size() == 0 ) { cout <<copter.number << ": no color2 ! " << endl; } #if DEBUG end=(double)cvGetTickCount(); t1 = (end-start)/((double)cvGetTickFrequency()*1000.); printf("findcountours : %g ms\n",t1); start=(double)cvGetTickCount(); #endif for(int m=0; m<contours1.size(); m++) { for(int n=0; n<contours2.size(); n++) {// copter_box1 = boundingRect(contours1[m]); copter_box2 = boundingRect(contours2[n]); Point box2_center = Point(copter_box2.x+(copter_box2.width/2),copter_box2.y+(copter_box2.height/2)); if(box2_center.x >=copter_box1.x-copter_box1.width && box2_center.x <= copter_box1.x+copter_box1.width*2 && box2_center.y >=copter_box1.y-copter_box1.height && box2_center.y <=copter_box1.y+(copter_box1.height)*2) { int diff = abs(copter_box2.x+(copter_box2.width/2) - copter_box1.x+(copter_box1.width/2)) + abs(copter_box2.y+(copter_box2.height/2) - copter_box1.y+(copter_box1.height/2)); if(diff < min_diff){ min_diff = diff; min_num1 = m; min_num2 = n; } } }// } absdiff(color3,color2,color3); findContours(color3, contours3, hierarchy3, RETR_CCOMP, CHAIN_APPROX_TC89_KCOS); if(contours1.size()>0 && contours3.size()>0 && min_num1 < contours1.size()) { copter_box4 = boundingRect(contours1[min_num1]); int centerof_box4_x = copter_box4.x + (copter_box4.width/2); int centerof_box4_y = copter_box4.y + (copter_box4.height/2); int centerof_box3_x=0; int centerof_box3_y=0; for(int t=0; t<contours3.size(); t++) { bool check_exception=true; copter_box3 = boundingRect(contours3[t]); centerof_box3_x = copter_box3.x + (copter_box3.width/2); centerof_box3_y = copter_box3.y + (copter_box3.height/2); if(centerof_box3_x >= copter_box4.x && centerof_box3_x <= copter_box4.x+copter_box4.width && centerof_box3_y >= copter_box4.y && centerof_box3_y <= copter_box4.y+copter_box4.height) { check_exception = false; } if(check_exception && contours3[t].size() < contours1[min_num1].size() && t != min_num2 ) { int diff = abs(centerof_box4_x - centerof_box3_x) + abs(centerof_box4_y - centerof_box3_y); if(diff<min_diff2){ min_diff2 = diff; min_num3 = t; } } } if(min_num3 <contours3.size()) { copter_box3 = boundingRect(contours3[min_num3]); copter.Head_vector = Return_HeadWay(copter_box3, copter_box4); } } #if DEBUG cout << "Copter.Head_Vector : " << copter.Head_vector << endl; #endif #if DEBUG end=(double)cvGetTickCount(); t1 = (end-start)/((double)cvGetTickFrequency()*1000.); printf("for loop : %g ms\n",t1); start =(double)cvGetTickCount(); #endif if(min_diff > 10000) { copter.not_found_count++; switch(copter.vector) { case 1 : copter.width += (copter.width>>1); //cout << copter.number << " : 1 " << endl; break; case 2 : copter.width += (copter.width>>1); copter.y -= (copter.height>>1); copter.height += (copter.height>>1); //cout << copter.number << " : 2 " << endl; break; case 3 : copter.y -= (copter.height>>1); copter.height += (copter.height>>1); //cout << copter.number << " : 3 "<< endl; break; case 4 : copter.x -= (copter.width>>1); copter.width +=(copter.width>>1); copter.y -= (copter.height>>1); copter.height += (copter.height>>1); //cout << copter.number << " : 4 "<< endl; break; case 5 : copter.x -= (copter.width>>1); copter.width += (copter.width>>1); //cout << copter.number << " : 5 "<< endl; break; case 6 : copter.x -= (copter.width>>1); copter.width += (copter.width>>1); copter.height += (copter.height>>1); //cout << copter.number << " : 6 "<< endl; break; case 7 : copter.height += (copter.height>>1); //cout << copter.number << " : 7 "<< endl; break; case 8 : copter.height += (copter.height>>1); copter.width += (copter.width>>1); //cout << copter.number << " : 8 "<< endl; break; default : break; } Reposition_minus(copter); if(copter.not_found_count >=FIND_THRESHOLD) { copter.not_found_count = 0 ; copter.Flag = false; } return; }//확인요망