Beispiel #1
0
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());
}
Beispiel #2
0
void Line::draw(CImage *img){
    int i;
    for (i = min(getX(), getX2()); i<max(getX(), getX2()); i++){
        CPixel *p = img->getPixel(i, interpolate(i));
        *p = color;

        }
}
Beispiel #3
0
bool Rectangle::contains(int x, int y)
{
    if(x >= getX() && y >= getY() && x <= getX2() && y <= getY2())
        return true;

    return false;
}
Beispiel #4
0
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);
		}
	}
}
Beispiel #5
0
//----------------------------------------------------------
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;
}
Beispiel #6
0
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 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());
}
Beispiel #8
0
//----------------------------------------------------------
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);
}
Beispiel #9
0
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;
}
Beispiel #10
0
/** 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);
	*/
}
    void InfTheoMetricLearner::computeConstraints() {

        simConstraints.flush();
        disSimConstraints.flush();

        int sampleCount = getSampleCount();

        for(int i = 0; i < sampleCount; ++i) {

            vec x1 = getX1(i);
            vec x2 = getX2(i);

            double dist = getSampleDistance(i);
            if(dist <= simBorder) {
                simConstraints.addConstraint(x1, x2, simBorder);
            } else if(dist >= disSimBorder) {
                disSimConstraints.addConstraint(x1, x2, disSimBorder);
            } else {
                // no additional constraint
            }

        }

    }
/// 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 );
        }
    }
}
Beispiel #13
0
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());
}
Beispiel #14
0
void Line::check(){
    cout << "------------ LINE PARAMETERS -------------" << endl;
    cout << "Position: " << Shape::getX() << "*" << getY() << " (X,Y)" << endl;
    cout << "End: " << getX2() << "*" << getY2() << " (X2,Y2)" << endl;
    cout << "------------------------------------------" << endl;
}
Beispiel #15
0
int Line::interpolate(int x){
    float f;
    f = ( ( x - getX() )*( getY2() - getY()) / ( getX2() - getX()) ) + getY();
    return round(f);

}
Beispiel #16
0
int QFCropPixelsEdit::getWIDTH() const
{
    return getX2()-getX1()+1;
}