Пример #1
0
static void test_patch(SkCanvas* canvas, const SkBitmap& bm, SkScalar scale) {
    SkCubicBoundary cubic;
    set_cubic(cubic.fPts + 0, 0, 0, 100, 0, scale);
    set_cubic(cubic.fPts + 3, 100, 0, 100, 100, scale);
    set_cubic(cubic.fPts + 6, 100, 100,  0, 100, -scale);
    set_cubic(cubic.fPts + 9, 0, 100, 0, 0, 0);

    SkBoundaryPatch patch;
    patch.setBoundary(&cubic);

    const int Rows = 16;
    const int Cols = 16;
    SkPoint pts[Rows * Cols];
    patch.evalPatch(pts, Rows, Cols);

    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setStrokeWidth(1);
    paint.setStrokeCap(SkPaint::kRound_Cap);

    canvas->translate(50, 50);
    canvas->scale(3, 3);

    SkMeshUtils::Draw(canvas, bm, Rows, Cols, pts, NULL, paint);
}
Пример #2
0
static void test_drag(SkCanvas* canvas, const SkBitmap& bm,
                      const SkPoint& p0, const SkPoint& p1) {
    SkCubicBoundary cubic;
    set_cubic(cubic.fPts + 0, 0, 0, 100, 0, 0);
    set_cubic(cubic.fPts + 3, 100, 0, 100, 100, 0);
    set_cubic(cubic.fPts + 6, 100, 100,  0, 100, 0);
    set_cubic(cubic.fPts + 9, 0, 100, 0, 0, 0);

#if 0
    cubic.fPts[1] += p1 - p0;
    cubic.fPts[2] += p1 - p0;
#else
    SkScalar dx = p1.fX - p0.fX;
    if (dx > 0) dx = 0;
    SkScalar dy = p1.fY - p0.fY;
    if (dy > 0) dy = 0;

    cubic.fPts[1].fY += dy;
    cubic.fPts[2].fY += dy;
    cubic.fPts[10].fX += dx;
    cubic.fPts[11].fX += dx;
#endif

    SkBoundaryPatch patch;
    patch.setBoundary(&cubic);

    const int Rows = 16;
    const int Cols = 16;
    SkPoint pts[Rows * Cols];
    patch.evalPatch(pts, Rows, Cols);

    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setStrokeWidth(1);
    paint.setStrokeCap(SkPaint::kRound_Cap);

    canvas->translate(50, 50);
    canvas->scale(3, 3);

    SkAutoCanvasRestore acr(canvas, true);

    SkRect r = { 0, 0, 100, 100 };
    canvas->clipRect(r);
    SkMeshUtils::Draw(canvas, bm, Rows, Cols, pts, NULL, paint);
}
Пример #3
0
static void get_conventional_lattice(double lattice[3][3],
				     SPGCONST Spacegroup *spacegroup)
{
  int i, j;
  double metric[3][3];
  Pointgroup pointgroup;

  pointgroup = ptg_get_pointgroup(spacegroup->pointgroup_number);

  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      lattice[i][j] = 0;
    }
  }

  mat_get_metric(metric, spacegroup->bravais_lattice);

  debug_print("bravais lattice\n");
  debug_print_matrix_d3(spacegroup->bravais_lattice);
  debug_print("%s\n", spacegroup->setting);

  switch (pointgroup.holohedry) {
  case TRICLI:
    set_tricli(lattice, metric);
    break;
  case MONOCLI: /* b-axis is the unique axis. */
    set_monocli(lattice, metric);
    break;
  case ORTHO:
    set_ortho(lattice, metric);
    break;
  case TETRA:
    set_tetra(lattice, metric);
    break;
  case TRIGO:
    if (spacegroup->setting[0] == 'R') {
      set_rhomb(lattice, metric);
    } else {
      set_trigo(lattice, metric);
    }
    break;
  case HEXA:
    set_trigo(lattice, metric);
    break;
  case CUBIC:
    set_cubic(lattice, metric);
    break;
  case HOLOHEDRY_NONE:
    break;
  }
}
Пример #4
0
void test_patch(SkCanvas* canvas, const SkBitmap& bm, SkScalar scale) {
    const float w = bm.width();
    const float h = bm.height();
    SkCubicBoundary cubic;    
    set_cubic(cubic.fPts + 0, 0, 0, w, 0, scale);
    set_cubic(cubic.fPts + 3, w, 0, w, h, scale);
    set_cubic(cubic.fPts + 6, w, h, 0, h, -scale);
    set_cubic(cubic.fPts + 9, 0, h, 0, 0, scale);
    
    SkBoundaryPatch patch;
    patch.setBoundary(&cubic);
    
    const int Rows = 16;
    const int Cols = 16;
    SkPoint pts[Rows * Cols];
    patch.evalPatch(pts, Rows, Cols);
    
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);

    SkMeshUtils::Draw(canvas, bm, Rows, Cols, pts, NULL, paint);
}
Пример #5
0
static int get_conventional_lattice(double lattice[3][3],
                                    const Holohedry holohedry,
                                    SPGCONST double bravais_lattice[3][3])
{
    int i, j;
    double metric[3][3];

    for (i = 0; i < 3; i++) {
        for (j = 0; j < 3; j++) {
            lattice[i][j] = 0;
        }
    }

    mat_get_metric(metric, bravais_lattice);

    switch (holohedry) {
    case TRICLI:
        mat_copy_matrix_d3(lattice, bravais_lattice);
        break;
    case MONOCLI: /* b-axis is the unique axis. */
        set_monocli(lattice, metric);
        break;
    case ORTHO:
        set_ortho(lattice, metric);
        break;
    case TETRA:
        set_tetra(lattice, metric);
        break;
    case RHOMB:
        set_rhomb(lattice, metric);
        break;
    case TRIGO:
        set_trigo(lattice, metric);
        break;
    case HEXA:
        set_trigo(lattice, metric);
        break;
    case CUBIC:
        set_cubic(lattice, metric);
        break;
    case NONE:
        break;
    }

    return 1;
}