本文整理汇总了C++中SkPoint::x方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPoint::x方法的具体用法?C++ SkPoint::x怎么用?C++ SkPoint::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPoint
的用法示例。
在下文中一共展示了SkPoint::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDraw
virtual void onDraw(SkCanvas* canvas) {
const char* lcd_text = "LCD";
const char* gray_text = "GRAY";
SkPaint paint;
paint.setAntiAlias(true);
paint.setLCDRenderText(true);
const struct {
SkPoint fLoc;
SkScalar fTextSize;
SkScalar fScale;
const char* fText;
} rec[] = {
{ { 10, 50 }, kLCDTextSizeLimit - 1, 1, lcd_text },
{ { 160, 50 }, kLCDTextSizeLimit + 1, 1, gray_text },
{ { 10, 100 }, kLCDTextSizeLimit / 2, 1.99f, lcd_text },
{ { 160, 100 }, kLCDTextSizeLimit / 2, 2.01f, gray_text },
};
for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
const SkPoint loc = rec[i].fLoc;
SkAutoCanvasRestore acr(canvas, true);
paint.setTextSize(rec[i].fTextSize);
ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y());
canvas->drawString(rec[i].fText, loc.x(), loc.y(), paint);
}
}
示例2: drawSceneColumn
void drawSceneColumn(SkCanvas* canvas, const SkPoint& pos, SkScalar scale, SkScalar localScale,
unsigned tileMode) {
SkMatrix ctm, localMatrix;
ctm.setTranslate(pos.x(), pos.y());
ctm.preScale(scale, scale);
localMatrix.setScale(localScale, localScale);
this->drawScene(canvas, ctm, localMatrix, tileMode);
ctm.setTranslate(pos.x(), pos.y() + fSceneSize * 1.2f * scale);
ctm.preScale(scale, scale);
localMatrix.setTranslate(fTileSize / 4, fTileSize / 4);
localMatrix.preScale(localScale, localScale);
this->drawScene(canvas, ctm, localMatrix, tileMode);
ctm.setTranslate(pos.x(), pos.y() + fSceneSize * 2.4f * scale);
ctm.preScale(scale, scale);
localMatrix.setRotate(45);
localMatrix.preScale(localScale, localScale);
this->drawScene(canvas, ctm, localMatrix, tileMode);
ctm.setTranslate(pos.x(), pos.y() + fSceneSize * 3.6f * scale);
ctm.preScale(scale, scale);
localMatrix.setSkew(1, 0);
localMatrix.preScale(localScale, localScale);
this->drawScene(canvas, ctm, localMatrix, tileMode);
ctm.setTranslate(pos.x(), pos.y() + fSceneSize * 4.8f * scale);
ctm.preScale(scale, scale);
localMatrix.setTranslate(fTileSize / 4, fTileSize / 4);
localMatrix.preRotate(45);
localMatrix.preScale(localScale, localScale);
this->drawScene(canvas, ctm, localMatrix, tileMode);
}
示例3: runAnimationTask
/**
* Called on a background thread. Here we can only modify fBackPaths.
*/
void runAnimationTask(double t, double dt, int w, int h) override {
const float tsec = static_cast<float>(t);
this->INHERITED::runAnimationTask(t, 0.5 * dt, w, h);
for (int i = 0; i < kNumPaths; ++i) {
const Glyph& glyph = fGlyphs[i];
const SkMatrix& backMatrix = fBackMatrices[i];
const Sk2f matrix[3] = {
Sk2f(backMatrix.getScaleX(), backMatrix.getSkewY()),
Sk2f(backMatrix.getSkewX(), backMatrix.getScaleY()),
Sk2f(backMatrix.getTranslateX(), backMatrix.getTranslateY())
};
SkPath* backpath = &fBackPaths[i];
backpath->reset();
backpath->setFillType(SkPath::kEvenOdd_FillType);
SkPath::RawIter iter(glyph.fPath);
SkPath::Verb verb;
SkPoint pts[4];
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
case SkPath::kMove_Verb: {
SkPoint pt = fWaves.apply(tsec, matrix, pts[0]);
backpath->moveTo(pt.x(), pt.y());
break;
}
case SkPath::kLine_Verb: {
SkPoint endpt = fWaves.apply(tsec, matrix, pts[1]);
backpath->lineTo(endpt.x(), endpt.y());
break;
}
case SkPath::kQuad_Verb: {
SkPoint controlPt = fWaves.apply(tsec, matrix, pts[1]);
SkPoint endpt = fWaves.apply(tsec, matrix, pts[2]);
backpath->quadTo(controlPt.x(), controlPt.y(), endpt.x(), endpt.y());
break;
}
case SkPath::kClose_Verb: {
backpath->close();
break;
}
case SkPath::kCubic_Verb:
case SkPath::kConic_Verb:
case SkPath::kDone_Verb:
SK_ABORT("Unexpected path verb");
break;
}
}
}
}
示例4: updateDom
void updateDom() {
const SkPoint corner = pos - SkPoint::Make(size.width() / 2, size.height() / 2);
objectNode->setX(SkSVGLength(corner.x()));
objectNode->setY(SkSVGLength(corner.y()));
// Simulate parallax shadow for a centered light source.
SkPoint shadowOffset = pos - SkPoint::Make(kBounds.centerX(), kBounds.centerY());
shadowOffset.scale(kShadowParallax);
const SkPoint shadowCorner = corner + shadowOffset;
shadowNode->setX(SkSVGLength(shadowCorner.x()));
shadowNode->setY(SkSVGLength(shadowCorner.y()));
}
示例5: cubicPath
SkPath cubicPath(SkPoint p1, SkPoint p2) {
SkASSERT(p1.y() == p2.y());
SkPath path;
path.moveTo(p1);
SkPoint p3 = SkPoint::Make((p1.x() + p2.x()) / 3.0f, p1.y() * 0.7f);
SkPoint p4 = SkPoint::Make(2.0f*(p1.x() + p2.x()) / 3.0f, p1.y() * 1.5f);
path.cubicTo(p3, p4, p2);
return path;
}
示例6: quadPath
SkPath quadPath(SkPoint p1, SkPoint p2) {
SkASSERT(p1.y() == p2.y());
SkPath path;
path.moveTo(p1);
path.lineTo(p2);
SkPoint p3 = SkPoint::Make((p1.x() + p2.x()) / 2.0f, p1.y() * 0.7f);
path.quadTo(p3, p1);
return path;
}
示例7: onContains
bool RRect::onContains(const SkPoint& p) const {
if (!fRRect.rect().contains(p.x(), p.y())) {
return false;
}
if (fRRect.isRect()) {
return true;
}
// TODO: no SkRRect::contains(x, y)
return fRRect.contains(SkRect::MakeLTRB(p.x() - SK_ScalarNearlyZero,
p.y() - SK_ScalarNearlyZero,
p.x() + SK_ScalarNearlyZero,
p.y() + SK_ScalarNearlyZero));
}
示例8: conv
static void convolve_gaussian_2d(GrDrawContext* drawContext,
const GrClip& clip,
const SkRect& dstRect,
const SkPoint& srcOffset,
GrTexture* texture,
int radiusX,
int radiusY,
SkScalar sigmaX,
SkScalar sigmaY,
const SkRect* srcBounds) {
SkMatrix localMatrix = SkMatrix::MakeTrans(-srcOffset.x(), -srcOffset.y());
SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1);
SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
GrPaint paint;
SkIRect bounds;
if (srcBounds) {
srcBounds->roundOut(&bounds);
} else {
bounds.setEmpty();
}
SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaussian(
texture, bounds, size, 1.0, 0.0, kernelOffset,
srcBounds ? GrTextureDomain::kDecal_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.addColorFragmentProcessor(conv);
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(), dstRect, localMatrix);
}
示例9: drawSets
void drawSets(SkCanvas* canvas) const {
SkAutoCanvasRestore acr(canvas, true);
const SkFilterQuality filters[] = {
kNone_SkFilterQuality,
kLow_SkFilterQuality,
kMedium_SkFilterQuality,
kHigh_SkFilterQuality
};
const bool AAs[] = { false, true };
SkPaint paint;
for (int i = 0; i < fSets.count(); ++i) {
auto& set = fSets[i];
SkPoint lastPt;
for (size_t j = 0; j < SK_ARRAY_COUNT(AAs); ++j) {
paint.setAntiAlias(AAs[j]);
for (size_t k = 0; k < SK_ARRAY_COUNT(filters); ++k) {
paint.setFilterQuality(filters[k]);
lastPt = drawSet(canvas, set, paint);
canvas->translate((kSegLen + 4) * set.fVector.y(),
(kSegLen + 4) * set.fVector.x());
}
}
canvas->translate(lastPt.x() + kSegLen,
- SkIntToScalar(kSegLen + 4) * SK_ARRAY_COUNT(filters) * SK_ARRAY_COUNT(AAs));
}
}
示例10:
PassRefPtr<JSONObject> LoggingCanvas::objectForSkPoint(const SkPoint& point)
{
RefPtr<JSONObject> pointItem = JSONObject::create();
pointItem->setNumber("x", point.x());
pointItem->setNumber("y", point.y());
return pointItem.release();
}
示例11: SkAnnotateNamedDestination
void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
if (nullptr == name) {
return;
}
const SkRect rect = SkRect::MakeXYWH(point.x(), point.y(), 0, 0);
canvas->drawAnnotation(rect, SkAnnotationKeys::Define_Named_Dest_Key(), name);
}
示例12: appendGlyph
inline void GrStencilAndCoverTextContext::appendGlyph(const SkGlyph& glyph, const SkPoint& pos) {
// Stick the glyphs we can't draw into the fallback arrays.
if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
fFallbackIndices.push_back(glyph.getGlyphID());
fFallbackPositions.push_back().set(fTextInverseRatio * pos.x(),
-fTextInverseRatio * pos.y());
} else {
// TODO: infer the reserve count from the text length.
if (!fDraw) {
fDraw = GrPathRangeDraw::Create(fGlyphs,
GrPathRendering::kTranslate_PathTransformType,
64);
}
float translate[] = { fTextInverseRatio * pos.x(), -fTextInverseRatio * pos.y() };
fDraw->append(glyph.getGlyphID(), translate);
}
}
示例13: SkAnnotateNamedDestination
void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
if (NULL == name) {
return;
}
SkPaint paint;
annotate_paint(paint, SkAnnotationKeys::Define_Named_Dest_Key(), name);
canvas->drawPoint(point.x(), point.y(), paint);
}
示例14: draw_label
static void draw_label(SkCanvas* canvas, const char* label,
const SkPoint& offset) {
SkPaint paint;
size_t len = strlen(label);
SkScalar width = paint.measureText(label, len);
canvas->drawText(label, len, offset.x() - width / 2, offset.y(),
paint);
}
示例15: noiseX
SkScalar SkPerlinNoiseShader::PerlinNoiseShaderContext::noise2D(
int channel, const StitchData& stitchData, const SkPoint& noiseVector) const {
struct Noise {
int noisePositionIntegerValue;
int nextNoisePositionIntegerValue;
SkScalar noisePositionFractionValue;
Noise(SkScalar component)
{
SkScalar position = component + kPerlinNoise;
noisePositionIntegerValue = SkScalarFloorToInt(position);
noisePositionFractionValue = position - SkIntToScalar(noisePositionIntegerValue);
nextNoisePositionIntegerValue = noisePositionIntegerValue + 1;
}
};
Noise noiseX(noiseVector.x());
Noise noiseY(noiseVector.y());
SkScalar u, v;
const SkPerlinNoiseShader& perlinNoiseShader = static_cast<const SkPerlinNoiseShader&>(fShader);
// If stitching, adjust lattice points accordingly.
if (perlinNoiseShader.fStitchTiles) {
noiseX.noisePositionIntegerValue =
checkNoise(noiseX.noisePositionIntegerValue, stitchData.fWrapX, stitchData.fWidth);
noiseY.noisePositionIntegerValue =
checkNoise(noiseY.noisePositionIntegerValue, stitchData.fWrapY, stitchData.fHeight);
noiseX.nextNoisePositionIntegerValue =
checkNoise(noiseX.nextNoisePositionIntegerValue, stitchData.fWrapX, stitchData.fWidth);
noiseY.nextNoisePositionIntegerValue =
checkNoise(noiseY.nextNoisePositionIntegerValue, stitchData.fWrapY, stitchData.fHeight);
}
noiseX.noisePositionIntegerValue &= kBlockMask;
noiseY.noisePositionIntegerValue &= kBlockMask;
noiseX.nextNoisePositionIntegerValue &= kBlockMask;
noiseY.nextNoisePositionIntegerValue &= kBlockMask;
int i =
fPaintingData->fLatticeSelector[noiseX.noisePositionIntegerValue];
int j =
fPaintingData->fLatticeSelector[noiseX.nextNoisePositionIntegerValue];
int b00 = (i + noiseY.noisePositionIntegerValue) & kBlockMask;
int b10 = (j + noiseY.noisePositionIntegerValue) & kBlockMask;
int b01 = (i + noiseY.nextNoisePositionIntegerValue) & kBlockMask;
int b11 = (j + noiseY.nextNoisePositionIntegerValue) & kBlockMask;
SkScalar sx = smoothCurve(noiseX.noisePositionFractionValue);
SkScalar sy = smoothCurve(noiseY.noisePositionFractionValue);
// This is taken 1:1 from SVG spec: http://www.w3.org/TR/SVG11/filters.html#feTurbulenceElement
SkPoint fractionValue = SkPoint::Make(noiseX.noisePositionFractionValue,
noiseY.noisePositionFractionValue); // Offset (0,0)
u = fPaintingData->fGradient[channel][b00].dot(fractionValue);
fractionValue.fX -= SK_Scalar1; // Offset (-1,0)
v = fPaintingData->fGradient[channel][b10].dot(fractionValue);
SkScalar a = SkScalarInterp(u, v, sx);
fractionValue.fY -= SK_Scalar1; // Offset (-1,-1)
v = fPaintingData->fGradient[channel][b11].dot(fractionValue);
fractionValue.fX = noiseX.noisePositionFractionValue; // Offset (0,-1)
u = fPaintingData->fGradient[channel][b01].dot(fractionValue);
SkScalar b = SkScalarInterp(u, v, sx);
return SkScalarInterp(a, b, sy);
}