本文整理汇总了C++中JXWindowPainter::Ellipse方法的典型用法代码示例。如果您正苦于以下问题:C++ JXWindowPainter::Ellipse方法的具体用法?C++ JXWindowPainter::Ellipse怎么用?C++ JXWindowPainter::Ellipse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JXWindowPainter
的用法示例。
在下文中一共展示了JXWindowPainter::Ellipse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: color
void
JXColorWheel::Draw
(
JXWindowPainter& p,
const JRect& rect
)
{
JXColormap* colormap = GetColormap();
const JColorIndex black = colormap->GetBlackColor();
const JRect bounds = GetBoundsGlobal();
const JCoordinate max = JMin(bounds.height(), bounds.width() - kSliderWidth - kSliderMargin);
const JCoordinate size = max - 2*kWheelMargin - 1;
const JCoordinate center = size/2 + kWheelMargin;
if (itsImage == NULL || itsImage->GetWidth() != max || itsColor.brightness != itsLastDrawBrightness)
{
p.SetFilling(kJTrue);
p.SetPenColor(black);
p.Ellipse(kWheelMargin, kWheelMargin, size, size);
p.SetFilling(kJFalse);
JRect r = bounds;
r.bottom = r.top + max;
r.right = r.left + max;
jdelete itsImage;
itsImage = jnew JXImage(GetDisplay(), p.GetDrawable(), r);
assert( itsImage != NULL );
itsLastDrawBrightness = itsColor.brightness;
for (JCoordinate x=0; x<max; x++)
{
const JCoordinate dx = - x + center;
for (JCoordinate y=0; y<max; y++)
{
if (itsImage->GetColor(x,y) == black)
{
const JCoordinate dy = y - center;
const JFloat r = sqrt(dx*dx + dy*dy) / center;
const JFloat a = 0.5 + atan2(dy, dx) / (2.0 * kJPi);
JHSB color(JRound(a * kJMaxHSBValue), JRound(r * kJMaxHSBValue), itsLastDrawBrightness);
itsImage->SetColor(x,y, colormap->JColormap::GetColor(color));
}
}
}
itsImage->ConvertToRemoteStorage();
}
p.JPainter::Image(*itsImage, itsImage->GetBounds(), 0,0);
const JFloat r = (itsColor.saturation / kJMaxHSBValueF) * size/2;
const JFloat a = ((itsColor.hue / kJMaxHSBValueF) - 0.5) * 2.0 * kJPi;
const JCoordinate x = center - JRound(r * cos(a));
const JCoordinate y = center + JRound(r * sin(a));
JRect mark(y-kWheelMargin, x-kWheelMargin, y+kWheelMargin+1, x+kWheelMargin+1);
p.SetPenColor(colormap->GetWhiteColor());
p.SetFilling(kJTrue);
p.JPainter::Rect(mark);
p.SetFilling(kJFalse);
p.SetPenColor(black);
p.JPainter::Rect(mark);
}