本文整理汇总了C++中SkMatrix::setSkew方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::setSkew方法的具体用法?C++ SkMatrix::setSkew怎么用?C++ SkMatrix::setSkew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::setSkew方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMatrices
void makeMatrices() {
{
SkMatrix m;
m.setScale(SkIntToScalar(2), SkIntToScalar(3));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setScale(SkIntToScalar(2), SkIntToScalar(2));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setSkew(SkIntToScalar(2), SkIntToScalar(3));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setSkew(SkIntToScalar(2), SkIntToScalar(2));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setRotate(SkIntToScalar(30));
fMatrices.push_back(m);
}
}
示例2: onDraw
virtual void onDraw(SkCanvas* canvas) {
canvas->clear(SK_ColorBLACK);
SkMatrix matrix;
SkScalar margin = SkIntToScalar(10);
matrix.setSkew(SkDoubleToScalar(0.5), SkDoubleToScalar(0.2));
SkBitmap checkerboard;
make_checkerboard(&checkerboard);
SkRect srcRect = SkRect::MakeWH(96, 96);
canvas->translate(margin, margin);
draw(canvas, srcRect, checkerboard, matrix, kNone_SkFilterQuality);
canvas->translate(srcRect.width() + margin, 0);
draw(canvas, srcRect, checkerboard, matrix, kLow_SkFilterQuality);
#if 0
// This may be causing Mac 10.6 to barf.
canvas->translate(srcRect.width() + margin, 0);
draw(canvas, srcRect, checkerboard, matrix, kMedium_SkFilterQuality);
canvas->translate(srcRect.width() + margin, 0);
draw(canvas, srcRect, checkerboard, matrix, kHigh_SkFilterQuality);
#endif
}
示例3: NativeSetSkew
void Matrix::NativeSetSkew(
/* [in] */ Int64 nObj,
/* [in] */ Float kx,
/* [in] */ Float ky)
{
SkMatrix* obj = reinterpret_cast<SkMatrix*>(nObj);
obj->setSkew(kx, ky);
}
示例4: makeMatrices
void makeMatrices() {
{
// 1x1.5 scale
SkMatrix m;
m.setScale(1, 1.5f);
fMatrices.push_back(m);
}
{
// 1.5x1.5 scale
SkMatrix m;
m.setScale(1.5f, 1.5f);
fMatrices.push_back(m);
}
{
// 1x1.5 skew
SkMatrix m;
m.setSkew(1, 1.5f);
fMatrices.push_back(m);
}
{
// 1.5x1.5 skew
SkMatrix m;
m.setSkew(1.5f, 1.5f);
fMatrices.push_back(m);
}
{
// 30 degree rotation
SkMatrix m;
m.setRotate(SkIntToScalar(30));
fMatrices.push_back(m);
}
{
// 90 degree rotation
SkMatrix m;
m.setRotate(SkIntToScalar(90));
fMatrices.push_back(m);
}
}
示例5: makeMatrices
void makeMatrices() {
{
SkMatrix m;
m.setIdentity();
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setScale(SkIntToScalar(3), SkIntToScalar(2));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setScale(SkIntToScalar(2), SkIntToScalar(2));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setScale(SkIntToScalar(1), SkIntToScalar(2));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setScale(SkIntToScalar(4), SkIntToScalar(1));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setRotate(SkIntToScalar(90));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setSkew(SkIntToScalar(2), SkIntToScalar(3));
fMatrices.push_back(m);
}
{
SkMatrix m;
m.setRotate(SkIntToScalar(60));
fMatrices.push_back(m);
}
}
示例6: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
const int nu = 10;
const int nv = 10;
SkPaint paint;
paint.setDither(true);
paint.setFilterQuality(kLow_SkFilterQuality);
canvas->translate(DX, DY);
Patch patch;
paint.setShader(fShader0);
if (fSize0.fX == 0) {
fSize0.fX = 1;
}
if (fSize0.fY == 0) {
fSize0.fY = 1;
}
patch.setBounds(fSize0.fX, fSize0.fY);
patch.setPatch(fPts);
drawpatches(canvas, paint, nu, nv, &patch);
paint.setShader(nullptr);
paint.setAntiAlias(true);
paint.setStrokeWidth(SkIntToScalar(5));
canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fPts, paint);
canvas->translate(0, SkIntToScalar(300));
paint.setAntiAlias(false);
paint.setShader(fShader1);
if (true) {
SkMatrix m;
m.setSkew(1, 0);
SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m);
paint.setShader(s)->unref();
}
if (true) {
SkMatrix m;
m.setRotate(fAngle);
SkShader* s = SkShader::CreateLocalMatrixShader(paint.getShader(), m);
paint.setShader(s)->unref();
}
patch.setBounds(fSize1.fX, fSize1.fY);
drawpatches(canvas, paint, nu, nv, &patch);
}
示例7: test_matrix_is_similarity
static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
REPORTER_ASSERT(reporter, mat.isSimilarity());
}
// see if there are any accumulated precision issues
mat.reset();
for (int i = 1; i < 360; i++) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postScale(SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + non-uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
//.........这里部分代码省略.........
示例8: test_matrix_is_similarity
static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
#ifdef SK_SCALAR_IS_FLOAT
/* We bypass the following tests for SK_SCALAR_IS_FIXED build.
* The long discussion can be found in this issue:
* http://codereview.appspot.com/5999050/
* In short, we haven't found a perfect way to fix the precision
* issue, i.e. the way we use tolerance in isSimilarityTransformation
* is incorrect. The situation becomes worse in fixed build, so
* we disabled rotation related tests for fixed build.
*/
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
REPORTER_ASSERT(reporter, mat.isSimilarity());
}
// see if there are any accumulated precision issues
mat.reset();
for (int i = 1; i < 360; i++) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
//.........这里部分代码省略.........
示例9: makeMatrix
SkMatrix makeMatrix() {
SkMatrix matrix;
matrix.reset();
RandomSetMatrix setMatrix = (RandomSetMatrix) fRand.nextRangeU(0, kRandomSetMatrix_Last);
if (fPrintName) {
SkDebugf("%.*s%s\n", fPathDepth * 3, fTab, gRandomSetMatrixNames[setMatrix]);
}
switch (setMatrix) {
case kSetIdentity:
break;
case kSetTranslateX:
matrix.setTranslateX(makeScalar());
break;
case kSetTranslateY:
matrix.setTranslateY(makeScalar());
break;
case kSetTranslate:
matrix.setTranslate(makeScalar(), makeScalar());
break;
case kSetScaleX:
matrix.setScaleX(makeScalar());
break;
case kSetScaleY:
matrix.setScaleY(makeScalar());
break;
case kSetScale:
matrix.setScale(makeScalar(), makeScalar());
break;
case kSetScaleTranslate:
matrix.setScale(makeScalar(), makeScalar(), makeScalar(), makeScalar());
break;
case kSetSkewX:
matrix.setSkewX(makeScalar());
break;
case kSetSkewY:
matrix.setSkewY(makeScalar());
break;
case kSetSkew:
matrix.setSkew(makeScalar(), makeScalar());
break;
case kSetSkewTranslate:
matrix.setSkew(makeScalar(), makeScalar(), makeScalar(), makeScalar());
break;
case kSetRotate:
matrix.setRotate(makeScalar());
break;
case kSetRotateTranslate:
matrix.setRotate(makeScalar(), makeScalar(), makeScalar());
break;
case kSetPerspectiveX:
matrix.setPerspX(makeScalar());
break;
case kSetPerspectiveY:
matrix.setPerspY(makeScalar());
break;
case kSetAll:
matrix.setAll(makeScalar(), makeScalar(), makeScalar(),
makeScalar(), makeScalar(), makeScalar(),
makeScalar(), makeScalar(), makeScalar());
break;
}
return matrix;
}
示例10: test_matrix_is_similarity
static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
#ifndef SK_CPU_ARM64
REPORTER_ASSERT(reporter, mat.isSimilarity());
#else
// 64-bit ARM devices built with -O2 and -ffp-contract=fast have a loss
// of precision and require that we have a higher tolerance
REPORTER_ASSERT(reporter, mat.isSimilarity(SK_ScalarNearlyZero + 0.00010113f));
#endif
}
// see if there are any accumulated precision issues
mat.reset();
for (int i = 1; i < 360; i++) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
//.........这里部分代码省略.........
示例11: setSkew__FF
static void setSkew__FF(JNIEnv* env, jobject clazz, jlong objHandle, jfloat kx, jfloat ky) {
SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
obj->setSkew(kx, ky);
}