extern void ANPMatrixInterfaceV0_Init(ANPInterface* value);
extern void ANPOffscreenInterfaceV0_Init(ANPInterface* value);
extern void ANPPaintInterfaceV0_Init(ANPInterface* value);
+extern void ANPPathInterfaceV0_Init(ANPInterface* value);
extern void ANPTypefaceInterfaceV0_Init(ANPInterface* value);
extern void ANPWindowInterfaceV0_Init(ANPInterface* value);
{ VARPROCLINE(CanvasInterfaceV0) },
{ VARPROCLINE(MatrixInterfaceV0) },
{ VARPROCLINE(PaintInterfaceV0) },
+ { VARPROCLINE(PathInterfaceV0) },
{ VARPROCLINE(TypefaceInterfaceV0) },
{ VARPROCLINE(WindowInterfaceV0) },
};
#define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002)
#define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003)
#define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004)
-#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1005)
-#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1006)
+#define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005)
+#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006)
+#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007)
/* queries for which drawing model is desired (for the draw event)
ANPCanvasInterfaceV0 gCanvasI;
ANPLogInterfaceV0 gLogI;
ANPPaintInterfaceV0 gPaintI;
+ANPPathInterfaceV0 gPathI;
ANPTypefaceInterfaceV0 gTypefaceI;
#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
{ kLogInterfaceV0_ANPGetValue, sizeof(gLogI), &gLogI },
{ kCanvasInterfaceV0_ANPGetValue, sizeof(gCanvasI), &gCanvasI },
{ kPaintInterfaceV0_ANPGetValue, sizeof(gPaintI), &gPaintI },
+ { kPathInterfaceV0_ANPGetValue, sizeof(gPathI), &gPathI },
{ kTypefaceInterfaceV0_ANPGetValue, sizeof(gPaintI), &gTypefaceI },
{ kAudioTrackInterfaceV0_ANPGetValue, sizeof(gSoundI), &gSoundI },
};
instance, evt->data.touch.action, evt->data.touch.x,
evt->data.touch.y);
if (kUp_ANPTouchAction == evt->data.touch.action) {
+ if (NULL == obj->track) {
+ obj->track = createTrack(instance, "/sdcard/sample.snd");
+ }
if (obj->track) {
+ gLogI.log(instance, kDebug_ANPLogType, "track %p %d",
+ obj->track, gSoundI.isStopped(obj->track));
if (gSoundI.isStopped(obj->track)) {
gSoundI.start(obj->track);
} else {
gSoundI.pause(obj->track);
}
- } else {
- obj->track = createTrack(instance, "/sdcard/sample.snd");
- gLogI.log(instance, kDebug_ANPLogType, "track %p %d",
- obj->track, gSoundI.isStopped(obj->track));
- gSoundI.start(obj->track);
- gLogI.log(instance, kDebug_ANPLogType, "track %p %d",
- obj->track, gSoundI.isStopped(obj->track));
}
}
return 1;
extern ANPLogInterfaceV0 gLogI;
extern ANPCanvasInterfaceV0 gCanvasI;
extern ANPPaintInterfaceV0 gPaintI;
+extern ANPPathInterfaceV0 gPathI;
extern ANPTypefaceInterfaceV0 gTypefaceI;
static void inval(NPP instance) {
PluginObject *obj = (PluginObject*) instance->pdata;
const float OW = 20;
const float OH = 20;
+ const int W = obj->window->width;
+ const int H = obj->window->height;
inval(instance, m_oval, true); // inval the old
m_oval.left = m_x;
m_oval.right = m_x + OW;
m_oval.bottom = m_y + OH;
inval(instance, m_oval, true); // inval the new
-
+
gCanvasI.drawColor(canvas, 0xFFFFFFFF);
+ // test out the Path API
+ {
+ ANPPath* path = gPathI.newPath();
+
+ float cx = W * 0.5f;
+ float cy = H * 0.5f;
+ gPathI.moveTo(path, 0, 0);
+ gPathI.quadTo(path, cx, cy, W, 0);
+ gPathI.quadTo(path, cx, cy, W, H);
+ gPathI.quadTo(path, cx, cy, 0, H);
+ gPathI.quadTo(path, cx, cy, 0, 0);
+
+ gPaintI.setColor(m_paint, 0xFF0000FF);
+ gCanvasI.drawPath(canvas, path, m_paint);
+
+ ANPRectF bounds;
+ memset(&bounds, 0, sizeof(bounds));
+ gPathI.getBounds(path, &bounds);
+#if 0
+ gLogI.log(instance, kDebug_ANPLogType, "drawpath: center %g %g bounds [%g %g %g %g]\n",
+ cx, cy,
+ bounds.left, bounds.top, bounds.right, bounds.bottom);
+#endif
+ gPathI.deletePath(path);
+ }
+
gPaintI.setColor(m_paint, 0xFFFF0000);
gCanvasI.drawOval(canvas, &m_oval, m_paint);