本文整理汇总了C++中FloatPoint::y方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatPoint::y方法的具体用法?C++ FloatPoint::y怎么用?C++ FloatPoint::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatPoint
的用法示例。
在下文中一共展示了FloatPoint::y方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTextWithSpacing
void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
{
graphicsContext->save();
wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
wxFont* wxfont = font->getWxFont();
graphicsContext->setFillColor(graphicsContext->fillColor(), DeviceColorSpace);
CGContextRef cgContext = static_cast<CGContextRef>(dc->GetGraphicsContext()->GetNativeContext());
CGFontRef cgFont;
#ifdef wxOSX_USE_CORE_TEXT && wxOSX_USE_CORE_TEXT
cgFont = CTFontCopyGraphicsFont((CTFontRef)wxfont->OSXGetCTFont(), NULL);
#else
ATSFontRef fontRef;
fontRef = FMGetATSFontRefFromFont(wxfont->MacGetATSUFontID());
if (fontRef)
cgFont = CGFontCreateWithPlatformFont((void*)&fontRef);
#endif
CGContextSetFont(cgContext, cgFont);
CGContextSetFontSize(cgContext, wxfont->GetPointSize());
CGFloat red, green, blue, alpha;
graphicsContext->fillColor().getRGBA(red, green, blue, alpha);
CGContextSetRGBFillColor(cgContext, red, green, blue, alpha);
CGAffineTransform matrix = CGAffineTransformIdentity;
matrix.b = -matrix.b;
matrix.d = -matrix.d;
CGContextSetTextMatrix(cgContext, matrix);
CGContextSetTextPosition(cgContext, point.x(), point.y());
const FloatSize* advanceSizes = static_cast<const FloatSize*>(glyphBuffer.advances(from));
int size = glyphBuffer.size() - from;
CGSize sizes[size];
CGGlyph glyphs[numGlyphs];
// if the function doesn't exist, we're probably on tiger and need to grab the
// function under its old name, CGFontGetGlyphsForUnicodes
if (!CGFontGetGlyphsForUnichars)
CGFontGetGlyphsForUnichars = (CGFontGetGlyphsForUnicharsPtr)dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnicodes");
// Let's make sure we got the function under one name or another!
ASSERT(CGFontGetGlyphsForUnichars);
CGFontGetGlyphsForUnichars(cgFont, glyphBuffer.glyphs(from), glyphs, numGlyphs);
for (int i = 0; i < size; i++) {
FloatSize fsize = advanceSizes[i];
sizes[i] = CGSizeMake(fsize.width(), fsize.height());
}
CGContextShowGlyphsWithAdvances(cgContext, glyphs, sizes, numGlyphs);
if (cgFont)
CGFontRelease(cgFont);
graphicsContext->restore();
}
示例2: drawGlyphs
void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs,
const FloatPoint& point, const FloatRect& textRect) const
{
SkScalar x = SkFloatToScalar(point.x());
SkScalar y = SkFloatToScalar(point.y());
// ENABLE_OPENTYPE_VERTICAL is not enabled on MACOSX
#if !OS(MACOSX)
const OpenTypeVerticalData* verticalData = font->verticalData();
if (font->platformData().orientation() == Vertical && verticalData) {
SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
SkPoint* pos = storage.get();
AffineTransform savedMatrix = gc->getCTM();
gc->concatCTM(AffineTransform(0, -1, 1, 0, point.x(), point.y()));
gc->concatCTM(AffineTransform(1, 0, 0, 1, -point.x(), -point.y()));
const unsigned kMaxBufferLength = 256;
Vector<FloatPoint, kMaxBufferLength> translations;
const FontMetrics& metrics = font->fontMetrics();
SkScalar verticalOriginX = SkFloatToScalar(point.x() + metrics.floatAscent() - metrics.floatAscent(IdeographicBaseline));
float horizontalOffset = point.x();
unsigned glyphIndex = 0;
while (glyphIndex < numGlyphs) {
unsigned chunkLength = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex);
translations.resize(chunkLength);
verticalData->getVerticalTranslationsForGlyphs(font, &glyphs[0], chunkLength, reinterpret_cast<float*>(&translations[0]));
x = verticalOriginX;
y = SkFloatToScalar(point.y() + horizontalOffset - point.x());
float currentWidth = 0;
for (unsigned i = 0; i < chunkLength; ++i, ++glyphIndex) {
pos[i].set(
x + SkIntToScalar(lroundf(translations[i].x())),
y + -SkIntToScalar(-lroundf(currentWidth - translations[i].y())));
currentWidth += glyphBuffer.advanceAt(from + glyphIndex);
}
horizontalOffset += currentWidth;
paintGlyphs(gc, font, glyphs, chunkLength, pos, textRect);
}
gc->setCTM(savedMatrix);
return;
}
#endif
if (!glyphBuffer.hasOffsets()) {
SkAutoSTMalloc<64, SkScalar> storage(numGlyphs);
SkScalar* xpos = storage.get();
const float* adv = glyphBuffer.advances(from);
for (unsigned i = 0; i < numGlyphs; i++) {
xpos[i] = x;
x += SkFloatToScalar(adv[i]);
}
const Glyph* glyphs = glyphBuffer.glyphs(from);
paintGlyphsHorizontal(gc, font, glyphs, numGlyphs, xpos, SkFloatToScalar(y), textRect);
return;
}
// FIXME: text rendering speed:
// Android has code in their WebCore fork to special case when the
// GlyphBuffer has no advances other than the defaults. In that case the
// text drawing can proceed faster. However, it's unclear when those
// patches may be upstreamed to WebKit so we always use the slower path
// here.
SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
SkPoint* pos = storage.get();
const FloatSize* offsets = glyphBuffer.offsets(from);
const float* advances = glyphBuffer.advances(from);
SkScalar advanceSoFar = SkFloatToScalar(0);
for (unsigned i = 0; i < numGlyphs; i++) {
pos[i].set(
x + SkFloatToScalar(offsets[i].width()) + advanceSoFar,
y + SkFloatToScalar(offsets[i].height()));
advanceSoFar += SkFloatToScalar(advances[i]);
}
const Glyph* glyphs = glyphBuffer.glyphs(from);
paintGlyphs(gc, font, glyphs, numGlyphs, pos, textRect);
}
示例3: addArc
void Path::addArc(const FloatPoint& center, float radius, float startAngle, float endAngle, bool anticlockwise)
{
// The OpenVG spec says nothing about inf as radius or start/end angle.
// WebKit seems to pass those (e.g. https://bugs.webkit.org/show_bug.cgi?id=16449),
// so abort instead of risking undefined behavior.
if (!isfinite(radius) || !isfinite(startAngle) || !isfinite(endAngle))
return;
// For some reason, the HTML 5 spec defines the angle as going clockwise
// from the positive X axis instead of going standard anticlockwise.
// So let's make it a proper angle in order to keep sanity.
startAngle = fmod((2.0 * piDouble) - startAngle, 2.0 * piDouble);
endAngle = fmod((2.0 * piDouble) - endAngle, 2.0 * piDouble);
// Make it so that endAngle > startAngle. fmod() above takes care of
// keeping the difference below 360 degrees.
if (endAngle <= startAngle)
endAngle += 2.0 * piDouble;
const VGfloat angleDelta = anticlockwise
? (endAngle - startAngle)
: (startAngle - endAngle + (2.0 * piDouble));
// OpenVG uses endpoint parameterization while this method receives its
// values in center parameterization. It lacks an ellipse rotation
// parameter so we use 0 for that, and also the radius is only a single
// value which makes for rh == rv. In order to convert from endpoint to
// center parameterization, we use the formulas from the OpenVG/SVG specs:
// (x,y) = (cos rot, -sin rot; sin rot, -cos rot) * (rh * cos angle, rv * sin angle) + (center.x, center.y)
// rot is 0, which simplifies this a bit:
// (x,y) = (1, 0; 0, -1) * (rh * cos angle, rv * sin angle) + (center.x, center.y)
// = (1 * rh * cos angle + 0 * rv * sin angle, 0 * rh * cos angle + -1 * rv * sin angle) + (center.x, center.y)
// = (rh * cos angle, -rv * sin angle) + (center.x, center.y)
// (Set angle = {startAngle, endAngle} to retrieve the respective endpoints.)
const VGfloat startX = radius * cos(startAngle) + center.x();
const VGfloat startY = -radius * sin(startAngle) + center.y();
const VGfloat endX = radius * cos(endAngle) + center.x();
const VGfloat endY = -radius * sin(endAngle) + center.y();
// Fa: large arc flag, makes the difference between SCWARC_TO and LCWARC_TO
// respectively SCCWARC_TO and LCCWARC_TO arcs.
const bool largeArc = (angleDelta > piDouble);
// Fs: sweep flag, specifying whether the arc is drawn in increasing (true)
// or decreasing (0) direction. No need to calculate this value, as it
// we already get it passed as a parameter (Fs == !anticlockwise).
// Translate the large arc and sweep flags into an OpenVG segment command.
// As OpenVG thinks of everything upside down, we need to reverse the
// anticlockwise parameter in order to get the specified rotation.
const VGubyte segmentCommand = !anticlockwise
? (largeArc ? VG_LCCWARC_TO_ABS : VG_SCCWARC_TO_ABS)
: (largeArc ? VG_LCWARC_TO_ABS : VG_SCWARC_TO_ABS);
// So now, we've got all the parameters in endpoint parameterization format
// as OpenVG requires it. Which means we can just pass it like this.
const VGubyte pathSegments[] = {
hasCurrentPoint() ? VG_LINE_TO_ABS : VG_MOVE_TO_ABS,
segmentCommand
};
const VGfloat pathData[] = {
startX, startY,
radius, radius, 0, endX, endY
};
m_path->makeCompatibleContextCurrent();
vgAppendPathData(m_path->vgPath(), 2, pathSegments, pathData);
ASSERT_VG_NO_ERROR();
m_path->m_currentPoint.setX(endX);
m_path->m_currentPoint.setY(endY);
}
示例4: drawEmphasisMarksForComplexText
void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRunPaintInfo& runInfo, const AtomicString& mark, const FloatPoint& point) const
{
GlyphBuffer glyphBuffer;
float initialAdvance = getGlyphsAndAdvancesForComplexText(runInfo, glyphBuffer, ForTextEmphasis);
if (glyphBuffer.isEmpty())
return;
drawEmphasisMarks(context, runInfo, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
}
示例5: drawLineForDocumentMarker
void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float width, DocumentMarkerLineStyle style)
{
if (paintingDisabled())
return;
if (style != DocumentMarkerSpellingLineStyle && style != DocumentMarkerGrammarLineStyle)
return;
// These are the same for misspelling or bad grammar
const int patternHeight = 3; // 3 rows
ASSERT(cMisspellingLineThickness == patternHeight);
const int patternWidth = 4; // 4 pixels
ASSERT(patternWidth == cMisspellingLinePatternWidth);
// Make sure to draw only complete dots.
// NOTE: Code here used to shift the underline to the left and increase the width
// to make sure everything gets underlined, but that results in drawing out of
// bounds (e.g. when at the edge of a view) and could make it appear that the
// space between adjacent misspelled words was underlined.
// allow slightly more considering that the pattern ends with a transparent pixel
float widthMod = fmodf(width, patternWidth);
if (patternWidth - widthMod > cMisspellingLinePatternGapWidth)
width -= widthMod;
// Draw the underline
CGContextRef context = platformContext();
CGContextSaveGState(context);
const Color& patternColor = style == DocumentMarkerGrammarLineStyle ? grammarPatternColor() : spellingPatternColor();
setCGStrokeColor(context, patternColor);
wkSetPatternPhaseInUserSpace(context, point);
CGContextSetBlendMode(context, kCGBlendModeNormal);
// 3 rows, each offset by half a pixel for blending purposes
const CGPoint upperPoints [] = {{point.x(), point.y() + patternHeight - 2.5 }, {point.x() + width, point.y() + patternHeight - 2.5}};
const CGPoint middlePoints [] = {{point.x(), point.y() + patternHeight - 1.5 }, {point.x() + width, point.y() + patternHeight - 1.5}};
const CGPoint lowerPoints [] = {{point.x(), point.y() + patternHeight - 0.5 }, {point.x() + width, point.y() + patternHeight - 0.5 }};
// Dash lengths for the top and bottom of the error underline are the same.
// These are magic.
static const CGFloat edge_dash_lengths[] = {2.0f, 2.0f};
static const CGFloat middle_dash_lengths[] = { 2.76f, 1.24f };
static const CGFloat edge_offset = -(edge_dash_lengths[1] - 1.0f) / 2.0f;
static const CGFloat middle_offset = -(middle_dash_lengths[1] - 1.0f) / 2.0f;
// Line opacities. Once again, these are magic.
const float upperOpacity = 0.33f;
const float middleOpacity = 0.75f;
const float lowerOpacity = 0.88f;
//Top line
CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths));
CGContextSetAlpha(context, upperOpacity);
CGContextStrokeLineSegments(context, upperPoints, 2);
// Middle line
CGContextSetLineDash(context, middle_offset, middle_dash_lengths, WTF_ARRAY_LENGTH(middle_dash_lengths));
CGContextSetAlpha(context, middleOpacity);
CGContextStrokeLineSegments(context, middlePoints, 2);
// Bottom line
CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths));
CGContextSetAlpha(context, lowerOpacity);
CGContextStrokeLineSegments(context, lowerPoints, 2);
CGContextRestoreGState(context);
}
示例6: defaultEventHandler
void HTMLAnchorElement::defaultEventHandler(Event* evt)
{
// React on clicks and on keypresses.
// Don't make this KEYUP_EVENT again, it makes khtml follow links it shouldn't,
// when pressing Enter in the combo.
if (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) {
MouseEvent* e = 0;
if (evt->type() == eventNames().clickEvent && evt->isMouseEvent())
e = static_cast<MouseEvent*>(evt);
KeyboardEvent* k = 0;
if (evt->type() == eventNames().keydownEvent && evt->isKeyboardEvent())
k = static_cast<KeyboardEvent*>(evt);
if (e && e->button() == RightButton) {
HTMLElement::defaultEventHandler(evt);
return;
}
// If the link is editable, then we need to check the settings to see whether or not to follow the link
if (isContentEditable()) {
EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
if (Settings* settings = document()->settings())
editableLinkBehavior = settings->editableLinkBehavior();
switch (editableLinkBehavior) {
// Always follow the link (Safari 2.0 behavior)
default:
case EditableLinkDefaultBehavior:
case EditableLinkAlwaysLive:
break;
case EditableLinkNeverLive:
HTMLElement::defaultEventHandler(evt);
return;
// If the selection prior to clicking on this link resided in the same editable block as this link,
// and the shift key isn't pressed, we don't want to follow the link
case EditableLinkLiveWhenNotFocused:
if (e && !e->shiftKey() && m_rootEditableElementForSelectionOnMouseDown == rootEditableElement()) {
HTMLElement::defaultEventHandler(evt);
return;
}
break;
// Only follow the link if the shift key is down (WinIE/Firefox behavior)
case EditableLinkOnlyLiveWithShiftKey:
if (e && !e->shiftKey()) {
HTMLElement::defaultEventHandler(evt);
return;
}
break;
}
}
if (k) {
if (k->keyIdentifier() != "Enter") {
HTMLElement::defaultEventHandler(evt);
return;
}
evt->setDefaultHandled();
dispatchSimulatedClick(evt);
return;
}
String url = deprecatedParseURL(getAttribute(hrefAttr));
ASSERT(evt->target());
ASSERT(evt->target()->toNode());
if (evt->target()->toNode()->hasTagName(imgTag)) {
HTMLImageElement* img = static_cast<HTMLImageElement*>(evt->target()->toNode());
if (img && img->isServerMap()) {
RenderImage* r = toRenderImage(img->renderer());
if (r && e) {
// FIXME: broken with transforms
FloatPoint absPos = r->localToAbsolute();
int x = e->pageX() - absPos.x();
int y = e->pageY() - absPos.y();
url += "?";
url += String::number(x);
url += ",";
url += String::number(y);
} else {
evt->setDefaultHandled();
HTMLElement::defaultEventHandler(evt);
return;
}
}
}
if (!evt->defaultPrevented() && document()->frame())
document()->frame()->loader()->urlSelected(document()->completeURL(url), getAttribute(targetAttr), evt, false, false, true, hasRel(RelationNoReferrer) ? NoReferrer : SendReferrer);
evt->setDefaultHandled();
} else if (isLink() && isContentEditable()) {
// This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
// for the LiveWhenNotFocused editable link behavior
if (evt->type() == eventNames().mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
MouseEvent* e = static_cast<MouseEvent*>(evt);
//.........这里部分代码省略.........