bool EbookEngine::RenderPage(HDC hDC, RectI screenRect, int pageNo, float zoom, int rotation, RectD *pageRect, RenderTarget target, AbortCookie **cookie_out)
{
    RectD pageRc = pageRect ? *pageRect : PageMediabox(pageNo);
    RectI screen = Transform(pageRc, pageNo, zoom, rotation).Round();

    Graphics g(hDC);
    g.SetCompositingQuality(CompositingQualityHighQuality);
    g.SetSmoothingMode(SmoothingModeAntiAlias);
    g.SetPageUnit(UnitPixel);
    g.SetTextRenderingHint(TextRenderingHintClearTypeGridFit);

    Color white(0xFF, 0xFF, 0xFF);
    Rect screenR(screenRect.x, screenRect.y, screenRect.dx, screenRect.dy);
    g.SetClip(screenR);
    screenR.Inflate(1, 1);
    g.FillRectangle(&SolidBrush(white), screenR);

    Matrix m;
    GetTransform(m, zoom, rotation);
    m.Translate((float)(screenRect.x - screen.x), (float)(screenRect.y - screen.y), MatrixOrderAppend);
    g.SetTransform(&m);

    EbookAbortCookie *cookie = NULL;
    if (cookie_out)
        *cookie_out = cookie = new EbookAbortCookie();

    ScopedCritSec scope(&pagesAccess);
    FixFontSizeForResolution(hDC);
    DrawHtmlPage(&g, GetHtmlPage(pageNo), pageBorder, pageBorder, false, &Color(Color::Black), cookie ? &cookie->abort : NULL);
    return !(cookie && cookie->abort);
}
void
gfxQuartzNativeDrawing::EndNativeDrawing()
{
  NS_ASSERTION(mCGContext, "EndNativeDrawing called without BeginNativeDrawing");
  MOZ_ASSERT(!mContext->IsCairo(), "BeginNativeDrawing succeeded with cairo context?");

  mBorrowedContext.Finish();
  if (mDrawTarget) {
    DrawTarget *dest = mContext->GetDrawTarget();
    RefPtr<SourceSurface> source = mDrawTarget->Snapshot();

    IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
                        NSToIntFloor(mNativeRect.height * mBackingScale));

    Matrix oldTransform = dest->GetTransform();
    Matrix newTransform = oldTransform;
    newTransform.Translate(mNativeRect.x, mNativeRect.y);
    newTransform.Scale(1.0f / mBackingScale, 1.0f / mBackingScale);

    dest->SetTransform(newTransform);

    dest->DrawSurface(source,
                      gfx::Rect(0, 0, backingSize.width, backingSize.height),
                      gfx::Rect(0, 0, backingSize.width, backingSize.height));


    dest->SetTransform(oldTransform);
  }
}
Example #3
0
void TexturedRectangle::Draw(ShaderProgram * program) const
{
	const float rectV[] =	{ right, upper
							, left, upper
							, left, lower

							, left, lower
							, right, lower
							, right, upper };

	float leftTex = (hMirror ? 1.f : 0.f);
	float rightTex = 1.f - leftTex;

	const float texV[] =	{ rightTex, 1.f
							, leftTex, 1.f
							, leftTex, 0.f

							, leftTex, 0.f
							, rightTex, 0.f
							, rightTex, 1.f };

	Matrix modelMatrix;
	modelMatrix.Translate(point.x, point.y, 0);
	modelMatrix.Rotate(angle);

	program->setModelMatrix(modelMatrix);
	glBindTexture(GL_TEXTURE_2D, texture);
	glEnableVertexAttribArray(program->positionAttribute);
	glEnableVertexAttribArray(program->texCoordAttribute);
	glVertexAttribPointer(program->positionAttribute, 2, GL_FLOAT, false, 0, rectV);
	glVertexAttribPointer(program->texCoordAttribute, 2, GL_FLOAT, false, 0, texV);
	glDrawArrays(GL_TRIANGLES, 0, 6);
	glDisableVertexAttribArray(program->positionAttribute);
	glDisableVertexAttribArray(program->texCoordAttribute);
}
CGContextRef
gfxQuartzNativeDrawing::BeginNativeDrawing()
{
  NS_ASSERTION(!mCGContext, "BeginNativeDrawing called when drawing already in progress");

  if (mContext->IsCairo()) {
    // We're past that now. Any callers that still supply a Cairo context
    // don't deserve native theming.
    NS_WARNING("gfxQuartzNativeDrawing being used with a gfxContext that is not backed by a DrawTarget");
    return nullptr;
  }

  DrawTarget *dt = mContext->GetDrawTarget();
  if (dt->GetBackendType() != BackendType::COREGRAPHICS || dt->IsDualDrawTarget()) {
    IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
                        NSToIntFloor(mNativeRect.height * mBackingScale));

    if (backingSize.IsEmpty()) {
      return nullptr;
    }

    mDrawTarget = Factory::CreateDrawTarget(BackendType::COREGRAPHICS, backingSize, SurfaceFormat::B8G8R8A8);

    Matrix transform;
    transform.Scale(mBackingScale, mBackingScale);
    transform.Translate(-mNativeRect.x, -mNativeRect.y);

    mDrawTarget->SetTransform(transform);
    dt = mDrawTarget;
  }

  mCGContext = mBorrowedContext.Init(dt);
  MOZ_ASSERT(mCGContext);
  return mCGContext;
}
Example #5
0
//原生GDI+ 绘制
void converDemo::drawOnNativeGdi(Graphics &graphics)
{

	GraphicsPath path;
	path.AddEllipse(10, 10, 100, 100);
	path.AddRectangle(RectF(100, 100, 200, 250));
	PathGradientBrush* brush = new PathGradientBrush(&path);
	Color colors[] = {
		Color(0, 0, 255), Color(0, 0, 0), Color(0, 255, 0), Color(255, 0, 0)
	};
	REAL reals[] = {
		0, 0.5, 0.8, 1
	};
	brush->SetInterpolationColors(colors, reals, 4);
	Matrix matrix;
	matrix.Translate(100, 0);
	matrix.Shear(0.15, 0.3);
	matrix.Scale(0.4, 0.2);
	matrix.Rotate(0.5);
//	brush->MultiplyTransform(&matrix, MatrixOrderAppend);
	RectF rect(convertQRectF2GpRectF(QRectF(100.0f, 100.0f, 200.0f, 400.0f)));
	graphics.FillRectangle(brush, rect);
	delete brush;

}
Example #6
0
void GameApp::displayText(const string s, float x, float y, float w, float h, float spacing){
	shader->setViewMatrix(Matrix());
	Matrix model;
	model.Translate(x, y, 0);
	SheetSprite temp;
	viewMatrix.identity();
	shader->setViewMatrix(viewMatrix);
	for (size_t i = 0; i < s.length(); i++){
		temp = *sprites[s.substr(i, 1)];
		temp.width = w;
		temp.height = h;
		shader->setModelMatrix(model);
		temp.draw(shader);
		model.Translate(w + spacing, 0, 0);
	}
}
Example #7
0
bool ImagesEngine::RenderPage(HDC hDC, RectI screenRect, int pageNo, float zoom, int rotation, RectD *pageRect, RenderTarget target, AbortCookie **cookie_out)
{
    Bitmap *bmp = LoadImage(pageNo);
    if (!bmp)
        return false;

    RectD pageRc = pageRect ? *pageRect : PageMediabox(pageNo);
    RectI screen = Transform(pageRc, pageNo, zoom, rotation).Round();

    Graphics g(hDC);
    g.SetCompositingQuality(CompositingQualityHighQuality);
    g.SetSmoothingMode(SmoothingModeAntiAlias);
    g.SetPageUnit(UnitPixel);

    Color white(0xFF, 0xFF, 0xFF);
    Rect screenR(screenRect.x, screenRect.y, screenRect.dx, screenRect.dy);
    g.SetClip(screenR);
    g.FillRectangle(&SolidBrush(white), screenR);

    Matrix m;
    GetTransform(m, pageNo, zoom, rotation);
    m.Translate((REAL)(screenRect.x - screen.x), (REAL)(screenRect.y - screen.y), MatrixOrderAppend);
    g.SetTransform(&m);

    RectI pageRcI = PageMediabox(pageNo).Round();
    ImageAttributes imgAttrs;
    imgAttrs.SetWrapMode(WrapModeTileFlipXY);
    Status ok = g.DrawImage(bmp, Rect(0, 0, pageRcI.dx, pageRcI.dy), 0, 0, pageRcI.dx, pageRcI.dy, UnitPixel, &imgAttrs);
    return ok == Ok;
}
Example #8
0
void move_it(ShaderProgram program, Matrix& modelMatrix, Matrix& projectionMatrix, Matrix& viewMatrix,float x, float y){
	program.setModelMatrix(modelMatrix);
	program.setProjectionMatrix(projectionMatrix);
	program.setViewMatrix(viewMatrix);
	modelMatrix.identity();
	modelMatrix.Translate(x, y, 0.0);
}
void RenderGameLevel(ShaderProgram &program, float elapsed) {
    //Rendering
    level.renderLevel(&program, mapTexture, modelMatrix);
    for (int i = 0; i<allUnits.size(); i++) {
        allUnits[i].Render(modelMatrix);
    }
    selectionWindow->Render(modelMatrix);
    if (moveWindowOn) {
        moveWindow->Render(modelMatrix);
    }
    if (warWindowOn) {
        warWindow->Render(modelMatrix);
    }

    //Scrolling
    viewMatrix.identity();
    viewMatrix.Scale(zoom, zoom, 0);
    viewMatrix.Translate(posX,posY,0);
    //viewMatrix.Rotate(.3);
    //viewMatrix.Pitch(elapsed/2);
    //viewMatrix.Yaw(elapsed);
    //cout << elapsed << endl;
    program.setViewMatrix(viewMatrix);

}
Example #10
0
void CompositeOverlay::render(Graphics *graphics)
{
	PointF origin(32768, 32768);

	for (int i=count()-1; i>=0; i--)
	{
		if ((*this)[i]->getX() < origin.X)
			origin.X = (*this)[i]->getX();
		if ((*this)[i]->getY() < origin.Y)
			origin.Y = (*this)[i]->getY();
	}

	Matrix matrix;
    matrix.Translate((float)getX(), (float)getY());
    matrix.RotateAt((float)rotation, origin);

	GraphicsState gState = graphics->Save();
    graphics->MultiplyTransform(&matrix);

	for (i=count()-1; i>=0; i--)
	{
		(*this)[i]->render(graphics);
	}

	graphics->Restore(gState);
}
Example #11
0
void Entity::update(float& lastFrameTicks, float& elapsed, Matrix& projectionMatrix, Matrix& viewMatrix, ShaderProgram& program, bool stat) {
    //    Update modelMatrix
    Matrix modelMatrix;
    static bool wall = false;
    if (stat) {
        modelMatrix.identity();
        modelMatrix.Scale(0.5, 2, 0);
        program.setModelMatrix(modelMatrix);
    }
    else {
        if (y >= -0.65) {
            if (x > -1.85 && !wall) {
                x -= elapsed/2;
            }
            if (x <= -1.85) {
                wall = true;
                y -= elapsed*2;
            }
            if (x < 1.85 && wall) {
                x += elapsed/2;
            }
            if (x >= 1.85) {
                wall = false;
                y -= elapsed*4;
            }
        }
        modelMatrix.identity();
        modelMatrix.Scale(0.5, 2, 0);
        modelMatrix.Translate(x, y+0.4, 0);
        program.setModelMatrix(modelMatrix);
    }
}
Example #12
0
void
DrawBlur(gfxContext* aDestinationCtx,
         SourceSurface* aBlur,
         const IntPoint& aTopLeft,
         const Rect* aDirtyRect)
{
    DrawTarget *dest = aDestinationCtx->GetDrawTarget();

    nsRefPtr<gfxPattern> thebesPat = aDestinationCtx->GetPattern();
    Pattern* pat = thebesPat->GetPattern(dest, nullptr);

    Matrix oldTransform = dest->GetTransform();
    Matrix newTransform = oldTransform;
    newTransform.Translate(aTopLeft.x, aTopLeft.y);

    // Avoid a semi-expensive clip operation if we can, otherwise
    // clip to the dirty rect
    if (aDirtyRect) {
        dest->PushClipRect(*aDirtyRect);
    }

    dest->SetTransform(newTransform);
    dest->MaskSurface(*pat, aBlur, Point(0, 0));
    dest->SetTransform(oldTransform);

    if (aDirtyRect) {
        dest->PopClip();
    }
}
Example #13
0
	void Rectangle::GetRotatedPosArray(Vector2* pArray) const
	{
		TL_ASSERT(pArray != NULL);

		Matrix mat = Matrix::CreateRotationZ(mthToRadians(rotation));

		Vector2 &topLeft = pArray[0];
		Vector2 &topRight = pArray[1];
		Vector2 &botRight = pArray[2];
		Vector2 &botLeft = pArray[3];

		Vector2 pos = GetPos();

		if(anchorInCenter) {
			topLeft = pos + mat.Translate(Vector2(-w/2.0f, -h/2.0f));
			topRight = pos + mat.Translate(Vector2(w/2.0f, -h/2.0f));
			botRight = pos + mat.Translate(Vector2(w/2.0f, h/2.0f));
			botLeft = pos + mat.Translate(Vector2(-w/2.0f, h/2.0f));
		} else {
			topLeft = pos;
			topRight = pos + mat.Translate(Vector2(w, 0.0f));
			botRight = pos + mat.Translate(Vector2(w, h));
			botLeft = pos + mat.Translate(Vector2(0.0f, h));
		}
	}
