2014年1月5日 星期日

[ mixare ] 在擴增實境上繪製縮放的捲軸

如果想安裝設mixare Android可以參考下列文章:

[ mixare ] 一套開放式源始碼擴增實境瀏覽器資源分享


因有讀者問到如何在鏡頭畫面中加上一些繪圖的功能,敏哥花了一些時間研究其原始碼。

當程式執行時,其畫面如下:
按下功能表鍵,就可以看到功能表單。
 選擇Zoom/level功能表,就可以看到捲軸了。


當讀者把程式滙入後,在org.mixare可以找到MixView.java打開程式後,可以在1146行找到AugmentedView類別,在該類別下有onDraw(Canvas canvas)重繪事件程序,在1185~1207行就是捲軸的繪製程式,程式碼如下:

if (app.isZoombarVisible()) {
zoomPaint.setColor(Color.WHITE);
zoomPaint.setTextSize(14);
String startKM, endKM;
endKM = "80km";
startKM = "0km";
/*
* if(MixListView.getDataSource().equals("Twitter")){ startKM =
* "1km"; }
*/
canvas.drawText(startKM, canvas.getWidth() / 100 * 4,
canvas.getHeight() / 100 * 85, zoomPaint);
canvas.drawText(endKM, canvas.getWidth() / 100 * 99 + 25,
canvas.getHeight() / 100 * 85, zoomPaint);

int height = canvas.getHeight() / 100 * 85;
int zoomProgress = app.getZoomProgress();
if (zoomProgress > 92 || zoomProgress < 6) {
height = canvas.getHeight() / 100 * 80;
}
canvas.drawText(app.getZoomLevel(), (canvas.getWidth()) / 100
* zoomProgress + 20, height, zoomPaint);
}

沒有留言:

張貼留言