bool MapNode::overlapsMap() { if(map == NULL) return false; for(int x = getX(); x < getX2(); x+= map->getTileWidth()) { for(int y = getY(); y < getY2(); y+= map->getTileHeight()) { if(map->checkSolid(x/map->getTileWidth(), y/map->getTileHeight())) { return true; } } if(map->checkSolid(x/map->getTileWidth(), getY2()/map->getTileHeight())) { return true; } } for(int y = getY(); y < getY2(); y+= map->getTileHeight()) { if(map->checkSolid(getX2()/map->getTileWidth(), y/map->getTileHeight())) { return true; } } return map->checkSolid(getX2()/map->getTileWidth(), getY2()/map->getTileHeight()); }
void MapNode::move(int x, int y) { if (!solid || map == NULL) { setX(getX() + x); setY(getY() + y); return; } setX(getX() + x); if (x < 0) { if (overlapsMap()) { setX(((getX() / map->getTileWidth()) + 1) * map->getTileWidth()); } } if (x > 0) { if (overlapsMap()) { setX2((getX2() / map->getTileWidth()) * map->getTileWidth() - 1); } } setY(getY() + y); if (y < 0) { if (overlapsMap()) { setY(((getY() / map->getTileHeight()) + 1) * map->getTileHeight()); } } if (y > 0) { if (overlapsMap()) { setY2((getY2() / map->getTileHeight()) * map->getTileHeight() - 1); } } }
/// Draw the Slider void Slider::draw() const { if(showing) { if( type == HORIZONTAL ) { gl::color( ColorA( 0.2,0.3,0.4, alpha) ); gl::drawSolidRoundedRect( *this, 5.0, 32 ); Rectf pctg_rect = Rectf( Vec2f( getX1(), getY1() ), Vec2f( getX1() + pctg*getWidth(), getY2() ) ) ; gl::color( color ); gl::drawSolidRoundedRect( pctg_rect, 5.0, 32); } else if( type == VERTICAL ) { gl::color( ColorA( 0.2,0.3,0.4, alpha) ); gl::drawSolidRoundedRect( *this, 5.0, 32 ); Rectf pctg_rect = Rectf( Vec2f( getX1(), getY2() - pctg*getHeight() ), Vec2f( getX2(), getY2() ) ) ; gl::color( color ); gl::drawSolidRoundedRect( pctg_rect, 5.0, 32); } else if( type == CIRCULAR ) { gl::color( ColorA( 0.2,0.3,0.4, alpha) ); _drawArc( getCenter(), getWidth(), getHeight(), 0.0, 2*3.14159 , 10 ); gl::color( color ); _drawArc( getCenter(), getWidth(), getHeight(), 0.0, 2*3.14159*pctg, 7 ); } } }
bool Rectangle::contains(int x, int y) { if(x >= getX() && y >= getY() && x <= getX2() && y <= getY2()) return true; return false; }
void Utility::Yuv422FileSaver::savePlanar() { for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) { QVector<unsigned char> uBuffer; QVector<unsigned char> vBuffer; auto frame=video_->getFrame(k); for(int i=0; i<width_*height_; i+=2) { int y1=i/width_; int x1=i%width_; int y2=(i+1)/width_; int x2=(i+1)%width_; if(!frame->valid(x1,y1)||!frame->valid(x2,y2)) { qDebug()<<"Wrong pixel coordinates"; continue; } auto vec=Rgb888ToYuv422(frame->pixel(x1,y1),frame->pixel(x2,y2)); dataStream_<<vec.getY1()<<vec.getY2(); uBuffer.push_back(vec.getU()); vBuffer.push_back(vec.getV()); } while (!uBuffer.isEmpty()) { dataStream_<<uBuffer.takeFirst(); } while (!vBuffer.isEmpty()) { dataStream_<<vBuffer.takeFirst(); } } }
void BossEntity::updateMoving() { setY(getY()+yVel); if(getY() < camera->getY()) { yVel = ENTITY_SPEED; } if(getY2() > camera->getY2()) { yVel = -ENTITY_SPEED; } if(rand()%100 == 1) { state = STATE_ATTACKING; attackCounter = 0; } if(health <= 200) { panicCounter = 0; state = STATE_PANIC; } }
//---------------------------------------------------------- bool Rect::operator == (const Rect & rect) const { bool bSame = true; bSame = bSame && (getX1() == rect.getX1()); bSame = bSame && (getX2() == rect.getX2()); bSame = bSame && (getY1() == rect.getY1()); bSame = bSame && (getY2() == rect.getY2()); return bSame; }
void TestYuv411FileSaver::testRgb888ToYuv411() { auto vector = Utility::Yuv411FileSaver::Rgb888ToYuv411(pixel1,pixel2,pixel3,pixel4); QVERIFY(vector.getY1() == 16); QVERIFY(vector.getU() == 128); QVERIFY(vector.getV() == 128); QVERIFY(vector.getY2() == 16); QVERIFY(vector.getY3() == 16); QVERIFY(vector.getY4() == 16); }
void QFCropPixelsEdit::spinValueChanged() { connectWidgets(false); if (spinX2->value()<=spinX1->value()) { spinX1->setValue(spinX2->value()+1); } if (spinY2->value()<=spinY1->value()) { spinY1->setValue(spinY2->value()+1); } connectWidgets(true); emit valueChanged(getX1(), getX2(), getY1(), getY2()); }
std::vector<Line> HourGlass::getLines() const { std::vector<Line> lines; float x1 = getX1()+2; float x2 = getX2()-2; float y1 = getY1()+2; float y2 = getY2()-2; lines.push_back(Line(x1,y1,x2,y2)); lines.push_back(Line(x2,y1,x1,y2)); lines.push_back(Line(x1,y1,x2,y1)); lines.push_back(Line(x1,y2,x2,y2)); return lines; }
//---------------------------------------------------------- void Rect::lerp(const Rect & rect, float p) { float _x1 = coc::lerp(getX1(), rect.getX1(), p); float _x2 = coc::lerp(getX2(), rect.getX2(), p); float _y1 = coc::lerp(getY1(), rect.getY1(), p); float _y2 = coc::lerp(getY2(), rect.getY2(), p); setX1(_x1); setX2(_x2); setY1(_y1); setY2(_y2); }
bool Rectangle::overlaps(Rectangle rect) { if(getX() > rect.getX2()) return false; if(getY() > rect.getY2()) return false; if(rect.getX() > getX2()) return false; if(rect.getY() > getY2()) return false; return true; }
void BossEntity::updatePanic() { getScene()->addNode(factory->makeEntity(ENTITY_SILENT_EXPLOSION, getX() + rand()%getWidth(), getY() + rand()%getHeight())); panicCounter++; if(panicCounter > 100) panicCounter = 0; setY(getY()+yVel); if(getY() < camera->getY()) { yVel = ENTITY_SPEED; } if(getY2() > camera->getY2()) { yVel = -ENTITY_SPEED; } if(panicCounter %5 != 0) return; if(health < 0) { remove(); } if(panicCounter > 10 && panicCounter < 30) { getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+(rand()%getHeight()))); } if(panicCounter > 30 && panicCounter < 60 && rand()%4) { getScene()->addNode(factory->makeEntity(ENTITY_ALIEN_SCOUT, getX(), getY()+(rand()%getHeight()))); } if(panicCounter > 60 && panicCounter < 100 && rand()%4) { getScene()->addNode(factory->makeEntity(ENTITY_ALIEN_SCOUT, getX(), getY()+(rand()%getHeight()))); getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+(rand()%getHeight()))); } }
void BossEntity::updateAttacking() { attackCounter++; if(attackCounter == 10) { for(int i = 0; i < getHeight(); i+= getHeight()/5) { getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+i)); } } if(attackCounter > 20) { setY(getY()+yVel); if(getY() < camera->getY()) { yVel = ENTITY_SPEED; } if(getY2() > camera->getY2()) { yVel = -ENTITY_SPEED; } } if(attackCounter == 30) { for(int i = 0; i < getHeight(); i+= getHeight()/5) { getScene()->addNode(factory->makeEntity(ENTITY_ALIEN_SCOUT, getX(), getY()+i)); } } if(attackCounter >= 50) { for(int i = 0; i < getHeight(); i+= getHeight()/10) { getScene()->addNode(factory->makeEntity(ENTITY_ENEMY_BULLET, getX(), getY()+i)); } state = STATE_MOVING; } }
void Utility::Yuv422FileSaver::savePacked() { for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) { auto frame=video_->getFrame(k); for(int i=0; i<width_*height_; i+=2) { int y1=i/width_; int x1=i%width_; int y2=(i+1)/width_; int x2=(i+1)%width_; if(!frame->valid(x1,y1)||!frame->valid(x2,y2)) { qDebug()<<"Wrong pixel coordinates"; continue; } auto vec=Rgb888ToYuv422(frame->pixel(x1,y1),frame->pixel(x2,y2)); dataStream_<<vec.getU()<<vec.getY1()<<vec.getV()<<vec.getY2(); } } }
/** Other Functions **/ void Wall::draw(Renderer & g_renderer) { /* * Draw the line for this Wall object. Use the simple SDL * functions. The hexidecimal can also be written as decimal. */ SDL_SetRenderDrawColor(g_renderer, 0x20, 0x20, 0x20, 0x20); SDL_RenderDrawLine(g_renderer, getX(), getY(), getX2(), getY2()); /* int y = getY(); int z; do { SDL_RenderDrawPoint(g_renderer, getX(), y); if (getO() == TOP) y--; else y++; std::cin >> z; } while (y != 0 && y != 479); */ }
int QFCropPixelsEdit::getHEIGHT() const { return getY2()-getY1()+1; }
int Line::interpolate(int x){ float f; f = ( ( x - getX() )*( getY2() - getY()) / ( getX2() - getX()) ) + getY(); return round(f); }
void Line::check(){ cout << "------------ LINE PARAMETERS -------------" << endl; cout << "Position: " << Shape::getX() << "*" << getY() << " (X,Y)" << endl; cout << "End: " << getX2() << "*" << getY2() << " (X2,Y2)" << endl; cout << "------------------------------------------" << endl; }
void UMLInheritanceLink::draw(Gtk::DrawingArea* drawingArea) { Cairo::RefPtr<Cairo::Context> cr = drawingArea->get_window()->create_cairo_context(); Arrows::draw_arrow(cr, getX1(), getY1(), getX2(), getY2(), Line::FULL, Arrow::NORMAL, Arrow::NONE, isSelected()); }