示例#1
0
void updatePositions()
{
	oldPaddle = paddle;
	oldBall = ball;

	if (KEY_DOWN_NOW(BUTTON_RIGHT))
	{
		paddle.x = min(paddle.x + PADDLE_SPEED, GAME_WIDTH - PADDLE_WIDTH);

		if (ball.onPaddle)
			ball.x = paddle.x + PADDLE_WIDTH / 2;
	}

	if (KEY_DOWN_NOW(BUTTON_LEFT))
	{
		paddle.x = max(paddle.x - PADDLE_SPEED, 0);

		if (ball.onPaddle)
			ball.x = paddle.x + PADDLE_WIDTH / 2;
	}

	//release ball from paddle
	if (ball.onPaddle && KEY_DOWN_NOW(BUTTON_A))
	{
		ball.onPaddle = FALSE;
		ball.xspeed = 1;
		ball.yspeed = -3;

		ball.y -= 1; //give it one pixel of space so it doesn't "collide" with paddle right away
	}

	//--------------------------CHECK FOR COLLISIONS-------------------------------//

	//check collision with right boundary
	if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, GAME_WIDTH, 0, GAME_WIDTH + 10, GAME_HEIGHT))
	{
		ball.xspeed = -ball.xspeed;
		ball.x -= 2;
	}

	//check collision with top boundary
	if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, 0, -10, GAME_WIDTH, 0))
	{
		ball.yspeed = -ball.yspeed;
		ball.y += 2;
	}

	//check collision with left boundary
	if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, -10, 0, 0, GAME_HEIGHT))
	{
		ball.xspeed = -ball.xspeed;
		ball.x += 2;
	}

	//check collision with bricks
	for (int i = 0; i < NUM_OF_BRICKS; i++)
	{
		if (brickArray[i].health && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, brickArray[i].x, brickArray[i].y,
			brickArray[i].x + BRICK_WIDTH, brickArray[i].y + BRICK_HEIGHT))
		{
			int ballxmid = ball.x + BALL_SIZE/2;
			int ballymid = ball.y + BALL_SIZE/2;
			int brickxmid = brickArray[i].x + BRICK_WIDTH/2;
			int brickymid = brickArray[i].y + BRICK_HEIGHT/2;

			//slope of the vector pointing from the ball to the brick
			int deltax = brickxmid - ballxmid;
			int deltay = brickymid - ballymid;

			//below or above brick
			if (abs(deltax) < 2 * abs(deltay) + 2) // abs(dy/dx) > 1/2 			(visual->)  \_____/
			{
				ball.yspeed = -ball.yspeed;
				ball.y += signOf(ball.yspeed) * 2; //"push it out of brick just a bit"
			}
			//side of brick
			else
			{
				ball.xspeed = -ball.xspeed;
				ball.x += signOf(ball.xspeed) * 2; //"push it out of brick just a bit"
			}



			brickArray[i].health -= 1;

			if (!brickArray[i].health)
			{
				//draw part of the background image that was previously hidden
				drawImageExt3(brickArray[i].x, brickArray[i].y, brickArray[i].x, brickArray[i].y, BRICK_WIDTH, BRICK_HEIGHT, gtech);
				bricksLeft --;
   				sprintf(bricksString, "%d", bricksLeft);  		//store lives as a string

   				waitForVblank();
   				drawRect(215, 85, 12, 8, RGB(6, 0, 6));
    			drawString(215, 85, bricksString, WHITE);
			}
		}
	}

	//check collision with paddle
	if (!ball.onPaddle && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, paddle.x, PADDLE_Y, paddle.x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT))
	{
		setNewBallSpeed();
	}

	//check for death
	if (ball.y > GAME_HEIGHT)
	{
		lives--;
		sprintf(livesString, "%d", lives);  		//store lives as a string

		//draw new lives number
		waitForVblank();
		drawRect(215, 35, 6, 8, RGB(6, 0, 6));
    	drawString(215, 35, livesString, WHITE);

		setBallOnPaddle();
	}

	ball.x += ball.xspeed;
	ball.y += ball.yspeed;
}
示例#2
0
文件: WPainter.C 项目: nkabir/wt
void WPainter::drawRect(const WRectF& rectangle)
{
    drawRect(rectangle.x(), rectangle.y(), rectangle.width(), rectangle.height());
}
示例#3
0
文件: WPainter.C 项目: nkabir/wt
void WPainter::drawRects(const std::vector<WRectF>& rectangles)
{
    for (unsigned i = 0; i < rectangles.size(); ++i)
        drawRect(rectangles[i]);
}
示例#4
0
void AxisBase::drawAxisData(QPainter &p)
{
    PlotterBase *plotter = (PlotterBase*)parent();
    QRect rect(plotter->contentsRect());

    double start = m_min;
    double end = m_max;

    int p_start, p_end;
    calculatePoints(p_start, p_end);

    switch (m_orient)
    {
        case Qt::Vertical:
        {
            p.setPen(m_pen);
            p.drawLine(m_offset+2, p_start, m_offset+2, p_end);

            if (m_minor > 1e-100)
            {
                int prevTick = INT_MAX/2;

                for (double i = start; i <= end; i += m_minor)
                {
                    int p_d = toView(i);

                    if (p_d < prevTick-1)
                    {
                        prevTick = p_d;
                        p.setPen(m_minorPen);
                        p.drawLine(m_offset+1, p_d, m_offset+3, p_d);

                        if (m_minorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_minorGridPen);
                            p.drawLine(m_offset+2, p_d, rect.right(), p_d);
                        }
                    }
                }
            }

            if (m_major > 1e-100)
            {
                QRect prevRect;
                int prevTick = INT_MAX/2;

                for (double i = start; i <= end; i += m_major)
                {
                    int p_d = toView(i);

                    if (p_d < prevTick-1)
                    {
                        prevTick = p_d;
                        p.setPen(m_majorPen);
                        p.drawLine(m_offset+0, p_d, m_offset+4, p_d);

                        if (m_majorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_majorGridPen);
                            p.drawLine(m_offset+2, p_d, rect.right(), p_d);
                        }
                    }

                    QString text(QString::number(i));
                    QFontMetrics fm(m_font);
                    QRect textRect(fm.boundingRect(text));

                    int h = textRect.height();
                    QRect drawRect(0, p_d - h/2, m_offset, h);

                    // skip paining the text
                    if (prevRect.isValid() && prevRect.intersects(drawRect))
                        continue;
                    prevRect = drawRect;

                    p.setPen(QPen(m_textColor));
                    p.drawText(drawRect, Qt::AlignRight | Qt::AlignVCenter, text);
                }
            }

            break;
        }

        case Qt::Horizontal:
        {
            p.setPen(m_pen);
            p.drawLine(p_start, rect.height()-m_offset, p_end, rect.height()-m_offset);

            if (m_minor > 1e-100)
            {
                int prevTick = -INT_MAX;

                for (double i = start; i <= end; i += m_minor)
                {
                    int p_d = toView(i);

                    if (p_d > prevTick+1)
                    {
                        prevTick = p_d;
                        p.setPen(m_minorPen);
                        p.drawLine(p_d, rect.height()-m_offset+1, p_d, rect.height()-m_offset+3);

                        if (m_minorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_minorGridPen);
                            p.drawLine(p_d, rect.top(), p_d, rect.height()-m_offset);
                        }
                    }
                }
            }

            if (m_major > 1e-100)
            {
                QRect prevRect;
                int prevTick = -INT_MAX;

                for (double i = start; i <= end; i += m_major)
                {
                    int p_d = toView(i);

                    if (p_d > prevTick+1)
                    {
                        prevTick = p_d;
                        p.setPen(m_majorPen);
                        p.drawLine(p_d, rect.height()-m_offset+0, p_d, rect.height()-m_offset+4);

                        if (m_majorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_majorGridPen);
                            p.drawLine(p_d, rect.top(), p_d, rect.height()-m_offset);
                        }
                    }

                    QString text(QString::number(i));
                    QFontMetrics fm(m_font);
                    QRect textRect(fm.boundingRect(text));

                    int w = textRect.width();
                    QRect drawRect(p_d - w/2, rect.height()-m_offset+3, w, m_offset);

                    // skip paining the text
                    if (prevRect.isValid() && prevRect.intersects(drawRect))
                        continue;
                    prevRect = drawRect;

                    p.setPen(QPen(m_textColor));
                    p.drawText(drawRect, Qt::AlignCenter, text);
                }
            }

            break;

        }
    }
}
// ---------------------------------------------------------------------------
// CMMACameraWindow::DrawViewFinderError()
// Draws the error message to specified area.
// Used in cases when viewfinder is unable to start.
// ---------------------------------------------------------------------------
//
void CMMACameraWindow::DrawViewFinderErrorL(
    const TInt /*aError*/,
    const TRect& aDrawRect)
{

    ASSERT(iDirectAccess);
    TInt dcError = KErrNone;
    if (!iDirectAccess->IsActive())
    {
        TRAP(dcError, iDirectAccess->StartL());
    }

    TRect drawRect(aDrawRect);

    if (dcError == KErrNone)
    {
        drawRect.Intersection(iClientRect);
        drawRect.Move(-iWindow->AbsPosition());

        CFbsBitGc* directGc = iDirectAccess->Gc();
        directGc->SetClippingRect(drawRect);
        directGc->SetBrushColor(TRgb(128,128,128));
        directGc->SetPenColor(TRgb(128,0,0));
        directGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
        directGc->SetPenStyle(CGraphicsContext::ESolidPen);
        directGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
        directGc->DrawRect(drawRect);

        if (!iErrorIconBitmap || !iErrorIconMaskBitmap)
        {
            if (iErrorIconBitmap)
            {
                delete iErrorIconBitmap;
                iErrorIconBitmap = NULL;
            }

            if (iErrorIconMaskBitmap)
            {
                delete iErrorIconMaskBitmap;
                iErrorIconMaskBitmap = NULL;
            }
            /*
                        AknsUtils::CreateIconL(
                            AknsUtils::SkinInstance(),
                            KAknsIIDQgnIndiCam4Camera,
                            iErrorIconBitmap,
                            iErrorIconMaskBitmap,
                            KCameraAppBitmapFile,
                            EMbmCameraappQgn_indi_cam4_camera,
                            EMbmCameraappQgn_indi_cam4_camera_mask
                        );
                        */
        }

        //TRect iconRect
        drawRect.iTl.iX += KErrorIconMargin;
        drawRect.iTl.iY += KErrorIconMargin;
        drawRect.iBr.iX -= KErrorIconMargin;
        drawRect.iBr.iY -= KErrorIconMargin;

        if (iErrorIconBitmap->SizeInPixels() != drawRect.Size())
        {
            AknIconUtils::SetSize(iErrorIconBitmap, drawRect.Size());
            AknIconUtils::SetSize(iErrorIconMaskBitmap, drawRect.Size());
        }

        directGc->BitBltMasked(
            drawRect.iTl, iErrorIconBitmap,
            TRect(iErrorIconBitmap->SizeInPixels()),
            iErrorIconMaskBitmap, EFalse);

        iDirectAccess->ScreenDevice()->Update();
    }

}
示例#6
0
namespace SkRecords {

// FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads.
static SkBitmap shallow_copy(const SkBitmap& bitmap) {
    return bitmap;
}

// NoOps draw nothing.
template <> void Draw::draw(const NoOp&) {}

#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
DRAW(Restore, restore());
DRAW(Save, save());
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(PopCull, popCull());
DRAW(PushCull, pushCull(r.rect));
DRAW(Clear, clear(r.color));
DRAW(Concat, concat(r.matrix));
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));

