コード例 #1
0
/**
* Return true if this linearizer can linearize a specified 2D point.
*
* @param const int x
* @param const int y
*
* @return bool
*/
bool Linearizer2D::contains(const int x, const int y) const
{
  return x >= getOffsetX() 
         && y >= getOffsetY()
         && x < getWidth() + getOffsetX()
         && y < getHeight() + getOffsetY();
}
コード例 #2
0
void GuiList<listType>::render()
{
	const int cutoff = getOffsetY();
	const int entrySize = mFont->getHeight() + 5;

	int startEntry = 0;

	//number of entries that can fit on the screen simultaniously
	int screenCount = (Renderer::getScreenHeight() - cutoff) / entrySize;
	//screenCount -= 1;

	if((int)mRowVector.size() >= screenCount)
	{
		startEntry = mSelection - (int)(screenCount * 0.5);
		if(startEntry < 0)
			startEntry = 0;
		if(startEntry >= (int)mRowVector.size() - screenCount)
			startEntry = mRowVector.size() - screenCount;
	}

	int y = cutoff;

	if(mRowVector.size() == 0)
	{
		Renderer::drawCenteredText("The list is empty.", 0, y, 0xFF0000FF, mFont);
		return;
	}

	int listCutoff = startEntry + screenCount;
	if(listCutoff > (int)mRowVector.size())
		listCutoff = mRowVector.size();

	for(int i = startEntry; i < listCutoff; i++)
	{
		//draw selector bar
		if(mSelection == i)
		{
			Renderer::drawRect(getOffsetX(), y, Renderer::getScreenWidth(), mFont->getHeight(), mSelectorColor);
		}

		ListRow row = mRowVector.at((unsigned int)i);

		if(mDrawCentered)
			Renderer::drawCenteredText(row.name, getOffsetX(), y, (mSelection == i && mSelectedTextColorOverride != 0) ? mSelectedTextColorOverride : row.color, mFont);
		else
			Renderer::drawText(row.name, getOffsetX() + mTextOffsetX, y, (mSelection == i && mSelectedTextColorOverride != 0) ? mSelectedTextColorOverride : row.color, mFont);

		y += entrySize;
	}
}
コード例 #3
0
ファイル: Ground.cpp プロジェクト: JRasay89/TappyPlane
void Ground::update(int deltaTime)
{

    setOffsetX(getOffsetX() - (getVelocityX() * (deltaTime/1000.0f)));
    //cout << "Ground Offset X: " << getOffsetX() << endl;
    if (getOffsetX() <= -808.0f)
    {
        setOffsetX(0.0f);
    }

    //Shift the collision boxes
    shiftCollisionBoxes();

}
コード例 #4
0
 void TextBox::drawText()
 {
     font->setColor(textColor);
     
     float innerWidth = width - paddingLeft - paddingRight;
     float innerHeight = height - paddingTop - paddingBottom;
     
     float limitTop = y + paddingTop + font->getAscent();
     float limitBottom = limitTop + innerHeight;
     float yy = limitTop + getOffsetY();
     
     font->beginSequence();
     
     for (int i = 0; i < wrapper.size && yy < limitBottom; i++)
     {
         if (yy + lineHeight > limitTop)
         {
             int start = wrapper.offsets[i];
             int end = start + wrapper.lengths[i];
             
             float limitLeft = x + paddingLeft;
             float limitRight = limitLeft + innerWidth;
             float xx = limitLeft + getOffsetX(start, end);
             
             drawTextSpan(xx, yy, start, end, limitLeft, limitRight);
         }
         
         yy += lineHeight;
     }
     
     font->endSequence();
 }
コード例 #5
0
void OffsetCameraDecorator::getProjection( Matrix &result, 
                                         UInt32 width, UInt32 height)
{
    if(width == 0 || height == 0)
    {
        result.setIdentity();
        return;
    }

    CameraPtr camera = getDecoratee();
    if(camera == NullFC)
    {
        FWARNING(("OffsetCameraDecorator::getProjection: no decoratee!\n"));
        result.setIdentity();
        return;
    }

    if(getFullWidth() != 0)
        width = getFullWidth();

    if(getFullHeight() != 0)
        height = getFullHeight();

    camera->getProjection(result, width, height);

    Real32 x = getOffsetX() / Real32(width);
    Real32 y = getOffsetY() / Real32(height);

    Matrix sm(  1, 0, 0, x,
                0, 1, 0, y,
                0, 0, 1, 0, 
                0, 0, 0, 1);

    result.multLeft(sm);
}
コード例 #6
0
ファイル: Ground.cpp プロジェクト: JRasay89/TappyPlane
/*
 * Shift the collision boxes as the ground's location change
 */
