Esempio n. 1
0
D2D1_RECT_F SimpleImage::GetTransformedRect(D2D1_POINT_2F midPoint, const D2D1_RECT_F& rect)
{
    D2D1::Matrix3x2F transform = GetTransformationsReversed(midPoint);

    D2D1_POINT_2F upperLeft = transform.TransformPoint(D2D1::Point2F(rect.left, rect.top));
    D2D1_POINT_2F lowerRight = transform.TransformPoint(D2D1::Point2F(rect.right, rect.bottom));

    return Direct2DUtility::FixRect(D2D1::RectF(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y));
}
Esempio n. 2
0
void CWedgeDrawer::RegenerateGeometry()
{
	// Points on horizontal line:
	// x^2 + y^2 = r^2      and     y = m
	// => x^2 = r^2 - m^2
	D2D1_POINT_2F p0 = D2D1::Point2F(
		(FLOAT)sqrt(mInnerRadius*mInnerRadius - mMarginThickness*mMarginThickness),
		(FLOAT)mMarginThickness);
	D2D1_POINT_2F p3 = D2D1::Point2F(
		(FLOAT)sqrt(mOuterRadius*mOuterRadius - mMarginThickness*mMarginThickness),
		(FLOAT)mMarginThickness);

	D2D1::Matrix3x2F rotation = D2D1::Matrix3x2F::Rotation((FLOAT)mSweep);
	D2D1_POINT_2F p1 = rotation.TransformPoint(
		D2D1::Point2F((FLOAT)mInnerRadius, -(FLOAT)mMarginThickness));
	D2D1_POINT_2F p2 = rotation.TransformPoint(
		D2D1::Point2F((FLOAT)mOuterRadius, -(FLOAT)mMarginThickness));

	// Points on other line:
	// x^2 + y^2 = r^2     &     y = mx + b
	// => m^2+1!=0 (i.e. angles not equal to 90 degrees)
	//    x = (-sqrt(-b^2+m^2 r^2+r^2)-b m)/(m^2+1)
	//    y = (b-m sqrt(-b^2+m^2 r^2+r^2))/(m^2+1)

	// Create the figure
	mGeometry.Release();
	mFactory->CreatePathGeometry(&mGeometry);
	{
		CComPtr<ID2D1GeometrySink> sink;
		mGeometry->Open(&sink);
		sink->BeginFigure(p0, D2D1_FIGURE_BEGIN_FILLED);
		sink->AddArc(D2D1::ArcSegment(p1, 
			D2D1::SizeF((FLOAT)mInnerRadius, (FLOAT)mInnerRadius), 0,
			D2D1_SWEEP_DIRECTION_CLOCKWISE, D2D1_ARC_SIZE_SMALL));
		sink->AddLine(p2);
		sink->AddArc(D2D1::ArcSegment(p3, 
			D2D1::SizeF((FLOAT)mOuterRadius, (FLOAT)mOuterRadius), 0,
			D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE, D2D1_ARC_SIZE_SMALL));
		sink->EndFigure(D2D1_FIGURE_END_CLOSED);
		sink->Close();
	}
}
Esempio n. 3
0
void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y)
{
    D2D1::Matrix3x2F dm;
    D2D1_POINT_2F pt;

    m2d(m, &dm);
    pt.x = *x;
    pt.y = *y;
    pt = dm.TransformPoint(pt);
    *x = pt.x;
    *y = pt.y;
}
Esempio n. 4
0
void Scene::CalculateLayout()
{
	D2D1_SIZE_F fSize = m_pRenderTarget->GetSize();

	const float x = fSize.width / 2.0f;
	const float y = fSize.height / 2.0f;
	const float radius = min(x, y);

	//m_ellipse = D2D1::Ellipse(D2D1::Point2F(x, y), radius, radius);
	m_ellipse = D2D1::Ellipse(m_PacLoc, m_PacRadius, m_PacRadius);

	// Calculate tick marks.

	D2D_POINT_2F pt1 = D2D1::Point2F(
		m_ellipse.point.x,
		m_ellipse.point.y - (m_ellipse.radiusY * 0.9f)
		);

	D2D_POINT_2F pt2 = D2D1::Point2F(
		m_ellipse.point.x,
		m_ellipse.point.y - m_ellipse.radiusY
		);

	for (DWORD i = 0; i < 12; i++)
	{
		D2D1::Matrix3x2F mat = D2D1::Matrix3x2F::Rotation(
			(360.0f / 12) * i, m_ellipse.point);

		m_Ticks[i * 2] = mat.TransformPoint(pt1);
		m_Ticks[i * 2 + 1] = mat.TransformPoint(pt2);
	}

	// Create the radial brush. The radial brush is centered on
	// the pac man, so it must be recreated when the size changes.
	CreateRadialBrush();
	CreateMouthGeometry();
}
Esempio n. 5
0
HRESULT SimpleImage::TranslateToAbsolutePoint(D2D1_POINT_2F point, D2D1_POINT_2F *translatedPoint)
{
    if (nullptr == translatedPoint)
    {
        return E_POINTER;
    }

    D2D1::Matrix3x2F invertedMatrix = GetInverseTransformations(Direct2DUtility::GetMidPoint(m_drawingRect));
    *translatedPoint = invertedMatrix.TransformPoint(point);

    (*translatedPoint).x += m_clipRect.left / GetCurrentImageScale();
    (*translatedPoint).y += m_clipRect.top  / GetCurrentImageScale();

    return S_OK;
}
void TransformChroma(const D2D1::Matrix3x2F& mat, BYTE *pu, BYTE *pv)
{
    // Normalize the chroma values to [-112, 112] range

    D2D1_POINT_2F pt = { static_cast<float>(*pu) - 128, static_cast<float>(*pv) - 128 };

    pt = mat.TransformPoint(pt);

    // Clamp to valid range.
    clamp(pt.x, -112.0f, 112.0f);
    clamp(pt.y, -112.0f, 112.0f);

    // Map back to [16...240] range.
    *pu = static_cast<BYTE>(pt.x + 128.0f);
    *pv = static_cast<BYTE>(pt.y + 128.0f);
}