本文整理汇总了C++中gfx::Canvas::SetAntiAliasing方法的典型用法代码示例。如果您正苦于以下问题:C++ Canvas::SetAntiAliasing方法的具体用法?C++ Canvas::SetAntiAliasing怎么用?C++ Canvas::SetAntiAliasing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gfx::Canvas
的用法示例。
在下文中一共展示了Canvas::SetAntiAliasing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
/*
** Draws the solid background & bevel if such are defined
*/
bool Meter::Draw(Gfx::Canvas& canvas)
{
if (IsHidden()) return false;
canvas.SetAntiAliasing(m_AntiAlias);
if (m_SolidColor.a != 0.0f || m_SolidColor2.a != 0.0f)
{
const FLOAT x = (FLOAT)GetX();
const FLOAT y = (FLOAT)GetY();
const D2D1_RECT_F r = D2D1::RectF(x, y, x + (FLOAT)m_W, y + (FLOAT)m_H);
if (m_SolidColor.r == m_SolidColor2.r && m_SolidColor.g == m_SolidColor2.g &&
m_SolidColor.b == m_SolidColor2.b && m_SolidColor.a == m_SolidColor2.a)
{
canvas.FillRectangle(r, m_SolidColor);
}
else
{
canvas.FillGradientRectangle(r, m_SolidColor, m_SolidColor2, (FLOAT)m_SolidAngle);
}
}
if (m_SolidBevel != BEVELTYPE_NONE)
{
D2D1_COLOR_F lightColor = D2D1::ColorF(D2D1::ColorF::White);
D2D1_COLOR_F darkColor = D2D1::ColorF(D2D1::ColorF::Black);
if (m_SolidBevel == BEVELTYPE_DOWN)
{
lightColor = D2D1::ColorF(D2D1::ColorF::Black);
darkColor = D2D1::ColorF(D2D1::ColorF::White);
}
// The bevel is drawn outside the meter
const FLOAT x = (FLOAT)GetX();
const FLOAT y = (FLOAT)GetY();
const D2D1_RECT_F rect = D2D1::RectF(x - 2.0f, y - 2.0f, x + (FLOAT)m_W + 2.0f, y + (FLOAT)m_H + 2.0f);
DrawBevel(canvas, rect, lightColor, darkColor);
}
return true;
}
示例2: Draw
/*
** Draws the solid background & bevel if such are defined
*/
bool Meter::Draw(Gfx::Canvas& canvas)
{
if (IsHidden()) return false;
canvas.SetAntiAliasing(m_AntiAlias);
if (m_SolidColor.GetA() != 0 || m_SolidColor2.GetA() != 0)
{
int x = GetX();
int y = GetY();
Rect r(x, y, m_W, m_H);
if (m_SolidColor.GetValue() == m_SolidColor2.GetValue())
{
SolidBrush solid(m_SolidColor);
canvas.FillRectangle(r, solid);
}
else
{
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
if (!m_AntiAlias)
{
// Fix the tiling issue in some GradientAngle values
graphics.SetPixelOffsetMode(PixelOffsetModeHalf);
}
LinearGradientBrush gradient(r, m_SolidColor, m_SolidColor2, m_SolidAngle, TRUE);
graphics.FillRectangle(&gradient, r);
if (!m_AntiAlias)
{
graphics.SetPixelOffsetMode(PixelOffsetModeDefault);
}
canvas.EndGdiplusContext();
}
}
if (m_SolidBevel != BEVELTYPE_NONE)
{
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
int x = GetX();
int y = GetY();
Color lightColor(255, 255, 255, 255);
Color darkColor(255, 0, 0, 0);
if (m_SolidBevel == BEVELTYPE_DOWN)
{
lightColor.SetValue(Color::MakeARGB(255, 0, 0, 0));
darkColor.SetValue(Color::MakeARGB(255, 255, 255, 255));
}
Pen light(lightColor);
Pen dark(darkColor);
// The bevel is drawn outside the meter
Rect rect(x - 2, y - 2, m_W + 4, m_H + 4);
DrawBevel(graphics, rect, light, dark);
canvas.EndGdiplusContext();
}
return true;
}