aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleDegenerateTwoPtRadials.cpp7
-rw-r--r--samplecode/SampleEmptyPath.cpp9
-rw-r--r--samplecode/SamplePath.cpp10
3 files changed, 14 insertions, 12 deletions
diff --git a/samplecode/SampleDegenerateTwoPtRadials.cpp b/samplecode/SampleDegenerateTwoPtRadials.cpp
index 91f1622b69..4e83ed8f0a 100644
--- a/samplecode/SampleDegenerateTwoPtRadials.cpp
+++ b/samplecode/SampleDegenerateTwoPtRadials.cpp
@@ -10,6 +10,7 @@
#include "SkCanvas.h"
#include "Sk64.h"
#include "SkGradientShader.h"
+#include "SkString.h"
static void draw_gradient2(SkCanvas* canvas, const SkRect& rect, SkScalar delta) {
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorMAGENTA };
@@ -71,12 +72,12 @@ protected:
SkScalar l = SK_Scalar1 * 100;
SkScalar t = SK_Scalar1 * 100;
draw_gradient2(canvas, SkRect::MakeXYWH(l, t, w, h), delta);
- char txt[512];
- sprintf(txt, "gap at \"tangent\" pt = %f", SkScalarToFloat(delta));
+ SkString txt;
+ txt.appendf("gap at \"tangent\" pt = %f", SkScalarToFloat(delta));
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorBLACK);
- canvas->drawText(txt, strlen(txt), l + w/2 + w*DELTA_SCALE*delta, t + h + SK_Scalar1 * 10, paint);
+ canvas->drawText(txt.c_str(), txt.size(), l + w/2 + w*DELTA_SCALE*delta, t + h + SK_Scalar1 * 10, paint);
this->inval(NULL);
}
diff --git a/samplecode/SampleEmptyPath.cpp b/samplecode/SampleEmptyPath.cpp
index 51c570eb43..53e2199853 100644
--- a/samplecode/SampleEmptyPath.cpp
+++ b/samplecode/SampleEmptyPath.cpp
@@ -10,6 +10,7 @@
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRandom.h"
+#include "SkString.h"
class EmptyPathView : public SampleView {
public:
@@ -103,14 +104,14 @@ protected:
rectPaint.setAntiAlias(true);
canvas->drawRect(rect, rectPaint);
- char label[1024];
- sprintf(label, "%s, %s", gStyles[style].fName,
- gFills[fill].fName);
+ SkString label;
+ label.appendf("%s, %s", gStyles[style].fName, gFills[fill].fName);
+
SkPaint labelPaint;
labelPaint.setColor(color);
labelPaint.setAntiAlias(true);
labelPaint.setLCDRenderText(true);
- canvas->drawText(label, strlen(label),
+ canvas->drawText(label.c_str(), label.size(),
0, rect.height() + 15 * SK_Scalar1,
labelPaint);
}
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index fa6ad43464..a09be281b4 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -61,15 +61,15 @@ static void test_cubic2() {
int ix = (int)x;
int fx = (int)(x * 65536);
int ffx = SkScalarToFixed(x);
- printf("%g %x %x %x\n", x, ix, fx, ffx);
+ SkDebugf("%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",
- SkScalarToDouble(r.fLeft), SkScalarToDouble(r.fTop),
- SkScalarToDouble(r.fRight), SkScalarToDouble(r.fBottom),
- ir.fLeft, ir.fTop, ir.fRight, ir.fBottom);
+ SkDebugf("[%g %g %g %g] [%x %x %x %x]\n",
+ SkScalarToDouble(r.fLeft), SkScalarToDouble(r.fTop),
+ SkScalarToDouble(r.fRight), SkScalarToDouble(r.fBottom),
+ ir.fLeft, ir.fTop, ir.fRight, ir.fBottom);
}
SkBitmap bitmap;