当前位置: 首页>>代码示例>>C++>>正文


C++ FloatPoint::setX方法代码示例

本文整理汇总了C++中FloatPoint::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatPoint::setX方法的具体用法?C++ FloatPoint::setX怎么用?C++ FloatPoint::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FloatPoint的用法示例。


在下文中一共展示了FloatPoint::setX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawComplexText

void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
                           int from, int to) const
{
    if (to < 0)
        to = run.length();
    if (from < 0)
        from = 0;

    TextRunComponents components;
    int w = generateComponents(&components, *this, run);

    int curPos = 0;
    for (int i = 0; i < (int)components.size(); ++i) {
        const TextRunComponent& comp = components.at(i);
        int len = comp.textLength();
        int curEnd = curPos + len;
        if (curPos < to && from < curEnd && !comp.isSpace()) {
            FloatPoint pt = point;
            if (run.rtl())
                pt.setX(point.x() + w - comp.m_offset - comp.m_width);
            else
                pt.setX(point.x() + comp.m_offset);
            drawSimpleText(context, comp.m_textRun, pt, from - curPos, std::min(to, curEnd) - curPos);
        }
        curPos += len;
        if (from < curPos)
            from = curPos;
    }
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:29,代码来源:FontWinCE.cpp

示例2: findIntersection

bool findIntersection(const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& d1, const FloatPoint& d2, FloatPoint& intersection) 
{
    float pOffset = 0;
    float pSlope = findSlope(p1, p2, pOffset);

    float dOffset = 0;
    float dSlope = findSlope(d1, d2, dOffset);

    if (dSlope == pSlope)
        return false;
    
    if (pSlope == std::numeric_limits<float>::infinity()) {
        intersection.setX(p1.x());
        intersection.setY(dSlope * intersection.x() + dOffset);
        return true;
    }
    if (dSlope == std::numeric_limits<float>::infinity()) {
        intersection.setX(d1.x());
        intersection.setY(pSlope * intersection.x() + pOffset);
        return true;
    }
    
    // Find x at intersection, where ys overlap; x = (c' - c) / (m - m')
    intersection.setX((dOffset - pOffset) / (pSlope - dSlope));
    intersection.setY(pSlope * intersection.x() + pOffset);
    return true;
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:27,代码来源:FloatPoint.cpp

示例3: adjustLineToPixelBoundaries

void GraphicsContext::adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle penStyle)
{
    // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
    // works out.  For example, with a border width of 3, WebKit will pass us (y1+y2)/2, e.g.,
    // (50+53)/2 = 103/2 = 51 when we want 51.5.  It is always true that an even width gave
    // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
    if (penStyle == DottedStroke || penStyle == DashedStroke) {
        if (p1.x() == p2.x()) {
            p1.setY(p1.y() + strokeWidth);
            p2.setY(p2.y() - strokeWidth);
        } else {
            p1.setX(p1.x() + strokeWidth);
            p2.setX(p2.x() - strokeWidth);
        }
    }

    if (static_cast<int>(strokeWidth) % 2) { //odd
        if (p1.x() == p2.x()) {
            // We're a vertical line.  Adjust our x.
            p1.setX(p1.x() + 0.5f);
            p2.setX(p2.x() + 0.5f);
        } else {
            // We're a horizontal line. Adjust our y.
            p1.setY(p1.y() + 0.5f);
            p2.setY(p2.y() + 0.5f);
        }
    }
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:28,代码来源:GraphicsContext.cpp

示例4: floatPointForCenterCoordinate

FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& centerX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize)
{
    FloatPoint p;
    float offset = floatValueForLength(centerX.length(), boxSize.width());
    switch (centerX.keyword()) {
    case BasicShapeCenterCoordinate::None:
    case BasicShapeCenterCoordinate::Left:
        p.setX(offset);
        break;
    case BasicShapeCenterCoordinate::Right:
        p.setX(boxSize.width() - offset);
        break;
    default:
        ASSERT_NOT_REACHED();
    }

    offset = floatValueForLength(centerY.length(), boxSize.height());
    switch (centerY.keyword()) {
    case BasicShapeCenterCoordinate::None:
    case BasicShapeCenterCoordinate::Top:
        p.setY(offset);
        break;
    case BasicShapeCenterCoordinate::Bottom:
        p.setY(boxSize.height() - offset);
        break;
    default:
        ASSERT_NOT_REACHED();
    }

    return p;
}
开发者ID:wangshijun,项目名称:Blink,代码行数:31,代码来源:BasicShapeFunctions.cpp

示例5: resolvePoint

FloatPoint CSSGradientValue::resolvePoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, const IntSize& size, float zoomFactor)
{
    FloatPoint result;
    if (first->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
        result.setX(first->getFloatValue() * zoomFactor);
    else if (first->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
        result.setX(first->getFloatValue() / 100.f * size.width());
    if (second->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
        result.setY(second->getFloatValue() * zoomFactor);
    else if (second->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
        result.setY(second->getFloatValue() / 100.f * size.height());

    return result;
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:14,代码来源:CSSGradientValue.cpp

示例6:

void FullscreenVideoController::LayerClient::platformCALayerLayoutSublayersOfLayer(PlatformCALayer* layer) 
{
    ASSERT_ARG(layer, layer == m_parent->m_rootChild);

    HTMLVideoElement* videoElement = m_parent->m_videoElement.get();
    if (!videoElement)
        return;


    PlatformCALayer* videoLayer = PlatformCALayer::platformCALayer(videoElement->platformLayer());
    if (!videoLayer || videoLayer->superlayer() != layer)
        return;

    FloatRect layerBounds = layer->bounds();

    FloatSize videoSize = videoElement->player()->naturalSize();
    float scaleFactor;
    if (videoSize.aspectRatio() > layerBounds.size().aspectRatio())
        scaleFactor = layerBounds.width() / videoSize.width();
    else
        scaleFactor = layerBounds.height() / videoSize.height();
    videoSize.scale(scaleFactor);

    // Calculate the centered position based on the videoBounds and layerBounds:
    FloatPoint videoPosition;
    FloatPoint videoOrigin;
    videoOrigin.setX((layerBounds.width() - videoSize.width()) * 0.5);
    videoOrigin.setY((layerBounds.height() - videoSize.height()) * 0.5);
    videoLayer->setPosition(videoOrigin);
    videoLayer->setBounds(FloatRect(FloatPoint(), videoSize));
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:31,代码来源:FullscreenVideoController.cpp

示例7: advance

void SVGGlyphToPathTranslator::advance()
{
    do {
        if (m_glyph) {
            float advance = m_glyphBuffer.advanceAt(m_index).width();
            if (m_isVerticalText)
                m_currentPoint.move(0, advance);
            else
                m_currentPoint.move(advance, 0);
        }

        ++m_index;
        if (m_index >= m_stoppingPoint || !m_glyphBuffer.fontDataAt(m_index)->isSVGFont())
            break;
        m_glyph = m_glyphBuffer.glyphAt(m_index);
        if (!m_glyph)
            continue;
        m_svgGlyph = m_fontElement.svgGlyphForGlyph(m_glyph);
        ASSERT(!m_svgGlyph.isPartOfLigature);
        ASSERT(m_svgGlyph.tableEntry == m_glyph);
        SVGGlyphElement::inheritUnspecifiedAttributes(m_svgGlyph, &m_svgFontData);
    } while ((!m_glyph || m_svgGlyph.pathData.isEmpty()) && m_index < m_stoppingPoint);

    if (containsMorePaths() && m_isVerticalText) {
        m_glyphOrigin.setX(m_svgGlyph.verticalOriginX * m_scale);
        m_glyphOrigin.setY(m_svgGlyph.verticalOriginY * m_scale);
    }
}
开发者ID:highweb-project,项目名称:highweb-parallelwebkit,代码行数:28,代码来源:SVGTextRunRenderingContext.cpp

示例8: squaredDistanceToClosestPoint

static float squaredDistanceToClosestPoint(const FloatRect& rect, const FloatPoint& point)
{
    FloatPoint closestPoint;
    closestPoint.setX(std::max(std::min(point.x(), rect.maxX()), rect.x()));
    closestPoint.setY(std::max(std::min(point.y(), rect.maxY()), rect.y()));
    return (point - closestPoint).diagonalLengthSquared();
}
开发者ID:joone,项目名称:blink-crosswalk,代码行数:7,代码来源:LayoutSVGInlineText.cpp

示例9: updateCurrentPoint

static void updateCurrentPoint(FloatPoint& currentPoint, const PathSegmentData& segment)
{
    switch (segment.command) {
    case PathSegMoveToRel:
    case PathSegLineToRel:
    case PathSegCurveToCubicRel:
    case PathSegCurveToQuadraticRel:
    case PathSegArcRel:
    case PathSegLineToHorizontalRel:
    case PathSegLineToVerticalRel:
    case PathSegCurveToCubicSmoothRel:
    case PathSegCurveToQuadraticSmoothRel:
        currentPoint += segment.targetPoint;
        break;
    case PathSegMoveToAbs:
    case PathSegLineToAbs:
    case PathSegCurveToCubicAbs:
    case PathSegCurveToQuadraticAbs:
    case PathSegArcAbs:
    case PathSegCurveToCubicSmoothAbs:
    case PathSegCurveToQuadraticSmoothAbs:
        currentPoint = segment.targetPoint;
        break;
    case PathSegLineToHorizontalAbs:
        currentPoint.setX(segment.targetPoint.x());
        break;
    case PathSegLineToVerticalAbs:
        currentPoint.setY(segment.targetPoint.y());
        break;
    case PathSegClosePath:
        break;
    default:
        ASSERT_NOT_REACHED();
    }
}
开发者ID:joone,项目名称:blink-crosswalk,代码行数:35,代码来源:SVGPathBlender.cpp

示例10: mouseEventOffsetToThumb

FloatPoint RenderSlider::mouseEventOffsetToThumb(MouseEvent* evt)
{
    ASSERT(m_thumb && m_thumb->renderer());
    FloatPoint localPoint = m_thumb->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true);
    IntRect thumbBounds = m_thumb->renderBox()->borderBoxRect();
    FloatPoint offset;
    offset.setX(thumbBounds.x() + thumbBounds.width() / 2 - localPoint.x());
    offset.setY(thumbBounds.y() + thumbBounds.height() / 2 - localPoint.y());
    return offset;
}
开发者ID:flying-dutchmen,项目名称:3DS_w3Browser,代码行数:10,代码来源:RenderSlider.cpp

示例11: defaultEventHandler

void SliderThumbElement::defaultEventHandler(Event* event)
{
    if (!event->isMouseEvent()) {
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    bool isLeftButton = mouseEvent->button() == LeftButton;
    const AtomicString& eventType = event->type();

    if (eventType == eventNames().mousedownEvent && isLeftButton) {
        if (document()->frame() && renderer()) {
            RenderSlider* slider = toRenderSlider(renderer()->parent());
            if (slider) {
                if (slider->mouseEventIsInThumb(mouseEvent)) {
                    // We selected the thumb, we want the cursor to always stay at
                    // the same position relative to the thumb.
                    m_offsetToThumb = slider->mouseEventOffsetToThumb(mouseEvent);
                } else {
                    // We are outside the thumb, move the thumb to the point were
                    // we clicked. We'll be exactly at the center of the thumb.
                    m_offsetToThumb.setX(0);
                    m_offsetToThumb.setY(0);
                }

                m_inDragMode = true;
                document()->frame()->eventHandler()->setCapturingMouseEventsNode(m_shadowParent);
                event->setDefaultHandled();
                return;
            }
        }
    } else if (eventType == eventNames().mouseupEvent && isLeftButton) {
        if (m_inDragMode) {
            if (Frame* frame = document()->frame())
                frame->eventHandler()->setCapturingMouseEventsNode(0);      
            m_inDragMode = false;
            event->setDefaultHandled();
            return;
        }
    } else if (eventType == eventNames().mousemoveEvent) {
        if (m_inDragMode && renderer() && renderer()->parent()) {
            RenderSlider* slider = toRenderSlider(renderer()->parent());
            if (slider) {
                FloatPoint curPoint = slider->absoluteToLocal(mouseEvent->absoluteLocation(), false, true);
                IntPoint eventOffset(curPoint.x() + m_offsetToThumb.x(), curPoint.y() + m_offsetToThumb.y());
                slider->setValueForPosition(slider->positionForOffset(eventOffset));
                event->setDefaultHandled();
                return;
            }
        }
    }

    HTMLDivElement::defaultEventHandler(event);
}
开发者ID:flying-dutchmen,项目名称:3DS_w3Browser,代码行数:55,代码来源:RenderSlider.cpp

示例12: xAttrSetter

static void xAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.SVGPoint.x._set");
    V8SVGPODTypeWrapper<FloatPoint>* wrapper = V8SVGPODTypeWrapper<FloatPoint>::toNative(info.Holder());
    FloatPoint impInstance = *wrapper;
    FloatPoint* imp = &impInstance;
    float v = static_cast<float>(value->NumberValue());
    imp->setX(v);
    wrapper->commitChange(*imp, V8Proxy::svgContext(wrapper));
    return;
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:11,代码来源:V8SVGPoint.cpp

示例13: rightMostCornerToVector

static inline FloatPoint rightMostCornerToVector(const FloatRect& rect, const FloatSize& vector)
{
    // Return the corner of the rectangle that if it is to the left of the vector
    // would mean all of the rectangle is to the left of the vector.
    // The vector here represents the side between two points in a clockwise convex polygon.
    //
    //  Q  XXX
    // QQQ XXX   If the lower left corner of X is left of the vector that goes from the top corner of Q to
    //  QQQ      the right corner of Q, then all of X is left of the vector, and intersection impossible.
    //   Q
    //
    FloatPoint point;
    if (vector.width() >= 0)
        point.setY(rect.maxY());
    else
        point.setY(rect.y());
    if (vector.height() >= 0)
        point.setX(rect.x());
    else
        point.setX(rect.maxX());
    return point;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:22,代码来源:FloatQuad.cpp

示例14: drawGlyphBuffer

void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, FloatPoint& point) const
{
#if !ENABLE(SVG_FONTS)
    UNUSED_PARAM(run);
#endif

    // Draw each contiguous run of glyphs that use the same font data.
    const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
    FloatSize offset = glyphBuffer.offsetAt(0);
    FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height());
    float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
    float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
    int lastFrom = 0;
    int nextGlyph = 1;
#if ENABLE(SVG_FONTS)
    TextRun::RenderingContext* renderingContext = run.renderingContext();
#endif
    while (nextGlyph < glyphBuffer.size()) {
        const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
        FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph);

        if (nextFontData != fontData || nextOffset != offset) {
#if ENABLE(SVG_FONTS)
            if (renderingContext && fontData->isSVGFont())
                renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
            else
#endif
                drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);

            lastFrom = nextGlyph;
            fontData = nextFontData;
            offset = nextOffset;
            startPoint.setX(nextX);
            startPoint.setY(nextY);
        }
        nextX += glyphBuffer.advanceAt(nextGlyph).width();
        nextY += glyphBuffer.advanceAt(nextGlyph).height();
        nextGlyph++;
    }

#if ENABLE(SVG_FONTS)
    if (renderingContext && fontData->isSVGFont())
        renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
    else {
#endif
        drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
        point.setX(nextX);
#if ENABLE(SVG_FONTS)
    }
#endif
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:51,代码来源:FontFastPath.cpp

示例15: currentPoint

FloatPoint Path::currentPoint() const {
  if (m_path.countPoints() > 0) {
    SkPoint skResult;
    m_path.getLastPt(&skResult);
    FloatPoint result;
    result.setX(SkScalarToFloat(skResult.fX));
    result.setY(SkScalarToFloat(skResult.fY));
    return result;
  }

  // FIXME: Why does this return quietNaN? Other ports return 0,0.
  float quietNaN = std::numeric_limits<float>::quiet_NaN();
  return FloatPoint(quietNaN, quietNaN);
}
开发者ID:mirror,项目名称:chromium,代码行数:14,代码来源:Path.cpp


注:本文中的FloatPoint::setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。