void Ground::shiftCollisionBoxes()
{
    for (int i = 0; i < collisionBoxes_.size(); i++)
    {

        collisionBoxes_[i].x = getOffsetX() + COLLISION_BOX_X[i];
        collisionBoxes_[i].y = getOffsetY() + COLLISION_BOX_Y[i];
    }

    for (int i = 0; i < collisionBoxes_Loop_.size(); i++)
    {

        collisionBoxes_Loop_[i].x = getOffsetX() + COLLISION_BOX_X[i] + 808.0f;
        collisionBoxes_Loop_[i].y = getOffsetY() + COLLISION_BOX_Y[i];
    }
}
コード例 #7
0
ファイル: Plane.cpp プロジェクト: JRasay89/TappyPlane
/*
 * Shift the collision boxes as the plane's location changes
 */
void Plane::shiftCollisionBoxes()
{
    for (int i = 0; i < collisionBoxes_.size(); i++)
    {
        collisionBoxes_[i].x = getOffsetX() + COLLISION_BOX_X[i];
        collisionBoxes_[i].y = getOffsetY() + COLLISION_BOX_Y[i];
    }
}
コード例 #8
0
void ofxTextAlign::draw(string str, float x, float y, unsigned int flags)
{
	const char *ptr = str.c_str();
	float cursor_y = y+getOffsetY(ptr, flags, false);
	int line_count = getLineCount(ptr);
	float y_interval = line_count>1?(getDrawHeight(ptr, false)-getLineHeight())/(float)(line_count-1):0;
	while(*ptr != '\0') {
		float cursor_x = x+getOffsetX(ptr, flags, true);
		ptr = drawLine(ptr, cursor_x, cursor_y);
		cursor_y += y_interval;
	}
}
コード例 #9
0
void GuiImage::render()
{
	if(mTextureID && getOpacity() > 0)
	{
		GLfloat points[12], texs[12];
		GLubyte colors[6*4];

		if(mTiled)
		{
			float xCount = ((float)mResizeWidth/mWidth);
			float yCount = ((float)mResizeHeight/mHeight);

			Renderer::buildGLColorArray(colors, 0xFFFFFF00 | (getOpacity()), 6);
			buildImageArray(getOffsetX(), getOffsetY(), points, texs, xCount, yCount);
		}else{
			Renderer::buildGLColorArray(colors, 0xFFFFFF00 | (getOpacity()), 6);
			buildImageArray(getOffsetX(), getOffsetY(), points, texs);
		}

		drawImageArray(points, texs, colors, 6);
	}
}
コード例 #10
0
ファイル: PrecisionModel.cpp プロジェクト: 0004c/node-gdal
string
PrecisionModel::toString() const
{
	ostringstream s;
  	if (modelType == FLOATING) {
  		s<<"Floating";
  	} else if (modelType == FLOATING_SINGLE) {
  		s<<"Floating-Single";
  	} else if (modelType == FIXED) {
		s <<"Fixed (Scale=" << getScale()
		  << " OffsetX=" << getOffsetX()
		  << " OffsetY=" << getOffsetY()
		  << ")";
	} else {
		s<<"UNKNOWN";
	}
	return s.str();
}
コード例 #11
0
 /*
  * AN index EQUAL TO numeric_limits<int>::min() MEANS: FIRST CHARACTER ON THE LINE
  * AN index EQUAL TO numeric_limits<int>::max() MEANS: LAST CHARACTER ON THE LINE
  */
 Vec2f TextBox::getLocationAt(int line, int index)
 {
     int start = wrapper.offsets[line];
     int end = start + wrapper.lengths[line];
     
     if (index == numeric_limits<int>::min())
     {
         index = start;
     }
     else if (index == numeric_limits<int>::max())
     {
         index = end;
     }
     
     float xx = x + paddingLeft + getOffsetX(start, end) + font->getSubStringAdvance(text, start, index);
     float yy = y + paddingTop + getOffsetY() + line * lineHeight;
     
     return Vec2f(xx, yy);
 }