Example #14
0
//Returns a Translation Matrix
Matrix Transformation::Translation ( float _XPoint, float _YPoint, float _ZPoint )
{
	Matrix TranslationMatrix;

	//Calls the function written in Matrix class
	TranslationMatrix.Translate ( _XPoint, _YPoint, _ZPoint );

	return TranslationMatrix;
}
Example #15
0
void Entity::Draw(ShaderProgram* program) {
    if (active) {
        Matrix modelMatrix;
        modelMatrix.Translate(position_x, position_y, 0.0f);
        program->setModelMatrix(modelMatrix);
        
        sprite.Draw(program);
    }
}
Example #16
0
void GetBaseTransform(Matrix& m, RectF pageRect, float zoom, int rotation)
{
    rotation = rotation % 360;
    if (rotation < 0) rotation = rotation + 360;
    if (90 == rotation)
        m.Translate(0, -pageRect.Height, MatrixOrderAppend);
    else if (180 == rotation)
        m.Translate(-pageRect.Width, -pageRect.Height, MatrixOrderAppend);
    else if (270 == rotation)
        m.Translate(-pageRect.Width, 0, MatrixOrderAppend);
    else if (0 == rotation)
        m.Translate(0, 0, MatrixOrderAppend);
    else
        CrashIf(true);

    m.Scale(zoom, zoom, MatrixOrderAppend);
    m.Rotate((REAL)rotation, MatrixOrderAppend);
}
Example #17
0
void Entity::Render( ShaderProgram* program ) {
    if( active ) {
        Matrix modelMatrix;
        modelMatrix.Translate(x, y, 0.0f);
        program->setModelMatrix( modelMatrix );
        
        sprite.Draw( program );
    }
}
Example #18
0
/*++

Routine Name:

    CWatermark::CreateWMTransform

Routine Description:

    Method to create a transformation matrix which will scale, translate and rotate
    the watermark to correctly fit onto the page. This overload perform scaling to fit
    the watermark content to the requested bounds and is used when creating the bitmap
    or vector watermark.

Arguments:

    wmBounds         - Rectangular area to contain the watermark
    pbstrMatrixXForm - Pointer to the string to contain the watermark transformation matrix

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CWatermark::CreateWMTransform(
    _In_        RectF wmBounds,
    _Outptr_ BSTR* pbstrMatrixXForm
    )
{
    ASSERTMSG(wmBounds.Width > 0, "Zero width watermark found whilst creating transform\n");
    ASSERTMSG(wmBounds.Height > 0, "Zero height watermark found whilst creating transform\n");

    HRESULT hr = S_OK;

    if (wmBounds.Width <= 0 || wmBounds.Height <= 0)
    {
        hr = E_INVALIDARG;
    }

    if (SUCCEEDED(hr) &&
        SUCCEEDED(hr = CHECK_POINTER(pbstrMatrixXForm, E_POINTER)))
    {
        *pbstrMatrixXForm = NULL;

        RectF targetBounds;
        REAL  angle = 0;

        if (SUCCEEDED(hr = m_WMProps.GetBounds(&targetBounds)) &&
            SUCCEEDED(hr = m_WMProps.GetAngle(&angle)))
        {
            ASSERTMSG(targetBounds.Width > 0, "Zero width target found whilst creating transform\n");
            ASSERTMSG(targetBounds.Height > 0, "Zero height target found whilst creating transform\n");

            //
            // Start with the identity matrix
            //
            Matrix xForm;

            //
            // Offset to the target bounds
            //
            PointF offset(targetBounds.X - wmBounds.X, targetBounds.Y - wmBounds.Y);

            //
            // Apply the transforms to the matrix
            //
            xForm.Scale(targetBounds.Width/wmBounds.Width, targetBounds.Height/wmBounds.Height, MatrixOrderAppend);
            xForm.Rotate(angle, MatrixOrderAppend);
            xForm.Translate(offset.X, offset.Y, MatrixOrderAppend);

            //
            // Retrieve the matrix string
            //
            hr = MatrixToXML(&xForm, pbstrMatrixXForm);
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Example #19
0
mozilla::TemporaryRef<mozilla::gfx::SourceSurface>
WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
{
    if (!gl)
        return nullptr;

    nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(gfxIntSize(mWidth, mHeight),
                                                         gfxImageFormat::ARGB32,
                                                         mWidth * 4, 0, false);
    if (surf->CairoStatus() != 0) {
        return nullptr;
    }

    gl->MakeCurrent();
    {
        ScopedBindFramebuffer autoFB(gl, 0);
        ClearBackbufferIfNeeded();
        ReadPixelsIntoImageSurface(gl, surf);
    }

    if (aPremultAlpha) {
        *aPremultAlpha = true;
    }
    bool srcPremultAlpha = mOptions.premultipliedAlpha;
    if (!srcPremultAlpha) {
        if (aPremultAlpha) {
            *aPremultAlpha = false;
        } else {
            gfxUtils::PremultiplyImageSurface(surf);
            surf->MarkDirty();
        }
    }

    RefPtr<DrawTarget> dt =
        Factory::CreateDrawTarget(BackendType::CAIRO,
                                  IntSize(mWidth, mHeight),
                                  SurfaceFormat::B8G8R8A8);

    if (!dt) {
        return nullptr;
    }

    RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, surf);

    Matrix m;
    m.Translate(0.0, mHeight);
    m.Scale(1.0, -1.0);
    dt->SetTransform(m);

    dt->DrawSurface(source,
                    Rect(0, 0, mWidth, mHeight),
                    Rect(0, 0, mWidth, mHeight),
                    DrawSurfaceOptions(),
                    DrawOptions(1.0f, CompositionOp::OP_SOURCE));

    return dt->Snapshot();
}
void HEToolMove::redoAct()
{
    this->frame->addXY(this->dx,this->dy,true);

    if( this->wspc->getSelection() != NULL ) {
        Matrix off;
        off.Translate(this->dx,this->dy);
        this->wspc->getSelection()->Transform(&off);
    }
}
Example #21
0
void gameOver::Render() {
	Matrix modelMatrix;

	modelMatrix.identity();
	modelMatrix.Translate(-2.5f, 0, 0);

	programOver->setModelMatrix(modelMatrix);

	DrawText(comicFont, "GAME OVER", 0.5f, 0.1f);
}
Example #22
0
void SkyBox::RenderBoundingBox(void)
{
	glDisable(GL_CULL_FACE);
	glCullFace(GL_NONE);
	Matrix MatScale = Matrix::Identity;
	MatScale.Scale(scale);

	Matrix SkyPos;

	SkyPos.CreateFromQuaternion(&orient,&SkyPos);
	SkyPos.Translate(GAME->PlayerCamera->pos);
	SkyPos.Translate(pos);

	SkyPos = SkyPos * MatScale;

	model->DrawBoundingBox(GAME->GameRenderer,&SkyPos);
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
}
Example #23
0
mozilla::TemporaryRef<mozilla::gfx::SourceSurface>
WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
{
    if (!gl)
        return nullptr;

    RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurfaceWithStride(IntSize(mWidth, mHeight),
                                                                                SurfaceFormat::B8G8R8A8,
                                                                                mWidth * 4);
    if (!surf) {
        return nullptr;
    }

    gl->MakeCurrent();
    {
        ScopedBindFramebuffer autoFB(gl, 0);
        ClearBackbufferIfNeeded();
        ReadPixelsIntoDataSurface(gl, surf);
    }

    if (aPremultAlpha) {
        *aPremultAlpha = true;
    }
    bool srcPremultAlpha = mOptions.premultipliedAlpha;
    if (!srcPremultAlpha) {
        if (aPremultAlpha) {
            *aPremultAlpha = false;
        } else {
            gfxUtils::PremultiplyDataSurface(surf);
        }
    }

    RefPtr<DrawTarget> dt =
        Factory::CreateDrawTarget(BackendType::CAIRO,
                                  IntSize(mWidth, mHeight),
                                  SurfaceFormat::B8G8R8A8);

    if (!dt) {
        return nullptr;
    }

    Matrix m;
    m.Translate(0.0, mHeight);
    m.Scale(1.0, -1.0);
    dt->SetTransform(m);

    dt->DrawSurface(surf,
                    Rect(0, 0, mWidth, mHeight),
                    Rect(0, 0, mWidth, mHeight),
                    DrawSurfaceOptions(),
                    DrawOptions(1.0f, CompositionOp::OP_SOURCE));

    return dt->Snapshot();
}
Example #24
0
void Entity::Draw(ShaderProgram* program){
	Matrix ModelMatrix;
	ModelMatrix.identity();
	ModelMatrix.Translate(x, y, 0);
	ModelMatrix.Rotate(rotation * RAD_CONV);
	if (flip){
		ModelMatrix.Scale(-1, 1, 1);
	}
	
	program->setModelMatrix(ModelMatrix);
	sprite.Draw(program);
}
Example #25
0
void GPDrawShadowText( Graphics& gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB PenClrIn , ARGB shadowPenClrIn /*= 0xff000000*/, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
	Gdiplus::Font& gcfont = fontIn;
	FontFamily fmy;
	gcfont.GetFamily(&fmy);
	int nfontStyle  = gcfont.GetStyle();
	REAL dFontSize = gcfont.GetSize();
	Rect rcText = CRect2Rect(rcIn);
	StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisWord);
	fmt.SetLineAlignment(StringAlignmentCenter);
	StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;

	GraphicsContainer  gcContainer = gc.BeginContainer();
	gc.SetSmoothingMode(SmoothingModeAntiAlias);
	CComBSTR btrTxtIn(strTxtIn);
	GraphicsPath textPath;
	textPath.AddString(btrTxtIn, -1,  &fmy, nfontStyle, dFontSize, rcText, &fmtUse);

	Matrix mx;
	mx.Translate(nOffXIn, nOffYIn);
	textPath.Transform(&mx);

	Pen textPen(ARGB2Color(shadowPenClrIn), 1);
	SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
	textPen.SetLineJoin(LineJoinRound);
	if (shadowBrushClrIn != 0)
	{
		gc.FillPath(&textbrush, &textPath);
	}
	if (shadowPenClrIn != 0)
	{
		gc.DrawPath(&textPen, &textPath);
	}



	mx.Invert();
	textPath.Transform(&mx);
	textPen.SetColor(ARGB2Color(PenClrIn));
	textbrush.SetColor(ARGB2Color(BrushClrIn));
	if (BrushClrIn != 0)
	{
		gc.FillPath(&textbrush, &textPath);
	}
	if (PenClrIn != 0)
	{
		gc.DrawPath(&textPen, &textPath);
	}
	gc.EndContainer(gcContainer);
}
Example #26
0
void Player::SetArrowPos(const Vec3f& newpos)
{
//std::cout << " Setting arrow pos to " << newpos << "\n";

  Matrix m;
  m.Translate(newpos);
  m_arrow->SetLocalTransform(m);

  m_arrow->SetAABB(AABB(
    newpos.x - ARROW_XSIZE, newpos.x + ARROW_XSIZE,
    newpos.y, newpos.y + ARROW_YSIZE,
    newpos.z - ARROW_XSIZE, newpos.z + ARROW_XSIZE));
}
/**
 * \brief Test to see if we clicked on the image.
 * \param pos Position to test
 * \returns True if clicked on
 */
