aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SamplePath.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index e63c513064..1eb4222b1c 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -11,6 +11,7 @@
#include "SkXfermode.h"
#include "SkColorPriv.h"
#include "SkColorFilter.h"
+#include "SkParsePath.h"
#include "SkTime.h"
#include "SkTypeface.h"
@@ -37,6 +38,36 @@ static void test_cubic() {
#endif
}
+static void test_cubic2() {
+ const char* str = "M2242 -590088L-377758 9.94099e+07L-377758 9.94099e+07L2242 -590088Z";
+ SkPath path;
+ SkParsePath::FromSVGString(str, &path);
+
+ {
+ float x = strtof("9.94099e+07", NULL);
+ int ix = (int)x;
+ int fx = (int)(x * 65536);
+ int ffx = SkScalarToFixed(x);
+ printf("%g %x %x %x\n", x, ix, fx, ffx);
+
+ SkRect r = path.getBounds();
+ SkIRect ir;
+ r.round(&ir);
+ printf("[%g %g %g %g] [%x %x %x %x]\n",
+ r.fLeft, r.fTop, r.fRight, r.fBottom,
+ ir.fLeft, ir.fTop, ir.fRight, ir.fBottom);
+ }
+
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 200);
+ bitmap.allocPixels();
+
+ SkCanvas canvas(bitmap);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ canvas.drawPath(path, paint);
+}
+
class PathView : public SkView {
public:
int fDStroke, fStroke, fMinStroke, fMaxStroke;
@@ -45,6 +76,7 @@ public:
PathView() {
test_cubic();
+ test_cubic2();
fShowHairline = false;