コード例 #12
0
ファイル: ShadowInset.cpp プロジェクト: cubicool/osgpango
bool GlyphLayerShadowInset::render(
	cairo_t*       c,
	cairo_glyph_t* glyph,
	unsigned int   width,
	unsigned int   height
) {
	if(cairo_status(c) || !glyph) return false;
	
	cairo_push_group(c);
	cairo_glyph_path(c, glyph, 1);
	cairo_clip(c);
	cairo_translate(c, getOffsetX(), getOffsetY());
	// cairo_set_line_join(c, CAIRO_LINE_JOIN_ROUND);
	cairo_set_line_width(c, static_cast<double>(_radius) - 0.5f);
	cairo_glyph_path(c, glyph, 1);
	cairo_stroke(c);
	
	cairo_pattern_t* pattern = cairo_pop_group(c);
	cairo_surface_t* tmp     = createBlurredSurface(CAIRO_FORMAT_A8, pattern, width, height);

	cairo_set_source_surface(
		c,
		tmp,
		-static_cast<double>(_getBlurSize()) * 2,
		-static_cast<double>(_getBlurSize()) * 2
	);

	cairo_glyph_path(c, glyph, 1);
	cairo_clip(c);
	cairo_paint(c);

	cairo_surface_destroy(tmp);
	cairo_pattern_destroy(pattern);
	
	return true;
}
コード例 #13
0
ファイル: CameraSystem.cpp プロジェクト: chling/artemis
float CameraSystem::getEndX() const
{
	return _lookAtX + getOffsetX();
}
コード例 #14
0
ファイル: CameraSystem.cpp プロジェクト: chling/artemis
float CameraSystem::getStartX() const
{
	return _lookAtX - getOffsetX();
}
コード例 #15
0
ファイル: Plane.cpp プロジェクト: JRasay89/TappyPlane
/*
 * This method takes in a graphics and image objects to be used into
 * drawing the plane sprite onto the screen
 *
 * @param graphics is used for drawing the plane sprite
 * @param image is the sprite sheet where the plane sprite is retrieve from
 */
void Plane::draw(Graphics* graphics, Image* image)
{
    image->draw(getOffsetX(), getOffsetY(), SOURCE_SPRITE_OFFSET_X[color_][frameCounter_], SOURCE_SPRITE_OFFSET_Y[color_][frameCounter_], getSourceWidth(), getSourceHeight(), graphics);
    puffCloud_.draw(graphics, image);
}
コード例 #16
0
ファイル: qg_graphicview.cpp プロジェクト: LibreCAD/LibreCAD
/**
 * Called whenever the graphic view has changed.
 * Adjusts the scrollbar ranges / steps.
 */
void QG_GraphicView::adjustOffsetControls()
{
    if (scrollbars)
    {
        static bool running = false;

        if (running) {
                return;
        }

        running = true;

        if (container==NULL || hScrollBar==NULL || vScrollBar==NULL) {
            return;
        }

        int ox = getOffsetX();
        int oy = getOffsetY();

        RS_Vector min = container->getMin();
        RS_Vector max = container->getMax();

        // no drawing yet - still allow to scroll
        if (max.x < min.x+1.0e-6 ||
                max.y < min.y+1.0e-6 ||
                    max.x > RS_MAXDOUBLE ||
                    max.x < RS_MINDOUBLE ||
                    min.x > RS_MAXDOUBLE ||
                    min.x < RS_MINDOUBLE ||
                    max.y > RS_MAXDOUBLE ||
                    max.y < RS_MINDOUBLE ||
                    min.y > RS_MAXDOUBLE ||
                    min.y < RS_MINDOUBLE ) {
            min = RS_Vector(-10,-10);
            max = RS_Vector(100,100);
        }

        auto factor = getFactor();

        int minVal = (int)(-getWidth()*0.75
                           + std::min(min.x, 0.)*factor.x);
        int maxVal = (int)(-getWidth()*0.25
                           + std::max(max.x, 0.)*factor.x);

        if (minVal<=maxVal) {
            hScrollBar->setRange(minVal, maxVal);
        }

        minVal = (int)(+getHeight()*0.25
                       - std::max(max.y, 0.)*factor.y);
        maxVal = (int)(+getHeight()*0.75
                       - std::min(min.y, 0.)*factor.y);

        if (minVal<=maxVal) {
            vScrollBar->setRange(minVal, maxVal);
        }

        hScrollBar->setPageStep(getWidth());
        vScrollBar->setPageStep(getHeight());

        hScrollBar->setValue(-ox);
        vScrollBar->setValue(oy);


        slotHScrolled(-ox);
        slotVScrolled(oy);


//        RS_DEBUG->print("H min: %d / max: %d / step: %d / value: %d\n",
//                        hScrollBar->minimum(), hScrollBar->maximum(),
//                        hScrollBar->pageStep(), ox);

//        RS_DEBUG->print(/*RS_Debug::D_WARNING, */"V min: %d / max: %d / step: %d / value: %d\n",
//                        vScrollBar->minimum(), vScrollBar->maximum(),
//                        vScrollBar->pageStep(), oy);


        running = false;
    }
}
コード例 #17
0
ファイル: Ground.cpp プロジェクト: JRasay89/TappyPlane
void Ground::draw(Graphics* graphics, Image* image)
{

    image->draw(getOffsetX(), getOffsetY(), SOURCE_SPRITE_OFFSET_X[type_], SOURCE_SPRITE_OFFSET_Y[type_], getSourceWidth(), getSourceHeight(), graphics);
    image->draw((getOffsetX() + GROUND_WIDTH), getOffsetY(), SOURCE_SPRITE_OFFSET_X[type_], SOURCE_SPRITE_OFFSET_Y[type_], getSourceWidth(), getSourceHeight(), graphics);
}
コード例 #18
0
ファイル: wyScrollableLayer.cpp プロジェクト: Adoni/WiEngine
float wyScrollableLayer::getContainerPositionXPercent() {
	return getOffsetX() / m_xExtent;
}
コード例 #19
0
ファイル: Background.cpp プロジェクト: JRasay89/TappyPlane
void Background::draw(Graphics* graphics, Image* image)
{
    image->draw(getOffsetX(), getOffsetY(), SOURCE_SPRITE_OFFSET_X, SOURCE_SPRITE_OFFSET_Y, getSourceWidth(), getSourceHeight(), graphics);
}
コード例 #20
0
/**
 * Called whenever the graphic view has changed.
 * Adjusts the scrollbar ranges / steps.
 */