DRAW(ClipPath, clipPath(r.path, r.op, r.doAA));
DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA));
DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA));
DRAW(ClipRegion, clipRegion(r.region, r.op));

DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint));
DRAW(DrawBitmapRectToRect,
        drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
DRAW(DrawPath, drawPath(r.path, r.paint));
DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode.get(), r.paint));
DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint));
DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint));
DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint));
DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint));
DRAW(DrawRRect, drawRRect(r.rrect, r.paint));
DRAW(DrawRect, drawRect(r.rect, r.paint));
DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint));
DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint));
DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
                                r.xmode.get(), r.indices, r.indexCount, r.paint));
#undef DRAW


// This is an SkRecord visitor that fills an SkBBoxHierarchy.
//
// The interesting part here is how to calculate bounds for ops which don't
// have intrinsic bounds.  What is the bounds of a Save or a Translate?
//
// We answer this by thinking about a particular definition of bounds: if I
// don't execute this op, pixels in this rectangle might draw incorrectly.  So
// the bounds of a Save, a Translate, a Restore, etc. are the union of the
// bounds of Draw* ops that they might have an effect on.  For any given
// Save/Restore block, the bounds of the Save, the Restore, and any other
// non-drawing ("control") ops inside are exactly the union of the bounds of
// the drawing ops inside that block.
//
// To implement this, we keep a stack of active Save blocks.  As we consume ops
// inside the Save/Restore block, drawing ops are unioned with the bounds of
// the block, and control ops are stashed away for later.  When we finish the
// block with a Restore, our bounds are complete, and we go back and fill them
// in for all the control ops we stashed away.
class FillBounds : SkNoncopyable {
public:
    FillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) : fBounds(record.count()) {
        // Calculate bounds for all ops.  This won't go quite in order, so we'll need
        // to store the bounds separately then feed them in to the BBH later in order.
        fCTM.setIdentity();
        for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) {
            record.visit<void>(fCurrentOp, *this);
        }

        // If we have any lingering unpaired Saves, simulate restores to make
        // sure all ops in those Save blocks have their bounds calculated.
        while (!fSaveStack.isEmpty()) {
            this->popSaveBlock();
        }

        // Any control ops not part of any Save/Restore block draw everywhere.
        while (!fControlIndices.isEmpty()) {
            this->popControl(SkIRect::MakeLargest());
        }

        // Finally feed all stored bounds into the BBH.  They'll be returned in this order.
        SkASSERT(NULL != bbh);
        for (uintptr_t i = 0; i < record.count(); i++) {
            if (!fBounds[i].isEmpty()) {
                bbh->insert((void*)i, fBounds[i], true/*ok to defer*/);
            }
        }
        bbh->flushDeferredInserts();
    }

    template <typename T> void operator()(const T& r) {
        this->updateCTM(r);
        this->trackBounds(r);
    }

