代码
toastLog("Are you ready?");
var IMG, img;
if (!requestScreenCapture()) {
toast("请求截图失败");
exit();
};
IMG = captureScreen();
img = images.copy(IMG);
var window = floaty.rawWindow(
<vertical id="vertical" bg="#aaaaaa" w="{
{Math.floor(device.width*0.8)}}px" h="{
{Math.floor(device.width*0.8)}}px" gravity="center">
<canvas id="canvas" margin="5dp" layout_weight="1"/>
<horizontal id="horizontal" margin="5dp" w="*" gravity="center">
<button id="butJ" layout_weight="1" text="截图"/>
<button id="butX" layout_weight="1" text="选图"/>
<button id="butY" layout_weight="1" text="移动"/>
<button id="butG" layout_weight="1" text="关闭"/>
</horizontal>
</vertical>
);
var window_ = floaty.window(
<button id="but_" w="150px" h="150px" text="▽" alpha="0.7"/>
);
var ad = new 悬浮控制(window, window.butY, 1, window.vertical);
var ad_ = new 悬浮控制(window_, window_.but_);
var F = ad.OutScreen();
var F_ = ad_.OutScreen();
threads.start(function() {
sleep(100);
F_ = ad_.OutScreen();
ad_.windowyidong(F_);
});
ad.setClick(function() {
threads.start(function() {
F = ad.OutScreen();
ad.windowyidong(F);
ad_.windowyidong([F_[1], ad_.centerXY(ad.centerXY(F[0])[0])[1]]);
ad_.windowyidong(ad_.IntScreen());
ad_.windowyidong(ad_.toScreenEdge(0));
});
});
ad_.setClick(function() {
threads.start(function() {
F_ = ad_.OutScreen();
ad_.windowyidong(F_);
ad.windowyidong([F[1], ad.centerXY(ad_.centerXY(F_[0])[0])[1]]);
ad.windowyidong(ad.IntScreen());
});
});
window.butJ.click(function() {
threads.start(function() {
var F = ad.OutScreen();
ad.windowyidong(F);
sleep(100);
var IMG = captureScreen();
img = images.copy(IMG);
ad.windowyidong(F.reverse());
});
});
window.butX.click(function() {
threads.start(function() {
var F = ad.OutScreen();
ad.windowyidong(F);
var Apath = "/sdcard";
var path = listpath(Apath);
if (path) {
var IMG = 加载图片(path);
img = images.copy(IMG);
};
ad.windowyidong(F.reverse());
});
});
window.butG.on("click",()=>{
exit()});
ad.setLongClick(exit);
ad_.setLongClick(exit);
var paint = new Paint;
paint.setTextAlign(Paint.Align.CENTER);
paint.setStrokeWidth(5);
paint.setStyle(Paint.Style.STROKE);
var data = {
translate: {
x: 0,
y: 0
},
scale: 1,
};
threads.start(function() {
sleep(100);
window.setPosition(device.width / 2 - window.getWidth() / 2, device.height / 2 - window.getHeight() / 2);
sleep(100);
data = {
translate: {
x: -(window.getX() + window.canvas.getX()),
y: -(window.getY() + window.canvas.getY())
},
scale: 1,
};
});
var 点色;
setInterval(() => {
if (点色) {
ui.run(() => {
window.vertical.attr("bg", colors.toString(反色(点色.color)));
window.horizontal.attr("bg", 点色.colorString);
});
};
}, 50);
window.canvas.on("draw", function(canvas) {
canvas.drawARGB(255, 127, 127, 127);
try {
if (!img) {
return;
};
var w = canvas.getWidth();
var h = canvas.getHeight();
paint.setStrokeWidth(5);
var matrix = new android.graphics.Matrix();
matrix.postScale(data.scale, data.scale);
matrix.postTranslate(data.translate.x, data.translate.y);
paint.setARGB(255, 0, 0, 0);
canvas.drawImage(img, matrix, paint);
paint.setStrokeWidth(5);
paint.setStyle(Paint.Style.STROKE);
paint.setARGB(255, 255, 255, 0);
canvas.drawLine(w / 2 - 50, h / 2, w / 2 - 100, h / 2, paint);
paint.setARGB(255, 255, 0, 255);
canvas.drawLine(w / 2, h / 2