本文整理汇总了C++中SkRect::right方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRect::right方法的具体用法?C++ SkRect::right怎么用?C++ SkRect::right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkRect
的用法示例。
在下文中一共展示了SkRect::right方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_bbox
static void draw_bbox(SkCanvas* canvas, const SkRect& r) {
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(0xFFFF7088);
canvas->drawRect(r, paint);
canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint);
canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint);
}
示例2: draw
void draw(SkCanvas* canvas) {
SkRect rect = SkRect::MakeLTRB(5, 35, 15, 25);
SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
rect.bottom(), rect.isEmpty() ? "true" : "false");
rect.sort();
SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(),
rect.bottom(), rect.isEmpty() ? "true" : "false");
}
示例3: convolve_gaussian
static void convolve_gaussian(GrDrawContext* drawContext,
GrRenderTarget* rt,
const GrClip& clip,
const SkRect& srcRect,
const SkRect& dstRect,
GrTexture* texture,
Gr1DKernelEffect::Direction direction,
int radius,
float sigma,
bool cropToSrcRect) {
float bounds[2] = { 0.0f, 1.0f };
if (!cropToSrcRect) {
convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture,
direction, radius, sigma, false, bounds);
return;
}
SkRect lowerSrcRect = srcRect, lowerDstRect = dstRect;
SkRect middleSrcRect = srcRect, middleDstRect = dstRect;
SkRect upperSrcRect = srcRect, upperDstRect = dstRect;
SkScalar size;
SkScalar rad = SkIntToScalar(radius);
if (direction == Gr1DKernelEffect::kX_Direction) {
bounds[0] = SkScalarToFloat(srcRect.left()) / texture->width();
bounds[1] = SkScalarToFloat(srcRect.right()) / texture->width();
size = srcRect.width();
lowerSrcRect.fRight = srcRect.left() + rad;
lowerDstRect.fRight = dstRect.left() + rad;
upperSrcRect.fLeft = srcRect.right() - rad;
upperDstRect.fLeft = dstRect.right() - rad;
middleSrcRect.inset(rad, 0);
middleDstRect.inset(rad, 0);
} else {
bounds[0] = SkScalarToFloat(srcRect.top()) / texture->height();
bounds[1] = SkScalarToFloat(srcRect.bottom()) / texture->height();
size = srcRect.height();
lowerSrcRect.fBottom = srcRect.top() + rad;
lowerDstRect.fBottom = dstRect.top() + rad;
upperSrcRect.fTop = srcRect.bottom() - rad;
upperDstRect.fTop = dstRect.bottom() - rad;
middleSrcRect.inset(0, rad);
middleDstRect.inset(0, rad);
}
if (radius >= size * SK_ScalarHalf) {
// Blur radius covers srcRect; use bounds over entire draw
convolve_gaussian_1d(drawContext, rt, clip, srcRect, dstRect, texture,
direction, radius, sigma, true, bounds);
} else {
// Draw upper and lower margins with bounds; middle without.
convolve_gaussian_1d(drawContext, rt, clip, lowerSrcRect, lowerDstRect, texture,
direction, radius, sigma, true, bounds);
convolve_gaussian_1d(drawContext, rt, clip, upperSrcRect, upperDstRect, texture,
direction, radius, sigma, true, bounds);
convolve_gaussian_1d(drawContext, rt, clip, middleSrcRect, middleDstRect, texture,
direction, radius, sigma, false, bounds);
}
}
示例4: draw_box_frame
static void draw_box_frame(SkCanvas* canvas, int width, int height) {
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
p.setColor(SK_ColorRED);
SkRect r = SkRect::MakeIWH(width, height);
r.inset(0.5f, 0.5f);
canvas->drawRect(r, p);
canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), p);
canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), p);
}
示例5: onDraw
void onDraw(SkCanvas* canvas) override {
SkPaint blurPaint;
SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(5.0f, 5.0f));
blurPaint.setImageFilter(blur);
const SkScalar tile_size = SkIntToScalar(128);
SkRect bounds;
if (!canvas->getClipBounds(&bounds)) {
bounds.setEmpty();
}
int ts = SkScalarCeilToInt(tile_size);
SkImageInfo info = SkImageInfo::MakeN32Premul(ts, ts);
SkAutoTUnref<SkSurface> tileSurface(canvas->newSurface(info));
if (!tileSurface.get()) {
tileSurface.reset(SkSurface::NewRaster(info));
}
SkCanvas* tileCanvas = tileSurface->getCanvas();
for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) {
tileCanvas->save();
tileCanvas->clear(0);
tileCanvas->translate(-x, -y);
SkRect rect = SkRect::MakeWH(WIDTH, HEIGHT);
tileCanvas->saveLayer(&rect, &blurPaint);
SkRRect rrect = SkRRect::MakeRectXY(rect.makeInset(20, 20), 25, 25);
tileCanvas->clipRRect(rrect, SkRegion::kDifference_Op, true);
SkPaint paint;
tileCanvas->drawRect(rect, paint);
tileCanvas->restore();
tileCanvas->restore();
canvas->drawImage(tileSurface->makeImageSnapshot().get(), x, y);
}
}
}
示例6: onDraw
void onDraw(const int loops, SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(2);
if (fRound) {
paint.setStrokeJoin(SkPaint::kRound_Join);
}
this->setupPaint(&paint);
const SkRect r = fPath.getBounds();
switch (fAlign) {
case kLeft_Align:
canvas->translate(-r.left(), 0);
break;
case kMiddle_Align:
break;
case kRight_Align:
canvas->translate(640 - r.right(), 0);
break;
}
for (int i = 0; i < loops; i++) {
canvas->drawPath(fPath, paint);
}
}
示例7: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
const SkScalar tile_size = SkIntToScalar(128);
SkRect bounds;
if (!canvas->getClipBounds(&bounds)) {
bounds.setEmpty();
}
for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) {
canvas->save();
canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size));
canvas->saveLayer(NULL, &paint);
const char* str[] = {
"The quick",
"brown fox",
"jumped over",
"the lazy dog.",
};
SkPaint textPaint;
textPaint.setAntiAlias(true);
textPaint.setTextSize(SkIntToScalar(100));
int posY = 0;
for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) {
posY += 100;
canvas->drawText(str[i], strlen(str[i]), SkIntToScalar(0),
SkIntToScalar(posY), textPaint);
}
canvas->restore();
canvas->restore();
}
}
}
示例8: makeRect
Json::Value SkJSONCanvas::makeRect(const SkRect& rect) {
Json::Value result(Json::arrayValue);
result.append(Json::Value(rect.left()));
result.append(Json::Value(rect.top()));
result.append(Json::Value(rect.right()));
result.append(Json::Value(rect.bottom()));
return result;
}
示例9:
PassRefPtr<JSONObject> LoggingCanvas::objectForSkRect(const SkRect& rect)
{
RefPtr<JSONObject> rectItem = JSONObject::create();
rectItem->setNumber("left", rect.left());
rectItem->setNumber("top", rect.top());
rectItem->setNumber("right", rect.right());
rectItem->setNumber("bottom", rect.bottom());
return rectItem.release();
}
示例10: drawBorders
void drawBorders(SkCanvas* canvas) {
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
p.setColor(SK_ColorBLUE);
SkRect r = SkRect::MakeWH(fCell.width() * 2, fCell.height() * 2);
r.inset(SK_ScalarHalf, SK_ScalarHalf);
canvas->drawRect(r, p);
canvas->drawLine(r.left(), r.centerY(), r.right(), r.centerY(), p);
canvas->drawLine(r.centerX(), r.top(), r.centerX(), r.bottom(), p);
}
示例11: areBoundariesIntegerAligned
// Return true if the rectangle is aligned to integer boundaries.
// See comments for computeBitmapDrawRects() for how this is used.
static bool areBoundariesIntegerAligned(const SkRect& rect)
{
// Value is 1.19209e-007. This is the tolerance threshold.
const float epsilon = std::numeric_limits<float>::epsilon();
SkIRect roundedRect = roundedIntRect(rect);
return fabs(rect.x() - roundedRect.x()) < epsilon
&& fabs(rect.y() - roundedRect.y()) < epsilon
&& fabs(rect.right() - roundedRect.right()) < epsilon
&& fabs(rect.bottom() - roundedRect.bottom()) < epsilon;
}
示例12: MakeLinear
static sk_sp<SkShader> make_shader(const SkRect& bounds) {
const SkPoint pts[] = {
{ bounds.left(), bounds.top() },
{ bounds.right(), bounds.bottom() },
};
const SkColor colors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorBLACK,
SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW,
};
return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
SkShader::kClamp_TileMode);
}
示例13: writePathVertices
void writePathVertices(GrDrawBatch::Target* target,
GrBatchAtlas* atlas,
intptr_t offset,
GrColor color,
size_t vertexStride,
const SkMatrix& viewMatrix,
const ShapeData* shapeData) const {
GrTexture* texture = atlas->getTexture();
SkScalar dx = shapeData->fBounds.fLeft;
SkScalar dy = shapeData->fBounds.fTop;
SkScalar width = shapeData->fBounds.width();
SkScalar height = shapeData->fBounds.height();
SkScalar invScale = 1.0f / shapeData->fScale;
dx *= invScale;
dy *= invScale;
width *= invScale;
height *= invScale;
SkPoint* positions = reinterpret_cast<SkPoint*>(offset);
// vertex positions
// TODO make the vertex attributes a struct
SkRect r = SkRect::MakeXYWH(dx, dy, width, height);
positions->setRectFan(r.left(), r.top(), r.right(), r.bottom(), vertexStride);
// colors
for (int i = 0; i < kVerticesPerQuad; i++) {
GrColor* colorPtr = (GrColor*)(offset + sizeof(SkPoint) + i * vertexStride);
*colorPtr = color;
}
const SkScalar tx = SkIntToScalar(shapeData->fAtlasLocation.fX);
const SkScalar ty = SkIntToScalar(shapeData->fAtlasLocation.fY);
// vertex texture coords
SkPoint* textureCoords = (SkPoint*)(offset + sizeof(SkPoint) + sizeof(GrColor));
textureCoords->setRectFan(tx / texture->width(),
ty / texture->height(),
(tx + shapeData->fBounds.width()) / texture->width(),
(ty + shapeData->fBounds.height()) / texture->height(),
vertexStride);
}
示例14: advance
void advance(const SkRect& bounds) {
fCenter += fVelocity;
if (fCenter.fX > bounds.right()) {
SkASSERT(fVelocity.fX > 0);
fVelocity.fX = -fVelocity.fX;
} else if (fCenter.fX < bounds.left()) {
SkASSERT(fVelocity.fX < 0);
fVelocity.fX = -fVelocity.fX;
}
if (fCenter.fY > bounds.bottom()) {
if (fVelocity.fY > 0) {
fVelocity.fY = -fVelocity.fY;
}
} else if (fCenter.fY < bounds.top()) {
if (fVelocity.fY < 0) {
fVelocity.fY = -fVelocity.fY;
}
}
fScale += fDScale;
if (fScale > 2 || fScale < SK_Scalar1/2) {
fDScale = -fDScale;
}
fRadian += fDRadian;
fRadian = SkScalarMod(fRadian, 2 * SK_ScalarPI);
fAlpha += fDAlpha;
if (fAlpha > 1) {
fAlpha = 1;
fDAlpha = -fDAlpha;
} else if (fAlpha < 0) {
fAlpha = 0;
fDAlpha = -fDAlpha;
}
}
示例15: equal
static bool equal(const SkRect& a, const SkRect& b) {
return SkScalarNearlyEqual(a.left(), b.left()) &&
SkScalarNearlyEqual(a.top(), b.top()) &&
SkScalarNearlyEqual(a.right(), b.right()) &&
SkScalarNearlyEqual(a.bottom(), b.bottom());
}