private:
    struct SaveBounds {
        int controlOps;  // Number of control ops in this Save block, including the Save.
        SkIRect bounds;  // Bounds of everything in the block.
    };

    template <typename T> void updateCTM(const T&) { /* most ops don't change the CTM */ }
    void updateCTM(const Restore& r)   { fCTM = r.matrix; }
    void updateCTM(const SetMatrix& r) { fCTM = r.matrix; }
    void updateCTM(const Concat& r)    { fCTM.preConcat(r.matrix); }

    // The bounds of these ops must be calculated when we hit the Restore
    // from the bounds of the ops in the same Save block.
    void trackBounds(const Save&)       { this->pushSaveBlock(); }
    // TODO: bounds of SaveLayer may be more complicated?
    void trackBounds(const SaveLayer&)  { this->pushSaveBlock(); }
    void trackBounds(const Restore&)    { fBounds[fCurrentOp] = this->popSaveBlock(); }

    void trackBounds(const Concat&)     { this->pushControl(); }
    void trackBounds(const SetMatrix&)  { this->pushControl(); }
    void trackBounds(const ClipRect&)   { this->pushControl(); }
    void trackBounds(const ClipRRect&)  { this->pushControl(); }
    void trackBounds(const ClipPath&)   { this->pushControl(); }
    void trackBounds(const ClipRegion&) { this->pushControl(); }

    // For all other ops, we can calculate and store the bounds directly now.
    template <typename T> void trackBounds(const T& op) {
        fBounds[fCurrentOp] = this->bounds(op);
        this->updateSaveBounds(fBounds[fCurrentOp]);
    }

    // TODO: remove this trivially-safe default when done bounding all ops
    template <typename T> SkIRect bounds(const T&) { return SkIRect::MakeLargest(); }

    void pushSaveBlock() {
        // Starting a new Save block.  Push a new entry to represent that.
        SaveBounds sb = { 0, SkIRect::MakeEmpty() };
        fSaveStack.push(sb);
        this->pushControl();
    }

    SkIRect popSaveBlock() {
        // We're done the Save block.  Apply the block's bounds to all control ops inside it.
        SaveBounds sb;
        fSaveStack.pop(&sb);
        while (sb.controlOps --> 0) {
            this->popControl(sb.bounds);
        }

        // This whole Save block may be part another Save block.
        this->updateSaveBounds(sb.bounds);

        // If called from a real Restore (not a phony one for balance), it'll need the bounds.
        return sb.bounds;
    }

    void pushControl() {
        fControlIndices.push(fCurrentOp);
        if (!fSaveStack.isEmpty()) {
            fSaveStack.top().controlOps++;
        }
    }

    void popControl(const SkIRect& bounds) {
        fBounds[fControlIndices.top()] = bounds;
        fControlIndices.pop();
    }

    void updateSaveBounds(const SkIRect& bounds) {
        // If we're in a Save block, expand its bounds to cover these bounds too.
        if (!fSaveStack.isEmpty()) {
            fSaveStack.top().bounds.join(bounds);
        }
    }

    SkIRect bounds(const NoOp&) { return SkIRect::MakeEmpty(); }  // NoOps don't draw anywhere.

    SkAutoTMalloc<SkIRect> fBounds;  // One for each op in the record.
    SkMatrix fCTM;
    unsigned fCurrentOp;
    SkTDArray<SaveBounds> fSaveStack;
    SkTDArray<unsigned>   fControlIndices;
};

}  // namespace SkRecords
示例#7
0
void MainMenu::render()
{

	if (introMovie)
	{
		introMovie->render();
		return;
	}
	if ( bDrawMechlopedia && (fadeTime > fadeOutTime || !fadeOutTime) )
	{
		mechlopedia->render();
		return;
	}

	
	if ( bOptions )
	{
		optionsScreenWrapper->render();
		return;
	}

	//DO NOT play the splash screen animation in software.
	// WOW does it beat up the framerate!
	float xDelta = 0.f;
	float yDelta = 0.f;  
	long color = 0xff000000;

	if (Environment.Renderer != 3)
	{

		if ( beginAnim.isAnimating() && !beginAnim.isDone() )
		{
			xDelta = beginAnim.getXDelta();
			yDelta = beginAnim.getYDelta();

			float time = beginAnim.getCurrentTime();
			float endTime = beginAnim.getMaxTime();
			if ( endTime )
			{
				color = interpolateColor( 0x00000000, 0x7f000000, time/endTime );

			}
		}

		else if (endAnim.isAnimating() /*&& !endAnim.isDone()*/)
		{
			xDelta = endAnim.getXDelta();
			yDelta = endAnim.getYDelta();

			float time = endAnim.getCurrentTime();
			float endTime = endAnim.getMaxTime();
			if ( endTime && (time <= endTime))
			{
				color = interpolateColor( 0x7f000000, 0x00000000, time/endTime );
			}
		}

		GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
		drawRect( rect, color );

		if ( bDrawBackground )
		{
			background.render();
			intro.render();
			if ( !intro.animObjects[0].isDone() && !introOver && !bHostLeftDlg )
				return;


		}
	}
	else
	{
		GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
		drawRect( rect, color );
	}

	if ( !xDelta && !yDelta )
	{
		drawShadowText( 0xffc66600, 0xff000000, textObjects[1].font.getTempHandle(), 
			textObjects[1].globalX(), textObjects[1].globalTop(),
			textObjects[1].globalRight(), textObjects[1].globalBottom(),
			true, textObjects[1].text, false, textObjects[1].font.getSize(), 1, 1 );
	}

	textObjects[1].showGUIWindow( false );

	
	if ( (!bSave && !bLoad && !bLoadSingle && !bLoadCampaign) || (!endAnim.isDone() && endResult != RESTART ) )	
		LogisticsScreen::render( xDelta, yDelta );
	else if ( bLoadSingle )
		singleLoadDlg.render();
	else
		LogisticsSaveDialog::instance()->render();
 
	if ( promptToQuit || promptToDisconnect )
	{
		LogisticsOKDialog::instance()->render();
	}
	if ( bLegal )
	{
		LogisticsLegalDialog::instance()->render();
	}
	if ( bHostLeftDlg )
	{
		LogisticsOneButtonDialog::instance()->render();
	}



	
}
/**
 * Draws the button with the specified arrow shape.
 */