bool CImageDrawable::HitTest(Gdiplus::Point pos)
{
    Matrix mat;
    mat.Translate((float)mCenter.X, (float)mCenter.Y);
    mat.Rotate((float)(mPlacedR * RtoD));
    mat.Translate((float)-mPlacedPosition.X, (float)-mPlacedPosition.Y);

    Point points[] = { pos };
    mat.TransformPoints(points, 1);

    double wid = mImage->GetWidth();
    double hit = mImage->GetHeight();

    double testX = points[0].X;
    double testY = points[0].Y;

    // Test to see if x, y are in the image
    if (testX < 0 || testY < 0 || testX >= wid || testY >= hit)
    {
        // We are outside the image
        return false;
    }

    // Test to see if x, y are in the drawn part of the image
    auto format = mImage->GetPixelFormat();
    if (format == PixelFormat32bppARGB || format == PixelFormat32bppPARGB)
    {
        // This image has an alpha map, which implements the 
        // transparency. If so, we should check to see if we
        // clicked on a pixel where alpha is not zero, meaning
        // the pixel shows on the screen.
        Color color;
        mImage->GetPixel((int)testX, (int)testY, &color);
        return color.GetAlpha() != 0;
    }
    else {
        return true;
    }
}
Example #28
0
 void drawEntity(ShaderProgram &program) {
     modelM.identity();
     modelM.Scale(width, height, 1.0f);
     modelM.Translate(x, y, 0.0f);
     
     program.setModelMatrix(modelM);
     
     glVertexAttribPointer(program.positionAttribute, 2, GL_FLOAT, false, 0, vertices.data());
     glEnableVertexAttribArray(program.positionAttribute);
     
     
     glDrawArrays(GL_TRIANGLES, 0, ((int)vertices.size() / 2));
 }
Example #29
0
void Tank::Draw() {
	Matrix modelMatrix = Matrix();
	modelMatrix.Translate(x, y, 0.0f);

	program->setModelMatrix(modelMatrix);


	if (bullet->use) {
		DrawSpriteSheetSprite(1, 1, 2);
		bullet->Draw();
	}	else {
		DrawSpriteSheetSprite(0, 1, 2);
	}
}
Example #30
0
void Camera::Render(void)
{
	Vector3 temppos = -pos;
	Matrix TranslateMat = Matrix::Identity;
	TranslateMat.Translate(temppos);

	Matrix::CreateFromQuaternion(&orient,&CameraMat);
	CameraMat.Transpose();

	CameraMat = CameraMat * TranslateMat;

	GAME->GameRenderer->SetPerspective(&PerspectiveMat);
	GAME->GameRenderer->SetCamera(&CameraMat);
}