void QG_GraphicView::adjustOffsetControls() {
        static bool running = false;

        if (running) {
                return;
        }

        running = true;

    RS_DEBUG->print("QG_GraphicView::adjustOffsetControls() begin");

    if (container==NULL || hScrollBar==NULL || vScrollBar==NULL) {
        return;
    }

    int ox = getOffsetX();
    int oy = getOffsetY();

    RS_Vector min = container->getMin();
    RS_Vector max = container->getMax();

    // no drawing yet - still allow to scroll
    if (max.x < min.x+1.0e-6 ||
            max.y < min.y+1.0e-6 ||
                max.x > RS_MAXDOUBLE ||
                max.x < RS_MINDOUBLE ||
                min.x > RS_MAXDOUBLE ||
                min.x < RS_MINDOUBLE ||
                max.y > RS_MAXDOUBLE ||
                max.y < RS_MINDOUBLE ||
                min.y > RS_MAXDOUBLE ||
                min.y < RS_MINDOUBLE ) {
        min = RS_Vector(-10,-10);
        max = RS_Vector(100,100);
    }

        int minVal = (int)(-ox-toGuiDX(getWidth())*0.5
                        - QG_SCROLLMARGIN - getBorderLeft());
        int maxVal = (int)(-ox+toGuiDX(getWidth())*0.5
                        + QG_SCROLLMARGIN + getBorderRight());

        hScrollBar->setValue(0);
        if (minVal<=maxVal) {
                hScrollBar->setRange(minVal, maxVal);
        }
    //hScrollBar->setMinValue(minVal);

        //hScrollBar->setMaxValue(maxVal);

        minVal = (int)(oy-toGuiDY(getHeight())*0.5
                        - QG_SCROLLMARGIN - getBorderTop());
        maxVal = (int)(oy+toGuiDY(getHeight())*0.5
                       +QG_SCROLLMARGIN + getBorderBottom());

        if (minVal<=maxVal) {
                vScrollBar->setRange(minVal, maxVal);
        }
    //vScrollBar->setMaxValue((int)(QG_SCROLLMARGIN + getBorderBottom()
     //                             - (min.y * getFactor().y)));


    //vScrollBar->setMinValue((int)(getHeight() -
     //                             max.y * getFactor().y
     //                             - QG_SCROLLMARGIN - getBorderTop()));


    hScrollBar->setPageStep((int)(getWidth()));
    vScrollBar->setPageStep((int)(getHeight()));

    hScrollBar->setValue(-ox);
    vScrollBar->setValue(oy);


    slotHScrolled(-ox);
    slotVScrolled(oy);


    RS_DEBUG->print("H min: %d / max: %d / step: %d / value: %d\n",
                    hScrollBar->minimum(), hScrollBar->maximum(),
                    hScrollBar->pageStep(), ox);
//    DEBUG_HEADER();
    RS_DEBUG->print(/*RS_Debug::D_WARNING, */"V min: %d / max: %d / step: %d / value: %d\n",
                    vScrollBar->minimum(), vScrollBar->maximum(),
                    vScrollBar->pageStep(), oy);

    RS_DEBUG->print("QG_GraphicView::adjustOffsetControls() end");

        running = false;
}
コード例 #21
0
ファイル: LuaDrawable.cpp プロジェクト: leafnsand/only2d
	int32_t LuaDrawable::getOffsetX(lua_State *L)
	{
		auto drawable = Lua::getObject<Drawable>(L, 1, LuaType::Drawable);
		Lua::pushNumber(L, drawable->getOffsetX());
		return 1;
	}