void ArrowButton::draw()
{
	Surface::draw();
	lock();

	// Draw button
	SDL_Rect square;
	int color = _color + 2;

	square.x = 0;
	square.y = 0;
	square.w = getWidth() - 1;
	square.h = getHeight() - 1;

	drawRect(&square, color);

	square.x++;
	square.y++;
	color = _color + 5;

	drawRect(&square, color);

	square.w--;
	square.h--;
	color = _color + 4;

	drawRect(&square, color);

	setPixel(0, 0, _color + 1);
	setPixel(0, getHeight() - 1, _color + 4);
	setPixel(getWidth() - 1, 0, _color + 4);

	color = _color + 1;

	if (_shape == ARROW_BIG_UP)
	{
		// Draw arrow square
		square.x = 5;
		square.y = 8;
		square.w = 3;
		square.h = 3;

		drawRect(&square, color);

		// Draw arrow triangle
		square.x = 2;
		square.y = 7;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color);
			square.x++;
			square.y--;
		}
		drawRect(&square, color);
	}
	else if (_shape == ARROW_BIG_DOWN)
	{
		// Draw arrow square
		square.x = 5;
		square.y = 3;
		square.w = 3;
		square.h = 3;

		drawRect(&square, color);

		// Draw arrow triangle
		square.x = 2;
		square.y = 6;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color);
			square.x++;
			square.y++;
		}
		drawRect(&square, color);
	}
	else if (_shape == ARROW_SMALL_UP)
	{
		// Draw arrow triangle 1
		square.x = 1;
		square.y = 5;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color + 2);
			square.x++;
			square.y--;
		}
		drawRect(&square, color + 2);

		// Draw arrow triangle 2
		square.x = 2;
		square.y = 5;
		square.w = 7;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color);
			square.x++;
			square.y--;
		}
		drawRect(&square, color);
	}
	else if (_shape == ARROW_SMALL_DOWN)
	{
		// Draw arrow triangle 1
		square.x = 1;
		square.y = 2;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color + 2);
			square.x++;
			square.y++;
		}
		drawRect(&square, color + 2);

		// Draw arrow triangle 2
		square.x = 2;
		square.y = 2;
		square.w = 7;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color);
			square.x++;
			square.y++;
		}
		drawRect(&square, color);
	}
	else if (_shape == ARROW_SMALL_LEFT)
	{
		// Draw arrow triangle 1
		square.x = 2;
		square.y = 4;
		square.w = 2;
		square.h = 1;

		for (; square.h < 5; square.h += 2)
		{
			drawRect(&square, color + 2);
			square.x += 2;
			square.y--;
		}
		square.w = 1;
		drawRect(&square, color + 2);

		// Draw arrow triangle 2
		square.x = 3;
		square.y = 4;
		square.w = 2;
		square.h = 1;

		for (; square.h < 5; square.h += 2)
		{
			drawRect(&square, color);
			square.x += 2;
			square.y--;
		}
		square.w = 1;
		drawRect(&square, color);
	}
	else if (_shape == ARROW_SMALL_RIGHT)
	{
		// Draw arrow triangle 1
		square.x = 7;
		square.y = 4;
		square.w = 2;
		square.h = 1;

		for (; square.h < 5; square.h += 2)
		{
			drawRect(&square, color + 2);
			square.x -= 2;
			square.y--;
		}
		square.x++;
		square.w = 1;
		drawRect(&square, color + 2);

		// Draw arrow triangle 2
		square.x = 6;
		square.y = 4;
		square.w = 2;
		square.h = 1;

		for (; square.h < 5; square.h += 2)
		{
			drawRect(&square, color);
			square.x -= 2;
			square.y--;
		}
		square.x++;
		square.w = 1;
		drawRect(&square, color);
	}

	unlock();
}
void BSpline::addControlPoint(const Point point)
{
	_controlPoints.push_back(point);
	drawRect(point, 10);
}
void drawRect(rec2vector p1, rec2vector p2, COLORREF c)
{
   drawRect(p1.x, p1.y, p2.x, p2.y, c);
}
示例#11
0
// main function
int main(void) {
	
	REG_DISPCTL = MODE3 | BG2_ENABLE; // REG_DISPCTL = 1027/0x0403
	
	drawRect(0, 0, 240, 160, RGB(31, 31, 31)); //color1: white; drawRect

	while (1) {
		// draw UGLY GOOGLE

		// draw "G"
		drawRect(50, 40, 5, 5, RGB(0, 0, 31)); // color2: blue
		drawRect(45, 35, 5, 5, RGB(0, 0, 31));
		drawRect(40, 20, 15, 5, RGB(0, 0, 31));
		drawRect(45, 15, 5, 5, RGB(0, 0, 31));
		drawRect(50, 10, 5, 5, RGB(0, 0, 31));
		drawRect(55, 5, 5, 30, RGB(0, 0, 31));
		drawRect(85, 10, 5, 5, RGB(0, 0, 31));
		drawRect(90, 15, 5, 5, RGB(0, 0, 31));
		drawRect(95, 20, 15, 5, RGB(0, 0, 31));
		drawRect(90, 35, 5, 5, RGB(0, 0, 31));
		drawRect(80, 40, 5, 15, RGB(0, 0, 31));
		drawRect(75, 30, 20, 5, RGB(0, 0, 31));

		// draw "OO"
		drawHollowRect(65, 55, 30, 35, RGB(31, 0, 0)); // color3: red; drawHollowRect
		drawHollowRect(65, 90, 30, 35, RGB(31, 21, 0)); // color4: orange

		// draw 'g'
		drawHollowRect(65, 125, 20, 20, RGB(0, 0, 31));
		setPixel(64, 145, RGB(0, 0, 31)); // setPixel
		setPixel(64, 146, RGB(0, 0, 31));
		setPixel(64, 147, RGB(0, 0, 31));
		setPixel(63, 148, RGB(0, 0, 31));
		plotLine(145, 85, 150, 100, RGB(0, 0, 31)); // plotLine
		drawHollowRect(90, 125, 26, 15, RGB(0, 0, 31));

		// draw 'l'
		drawRect(40, 160, 5, 60, RGB(0, 31, 0)); // color5: green

		// draw 'e'
		drawRect(80, 180, 25, 5, RGB(31, 0, 0));
		drawRect(75, 200, 5, 5, RGB(31, 0, 0));
		drawRect(70, 195, 5, 5, RGB(31, 0, 0));
		drawRect(65, 190, 5, 5, RGB(31, 0, 0));
		drawRect(70, 185, 5, 5, RGB(31, 0, 0));
		drawRect(75, 180, 5, 5, RGB(31, 0, 0));
		drawRect(85, 180, 5, 15, RGB(31, 0, 0));
		drawRect(95, 185, 20, 5, RGB(31, 0, 0));
	}
}
示例#12
0
/**
 * Draws the minimap.
 */
