本文整理汇总了C++中GraphicsContext::drawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::drawEllipse方法的具体用法?C++ GraphicsContext::drawEllipse怎么用?C++ GraphicsContext::drawEllipse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::drawEllipse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintRadio
bool RenderThemeAndroid::paintRadio(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
Node* node = obj->node();
Element* element = static_cast<Element*>(node);
if (element) {
InputElement* input = element->toInputElement();
GraphicsContext* context = info.context;
if (!element->isEnabledFormControl()) {
context->setAlpha(0.5f);
}
const IntRect inner = IntRect(rect.x() - 2, rect.y() - 2, rect.width() - 4, rect.height() - 4);
context->setFillColor(Color(defaultBgBright), context->fillColorSpace());
context->setStrokeColor(Color(defaultBgBright), context->strokeColorSpace());
context->setStrokeThickness(1.0f);
//SAMSUNG CHANGE [Cq - 5912]
/* if (input->isCheckbox()) {
context->drawRect(inner);
} else {
context->drawEllipse(inner);
}
context->setStrokeColor(Color(defaultFgColor), context->strokeColorSpace());*/
//SAMSUNG CHANGE [Cq - 5912]
if (input->isCheckbox()) {
context->drawRect(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4));
} else {
context->drawEllipse(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4));
}
if (input->isChecked()) {
context->setFillColor(Color(defaultCheckColor), context->fillColorSpace());
context->setStrokeColor(Color(defaultCheckColor), context->strokeColorSpace());
if (input->isCheckbox()) {
const float w2 = ((float) rect.width() / 2);
const float cx = ((float) rect.x());
const float cy = ((float) rect.y());
context->save();
// magic numbers due to weird scale in context
context->translate(cx + w2 / 2.2f, cy + w2 / 1.2f);
context->rotate(3.93f); // 225 degrees
context->drawRect(IntRect(0, 0, rect.width() / 4, 2));
context->rotate(1.57f); // 90 degrees
context->drawRect(IntRect(0, 0, rect.width() / 2, 2));
context->restore();
} else {
context->drawEllipse(IntRect(inner.x() + 5, inner.y() + 5, inner.width() - 10, inner.height() - 10));
}
}
}
return false;
}
示例2: draw
void HUDSlider::draw(GraphicsContext& context)
{
// Draw gutter
IntSize radius(m_rect.height() / 2, m_rect.height() / 2);
context.fillRoundedRect(FloatRoundedRect(m_rect, radius, radius, radius, radius), Color(sliderGutterColor), ColorSpaceDeviceRGB);
// Draw button
context.setStrokeColor(Color(sliderButtonColor), ColorSpaceDeviceRGB);
context.setFillColor(Color(sliderButtonColor), ColorSpaceDeviceRGB);
if (m_buttonShape == RoundButton) {
context.drawEllipse(IntRect(m_rect.location().x() + m_buttonPosition, m_rect.location().y() - (m_buttonSize - m_rect.height()) / 2, m_buttonSize, m_buttonSize));
return;
}
// Draw a diamond
FloatPoint points[4];
float half = static_cast<float>(m_buttonSize) / 2;
points[0].setX(m_rect.location().x() + m_buttonPosition + half);
points[0].setY(m_rect.location().y());
points[1].setX(m_rect.location().x() + m_buttonPosition + m_buttonSize);
points[1].setY(m_rect.location().y() + half);
points[2].setX(m_rect.location().x() + m_buttonPosition + half);
points[2].setY(m_rect.location().y() + m_buttonSize);
points[3].setX(m_rect.location().x() + m_buttonPosition);
points[3].setY(m_rect.location().y() + half);
context.drawConvexPolygon(4, points, true);
}
示例3: draw
void HUDSlider::draw(GraphicsContext& context)
{
// Draw gutter
IntSize radius(m_rect.height() / 2, m_rect.height() / 2);
context.fillRoundedRect(FloatRoundedRect(m_rect, radius, radius, radius, radius), Color(sliderGutterColor));
// Draw button
context.setStrokeColor(Color(sliderButtonColor));
context.setFillColor(Color(sliderButtonColor));
if (m_buttonShape == RoundButton) {
context.drawEllipse(IntRect(m_rect.location().x() + m_buttonPosition, m_rect.location().y() - (m_buttonSize - m_rect.height()) / 2, m_buttonSize, m_buttonSize));
return;
}
// Draw a diamond
float half = static_cast<float>(m_buttonSize) / 2;
Vector<FloatPoint> points = {
FloatPoint(m_rect.location().x() + m_buttonPosition + half, m_rect.location().y()),
FloatPoint(m_rect.location().x() + m_buttonPosition + m_buttonSize, m_rect.location().y() + half),
FloatPoint(m_rect.location().x() + m_buttonPosition + half, m_rect.location().y() + m_buttonSize),
FloatPoint(m_rect.location().x() + m_buttonPosition, m_rect.location().y() + half)
};
context.drawPath(Path::polygonPathFromPoints(points));
}
示例4: apply
void DrawEllipse::apply(GraphicsContext& context) const
{
context.drawEllipse(m_rect);
}
示例5: paint
void RenderListMarker::paint(PaintInfo& paintInfo, int tx, int ty)
{
if (paintInfo.phase != PaintPhaseForeground)
return;
if (style()->visibility() != VISIBLE)
return;
IntRect marker = getRelativeMarkerRect();
marker.move(tx, ty);
IntRect box(tx + m_x, ty + m_y, m_width, m_height);
if (box.y() > paintInfo.rect.bottom() || box.y() + box.height() < paintInfo.rect.y())
return;
if (hasBoxDecorations())
paintBoxDecorations(paintInfo, box.x(), box.y());
GraphicsContext* context = paintInfo.context;
context->setFont(style()->font());
if (isImage()) {
#if PLATFORM(MAC)
if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
paintCustomHighlight(tx, ty, style()->highlight(), true);
#endif
context->drawImage(m_image->image(), marker.location());
if (selectionState() != SelectionNone)
context->fillRect(selectionRect(), selectionBackgroundColor());
return;
}
#if PLATFORM(MAC)
// FIXME: paint gap between marker and list item proper
if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
paintCustomHighlight(tx, ty, style()->highlight(), true);
#endif
if (selectionState() != SelectionNone)
context->fillRect(selectionRect(), selectionBackgroundColor());
const Color color(style()->color());
context->setStrokeColor(color);
context->setStrokeStyle(SolidStroke);
context->setStrokeThickness(1.0f);
context->setFillColor(color);
switch (style()->listStyleType()) {
case DISC:
context->drawEllipse(marker);
return;
case CIRCLE:
context->setFillColor(Color::transparent);
context->drawEllipse(marker);
return;
case SQUARE:
context->drawRect(marker);
return;
case LNONE:
return;
case ARMENIAN:
case CJK_IDEOGRAPHIC:
case DECIMAL_LEADING_ZERO:
case GEORGIAN:
case HEBREW:
case HIRAGANA:
case HIRAGANA_IROHA:
case KATAKANA:
case KATAKANA_IROHA:
case LDECIMAL:
case LOWER_ALPHA:
case LOWER_GREEK:
case LOWER_LATIN:
case LOWER_ROMAN:
case UPPER_ALPHA:
case UPPER_LATIN:
case UPPER_ROMAN:
break;
}
if (m_text.isEmpty())
return;
TextRun textRun(m_text);
// Text is not arbitrary. We can judge whether it's RTL from the first character,
// and we only need to handle the direction RightToLeft for now.
bool textNeedsReversing = direction(m_text[0]) == RightToLeft;
Vector<UChar> reversedText;
if (textNeedsReversing) {
int length = m_text.length();
reversedText.resize(length);
for (int i = 0; i < length; ++i)
reversedText[length - i - 1] = m_text[i];
textRun = TextRun(reversedText.data(), length);
}
const Font& font = style()->font();
if (style()->direction() == LTR) {
int width = font.width(textRun);
//.........这里部分代码省略.........