void MiniMapView::draw()
{
	int _startX = _camera->getCenterPosition().x - ((getWidth() / CELL_WIDTH) / 2);
	int _startY = _camera->getCenterPosition().y - ((getHeight() / CELL_HEIGHT) / 2);

	InteractiveSurface::draw();
	if(!_set)
	{
		return;
	}
	SDL_Rect current;
	current.x = current.y = 0;
	current.w = getWidth ();
	current.h = getHeight ();
	drawRect(&current, 0);
	this->lock();
	for (int lvl = 0; lvl <= _camera->getCenterPosition().z; lvl++)
	{
		int py = _startY;
		for (int y = Surface::getY(); y < getHeight () + Surface::getY(); y += CELL_HEIGHT)
		{
			int px = _startX;
			for (int x = Surface::getX(); x < getWidth () + Surface::getX(); x += CELL_WIDTH)
			{
				MapData * data = 0;
				Tile * t = 0;
				Position p (px, py, lvl);
				t = _battleGame->getTile(p);
				if (!t)
				{
					px++;
					continue;
				}
				int tileShade = 16;
				if (t->isDiscovered(2))
				{
					tileShade = t->getShade();
				}
				for(int i = 0; i < 4; i++)
				{
					data = t->getMapData(i);

					Surface * s = 0;
					if(data && data->getMiniMapIndex())
					{
						s = _set->getFrame (data->getMiniMapIndex()+35);
					}
					if(s)
					{
						s->blitNShade(this, x, y, tileShade);
					}
				}
				// alive units
				if (t->getUnit() && t->getUnit()->getVisible())
				{
					int frame = t->getUnit()->getMiniMapSpriteIndex();
					int size = t->getUnit()->getArmor()->getSize();
					frame += (t->getPosition().y - t->getUnit()->getPosition().y) * size;
					frame += t->getPosition().x - t->getUnit()->getPosition().x;
					frame += _frame * size * size;
					Surface * s = _set->getFrame(frame);
					s->blitNShade(this, x, y, 0);
				}
				// perhaps (at least one) item on this tile?
				if (t->isDiscovered(2) && !t->getInventory()->empty())
				{
					int frame = 9 + _frame;
					Surface * s = _set->getFrame(frame);
					s->blitNShade(this, x, y, 0);
				}

				px++;
			}
			py++;
		}
	}
	this->unlock();
	int centerX = getWidth() / 2 - 1;
	int centerY = getHeight() / 2 - 1;
	Uint8 color = 1 + _frame * 3;
	int xOffset = CELL_WIDTH / 2;
	int yOffset = CELL_HEIGHT / 2;
	drawLine(centerX - CELL_WIDTH, centerY - CELL_HEIGHT,
		 centerX - xOffset, centerY - yOffset,
		 color); // top left
	drawLine(centerX + xOffset, centerY - yOffset,
		 centerX + CELL_WIDTH, centerY - CELL_HEIGHT,
		 color); // top right
	drawLine(centerX - CELL_WIDTH, centerY + CELL_HEIGHT,
		 centerX - xOffset, centerY + yOffset,
		 color); // bottom left
	drawLine(centerX + CELL_WIDTH, centerY + CELL_HEIGHT,
		 centerX + xOffset, centerY + yOffset,
		 color); //bottom right
}
示例#13
0
int game(int seed)
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;
	int live = 5;
	char buffer[41];
	int speed = 1;

	int num = 100;
	int objx = 70;
	int objy = 50;

	drawPicture(black);
	
	WALL wall0;
	wall0.i = 80;
	wall0.gate = 90;
	wall0.gateSize = 10;
	wall0.color = WHITE;
	
	WALL wall1;
	wall1.i = 100;
	wall1.gate = 90;
	wall1.gateSize = 10;
	wall1.color = MAGENTA;

	WALL wall2;
	wall2.i = 120;
	wall2.gate = 30;
	wall2.gateSize = 30;
	wall2.color = RED;
	
	WALL wall3;
	wall3.i = 140;
	wall3.gate = 150;
	wall3.gateSize = 30;
	wall3.color = BLUE;

	WALL wall4;
	wall4.i = 160;
	wall4.gate = 0;
	wall4.gateSize = 20;
	wall4.color = GREEN;

	WALL wall5;
	wall5.i = 180;
	wall5.gate = 130;
	wall5.gateSize = 20;
	wall5.color = BLUE;
	
	WALL wall6;
	wall6.i = 200;
	wall6.gate = 130;
	wall6.gateSize = 15;
	wall6.color = CYAN;
	

	// Game Loop
	while(1)
	{
		
		int oldx = objx;
		int oldy = objy;
		
		drawRect(oldx,oldy,1,1, BLACK);


		if(KEY_DOWN_NOW(BUTTON_SELECT))
		{	
			
		 	objx = 70;
			objy = 50;
			live = 5;
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 0", YELLOW);

		}
		
				
		if(KEY_DOWN_NOW(BUTTON_UP))
		{
			objx-=speed;
			if(objx < 0)
			{
				objx = 0;
			}
			
		}
		if(KEY_DOWN_NOW(BUTTON_DOWN))
		{
			objx+=speed;
			if(objx > 159)
			{
				objx = 159;
			}
		
		}
		
		if(KEY_DOWN_NOW(BUTTON_A))
		{
			speed = 2;
		
		}
		if(KEY_DOWN_NOW(BUTTON_B))
		{
			speed = 1;
			
		}
		if(KEY_DOWN_NOW(BUTTON_RIGHT))
		{
			objy++;
	
		}
		if(KEY_DOWN_NOW(BUTTON_LEFT))
		{
			objy--;
			if(objy <= 0)
			{
				objy= 0;
			}
	
		}
	
		drawRect(objx,objy,1,1, RED);
		
		drawWall(wall0.i, wall0.gate, wall0.gateSize, wall0.color);
		
		if(num < 50) 
		{
			if(num <= 0)
			{
				num = 100;
			}
			
			drawWall(wall1.i, wall1.gate++, wall1.gateSize, wall1.color);
			drawWall(wall2.i, wall2.gate-=2, wall2.gateSize, wall2.color);
			drawWall(wall3.i, wall3.gate+=3, wall3.gateSize, wall3.color);
			drawWall(wall4.i, wall4.gate-=3, wall4.gateSize, wall4.color);
			drawWall(wall5.i, wall5.gate+=3, wall5.gateSize, wall5.color);
			drawWall(wall6.i, wall6.gate+=3, wall6.gateSize, wall6.color);
		}
		else 
		{
			drawWall(wall1.i, wall1.gate--, wall1.gateSize, wall1.color);
			drawWall(wall2.i, wall2.gate+=2, wall2.gateSize, wall2.color);
			drawWall(wall3.i, wall3.gate-=3, wall3.gateSize, wall3.color);
			drawWall(wall4.i, wall4.gate+=3, wall4.gateSize, wall4.color);
			drawWall(wall5.i, wall5.gate-=3, wall5.gateSize, wall5.color);
			drawWall(wall6.i, wall6.gate-=3, wall6.gateSize, wall6.color);
		}
		num--;
		
		if(objy < wall0.i)
		{
			drawString(150, 0, "Score: 0", YELLOW);
		}

		if(objy == wall0.i)
		{
			if(objx < wall0.gate || objx > wall0.gate + wall0.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);

				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			
			drawString(150, 0, "Score: 1", YELLOW);
		}
		if(objy == wall1.i)
		{
			if(objx < wall1.gate || objx > wall1.gate + wall1.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);
				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 2", YELLOW);
		}
		if(objy == wall2.i)
		{
			if(objx < wall2.gate || objx > wall2.gate + wall2.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);
				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 3", YELLOW);
		}
		if(objy == wall3.i)
		{
			if(objx < wall3.gate || objx > wall3.gate + wall3.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);
				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 4", YELLOW);
		}
		if(objy == wall4.i)
		{
			if(objx < wall4.gate || objx > wall4.gate + wall4.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);
				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 5", YELLOW);
		}
		if(objy == wall5.i)
		{
			if(objx < wall5.gate || objx > wall5.gate + wall5.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);
				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 6", YELLOW);
		}
		if(objy == wall6.i)
		{
			if(objx < wall6.gate || objx > wall6.gate + wall6.gateSize)
			{
				live--;
				objy-=10;
				drawRect(objx,objy ,1,1, RED);
				if (live == 0)
				{
					return LOSE;
				}
			}
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 7", YELLOW);
		}
		
		if(objy > wall6.i +5)
		{
			return WIN;
		}
		drawRect(5,5,60,30,BLACK);
		waitForVblank();
		drawImage3(0,0,30,30,heart);
		sprintf(buffer, " %d", live);
		drawString(10, 30, buffer, YELLOW);
		drawString(80,210, "EXIT", YELLOW);
	
		
	}

		
}
示例#14
0
int main(void)
{
    //video mode 3, activate background 2
    *REG_DISPCNT = MODE3 | BG2_ENABLE;

    paddle.x = 113;
    oldPaddle.x = 113;

    //ball starts on top of paddle
    setBallOnPaddle();

    lives = 3;
   	bricksLeft = NUM_OF_BRICKS;

   	sprintf(livesString, "%d", lives);  		//store lives as a string
   	sprintf(bricksString, "%d", bricksLeft);  	//store bricks left as a string

    drawBackground3(startscreen);
    drawString(10, 125, "Press any key", WHITE);
    drawString(10, 135, "to start", WHITE);

    while(!ANY_KEY_DOWN)
    {
    	//press key to advance
    }

    fillScreen(BLACK);

    waitForVblank();
    drawRect(GAME_WIDTH, 0, SCREEN_WIDTH - GAME_WIDTH, SCREEN_HEIGHT, RGB(6, 0, 6));

    instantiateBrickArray();

    drawString(205, 20, "Lives", WHITE);
    drawString(215, 35, livesString, WHITE);

    drawString(202, 60, "Bricks", WHITE);
    drawString(208, 70, "left", WHITE);
    drawString(215, 85, bricksString, WHITE);



    while(lives > 0 && bricksLeft > 0)
    {
    	updatePositions();
    	drawEverything();
    }

    if (bricksLeft <= 0)
    {
    	drawBackground3(win);
    }
    else
    {
    	drawBackground3(lose);
    }

    while(TRUE)
    {
    	//do nothing
    }

}
示例#15
0
void Light::paint(QPainter *p, const QRectF& boundingRect, const QPointF& mousePos, bool mouseIn, const bool isRotated) {
	if (!mouseIn && !m_animation) {
		return;
	}

	QRectF drawRect(boundingRect);

	// XXX: ugly hack because I don't know the real contents area of the FrameSvg
	drawRect.adjust(-4, -4, +4, +4);
	
	qreal  width  = drawRect.width();
	qreal  height = drawRect.height();
	qreal  size   = 0.5;
	qreal  x;
	qreal  y;
	QColor lightColor(m_item->icon()->highlightColor());

	switch (m_currentAnimation) {
	case StartupAnimation:
	case AttentionAnimation:
		x = drawRect.left() + width  * 0.5;
		y = drawRect.top()  + height * 0.5;
		size = size * 2.0 *
			(m_progress < 0.5 ? (m_progress * 0.5 + 0.5) : (1 - m_progress / 2));
		break;
	case NoAnimation:
		if (isRotated) {
			x = m_item->size().height() - mousePos.y();
			y = mousePos.x();
		}
		else {
			x = mousePos.x();
			y = mousePos.y();
		}
		// y = drawRect.top() + height * 1.10;
		width  *= 2.0;
		height *= 2.0;
		break;
	default:
		return;
	}
	
	QRadialGradient gradient(0.5, 0.5, size);
	gradient.setCoordinateMode(QRadialGradient::ObjectBoundingMode);
	
	lightColor.setAlpha(200);
	gradient.setColorAt(0.0, lightColor);
	
	lightColor.setAlpha(60);
	gradient.setColorAt(0.6, lightColor);
	
	lightColor.setAlpha(0);
	gradient.setColorAt(1.0, lightColor);
	
	p->setClipRect(drawRect);
	p->fillRect(
		x - width  * 0.5,
		y - height * 0.5,
		width, height,
		gradient);
	p->setClipping(false);
}
void BSpline::drawControlPoints(int length)
{
	for (auto it = _controlPoints.begin(); it != _controlPoints.end(); ++it)
		drawRect((*it), static_cast<float>(length));
}
示例#17
0
void alertDraw(){
	drawRect(alertTexture, 1024/2-256/2, 768/2-128/2,256,128);
	drawRect(alertSelectTexture, 1024/2-256/2, 768/2-128/2,256,128);
}
void BSpline::drawControlPoint(int index, int length)
{
	drawRect(_controlPoints[index], static_cast<float>(length));
}
示例#19
0
void Design::drawRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType) {
	drawRect(surface, rect.left, rect.top, rect.right, rect.bottom, thickness, color, patterns, fillType);
}
示例#20
0
void UIRenderer::drawRect(const aabox2f &rect, const color_t &color, Picture *picture) {
    if (!picture || picture->texture.null()) {
        return drawRect(rect, color);
    }
    drawRect(rect, color, picture->texture, picture->texcoords);
}
示例#21
0
void 
drawPath(e2dPath* path)  {
    glBindTexture(GL_TEXTURE_2D, 0);
    
    e2dPoint startPointOfSubPath;
    e2dPoint currentPoint;
    glBindTexture(GL_TEXTURE_2D, 0); 
    glColor4ub(255, 128, 128, 255);
    
    e2dPathElement* pathElem;
    e2dPathPoint* point;
    e2dPathCurve* curve;
    e2dPathElementIterator iter = e2dPathGetElementIterator(path);
    while(e2dPathElementIteratorHasNext(&iter))  {
        pathElem = e2dPathElementIteratorNext(&iter);
        switch(pathElem->type)
        {
            case(E2D_PATHPOINT):
                point = (e2dPathPoint*)pathElem;
                
                switch(pathElem->controlType)
                {
                    case(E2D_START_SUBPATH):
                        glBegin(GL_LINE_STRIP);
                        startPointOfSubPath = point->point;
                        glVertex3f(point->point.x, point->point.y, 5.0f);
                        currentPoint = point->point;
                        break;
                    case(E2D_END_SUBPATH):
                        glVertex3f(point->point.x, point->point.y, 5.0f);
                        glEnd();
                        currentPoint = point->point;
                        break;
                    case(E2D_END_SUBPATH_LOOP):
                        glVertex3f(point->point.x, point->point.y, 5.0f);
                        glVertex3f(startPointOfSubPath.x,
                                startPointOfSubPath.y,
                                2.5f);
                        
                        currentPoint = startPointOfSubPath;
                        glEnd();
                        break;
                    default:
                        glVertex3f(point->point.x, point->point.y, 5.0f);
                        currentPoint = point->point;
                        
                }
                
                break;
            case(E2D_PATHCURVE):
                curve = (e2dPathCurve*)pathElem;
                glEnd();
                drawControlPoint(curve->startPoint, curve->controlPoint1);
                drawControlPoint(curve->endPoint, curve->controlPoint2);
                glColor4ub(255, 128, 128, 255);
                glBegin(GL_LINE_STRIP);
                float t;
                for (t = 0.0f; t <= 1.0f; t += 0.05f)  {
                    float xt = 
                    powf(1.0f-t, 3.0f) * currentPoint.x + 
                    3.0f * t * powf (1.0f-t, 2.0f) * curve->controlPoint1.x +
                    3.0f * powf (t, 2.0f) * (1.0f-t) * curve->controlPoint2.x + 
                    powf (t, 3.0f) * curve->endPoint.x;

                    float yt = 
                    powf (1.0f-t, 3.0f) * currentPoint.y + 
                    3.0f * t * powf (1.0f-t, 2.0f) * curve->controlPoint1.y +
                    3.0f * powf (t, 2.0f) * (1.0f-t) * curve->controlPoint2.y + 
                    powf (t, 3.0f) * curve->endPoint.y;

                    glVertex3f(xt, yt, 5.0f);
                }
                
                currentPoint = curve->endPoint;
                if(pathElem->controlType == E2D_END_SUBPATH)
                    glEnd();
                else  {
                        if(pathElem->controlType == E2D_END_SUBPATH_LOOP)
                        {
                            glVertex3f(startPointOfSubPath.x, 
                                    startPointOfSubPath.y, 5.0f);
                            glEnd();
                            currentPoint = startPointOfSubPath;
                        }
                }
                    
                break;
        }
        
    }
    glColor4ub(255, 255, 255, 255);
    
    drawAxis();
    drawRect(path->element.bboxPosition, path->element.bboxWidth, path->element.bboxHeight);
    
}
示例#22
0
//==============================================================================
void Graphics::drawRect (float x, float y, float width, float height, float lineThickness) const
{
    drawRect (coordsToRectangle (x, y, width, height), lineThickness);
}
示例#23
0
void AxisBase::drawAxisModel(QPainter &p)
{
    PlotterBase *plotter = (PlotterBase*)parent();
    QRect rect(plotter->contentsRect());

    int p_start, p_end;
    calculatePoints(p_start, p_end);

    switch (m_orient)
    {
        case Qt::Vertical:
        {
            p.setPen(m_pen);
            p.drawLine(m_offset+2, p_start, m_offset+2, p_end);

            if (m_model)
            {
            }

            break;
        }

        case Qt::Horizontal:
        {
            p.setPen(m_pen);
            p.drawLine(p_start, rect.height()-m_offset, p_end, rect.height()-m_offset);

            if (m_model)
            {
                int count = m_model->columnCount();
				if (count <= 0)
					return;

                int p_offs = (p_end - p_start) / count;
                int p_line_d = p_start + p_offs;

				QRect prevRect;

                for (int i = 0; i < count; i++)
                {
                    double d = (double)i / (double)count;
                    int p_d = d * (p_end - p_start) + p_start + p_offs/2;

                    p.setPen(m_majorPen);
                    p.drawLine(p_d, rect.height()-m_offset+0, p_d, rect.height()-m_offset+4);

                    if (m_majorGridPen != Qt::NoPen)
                    {
                        p.setPen(m_majorGridPen);
                        p.drawLine(p_line_d, rect.top(), p_line_d, rect.height()-m_offset);
                        p_line_d += p_offs;
                    }

                    QString text(m_model->headerData(i, m_orient).toString());
                    QFontMetrics fm(m_font);
                    QRect textRect(fm.boundingRect(text));

                    int w = textRect.width() + 4;
                    QRect drawRect(p_d - w/2, rect.height()-m_offset+3, w, m_offset);

                    // skip paining the text
                    if (prevRect.isValid() && prevRect.intersects(drawRect))
                        continue;
                    prevRect = drawRect;

                    p.setPen(QPen(m_textColor));
                    p.drawText(drawRect, Qt::AlignCenter, text);
                }
            }

            break;
        }

    }

}
示例#24
0
void Graphics::drawRect (int x, int y, int width, int height, int lineThickness) const
{
    drawRect (coordsToRectangle (x, y, width, height), lineThickness);
}
示例#25
0
文件: cframe.cpp 项目: EQ4/vstgui
//-----------------------------------------------------------------------------
bool CFrame::platformDrawRect (CDrawContext* context, const CRect& rect)
{
	drawRect (context, rect);
	return true;
}
示例#26
0
void Graphics::drawRect (const Rectangle<int>& r, int lineThickness) const
{
    drawRect (r.toFloat(), (float) lineThickness);
}
示例#27
0
文件: WPainter.C 项目: nkabir/wt
void WPainter::drawRects(const WT_ARRAY WRectF *rectangles, int rectCount)
{
    for (int i = 0; i < rectCount; ++i)
        drawRect(rectangles[i]);
}
示例#28
0
void Graphics::drawRect(int x, int y, int width, int height, Color c)
{
    drawRect(Rect(x,y,width,height),c);
}
示例#29
0
void selectionDraw(){
	drawRect(selectionTexture, 1024/2-256/2, 768/2-128/2, 256, 128);
	drawRect(selectionIdxTexture[selectionIdx], 1024/2-256/2, 768/2-128/2, 256, 128);
}
示例#30
0
void GlVizualizer::draw(QPainter *p)
{
    p->fillRect(geometry(), Qt::black);
    QLinearGradient gradient( getWidth()/2, getY(),
                              getWidth()/2, getY() + getHeight());

    gradient.setColorAt(0, gradientColorAt0);
    gradient.setColorAt(1, gradientColorAt1);
    p->setBrush(QBrush(gradient));
    QPainterPath pa;
    QRect rect = geometry();
    pa.addRoundedRect(rect, borderRadius, borderRadius);
    pen.setWidth(border); //Strichbreite
    pen.setColor(borderColor); //Strichfarbe
    p->setPen(pen);
    p->drawPath(pa);

    for(int j = (int)(blockValue[8]); j > 0; j--)
        drawRect(p, 10, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[7]); j > 0; j--)
        drawRect(p, 70, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[6]); j > 0; j--)
        drawRect(p, 130, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[5]); j > 0; j--)
        drawRect(p, 190, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[4]); j > 0; j--)
        drawRect(p, 250, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[3]); j > 0; j--)
        drawRect(p, 310, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[2]); j > 0; j--)
        drawRect(p, 370, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[3]); j > 0; j--)
        drawRect(p, 430, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[4]); j > 0; j--)
        drawRect(p, 490, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[5]); j > 0; j--)
        drawRect(p, 550, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[6]); j > 0; j--)
        drawRect(p, 610, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[7]); j > 0; j--)
        drawRect(p, 670, getY() + getHeight() - (j*25));

    for(int j = (int)(blockValue[8]); j > 0; j--)
        drawRect(p, 730, getY() + getHeight() - (j*25));
}