/*
软件作者:https://xuhss.com/oxox/pro
*/
"ui";
ui.layout(
<vertical>
<canvas id="canvas"/>
</vertical>
);
threads.start(function() {
console.show();
});
new canvasDraw(ui.canvas);
function canvasDraw(canvasView) {
this.paint = new Paint;
//this.paint.setTextAlign(Paint.Align.CENTER);
this.paint.setStrokeWidth(5);
this.paint.setStyle(Paint.Style.STROKE);
this.paint.setARGB(255, 0, 0, 0);
this.paint.setTextSize(75);
//new android.graphics.RectF
canvasView.on("draw", (canvas) => {
canvas.drawARGB(255, 127, 127, 127);
var w = canvas.getWidth();
var h = canvas.getHeight();
var AX = w / 2;
var AY = h / 10;
this.paint.setStyle(Paint.Style.FILL);
canvas.drawCircle(AX, AY, 10, this.paint);
this.paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(AX, AY, 100, this.paint);
canvas.drawText(String("B"), AX, AY, this.paint);
if (this.TouchPointStart.length) {
for (let i = 0; i < this.TouchPointStart.length; i += 2) {
let X = this.TouchPointStart[i];
let Y = this.TouchPointStart[i + 1];
let x = this.TouchPointCurrent[i];
let y = this.TouchPointCurrent[i + 1];
let a = X - (x - X);
let b = Y - (y - Y);
canvas.drawLine(X, Y, x, y, this.paint);
canvas.drawLine(X, Y, a, b, this.paint);
canvas.drawText(String("A"), X, Y, this.paint)
canvas.drawCircle(X, Y, 10, this.paint);
canvas.drawCircle(x, y, 10, this.paint);
canvas.drawCircle(a, b, 10, this.paint);
};
if (this.SP.length) {
canvas.drawCircle(this.CC.ox, this.CC.oy, this.CC.r, this.paint);
canvas.drawCircle(this.CC.ox, this.CC.oy, 10, this.paint);
canvas.drawText(String("O"), this.CC.ox, this.CC.oy, this.paint);
canvas.drawText(String(this.SP.length / 2), w / 2, h / 4, this.paint);
for (var i = 0; i < this.SP.length; i += 2) {
var x = this.SP[i];
var y = this.SP[i + 1];
canvas.drawLine(AX, AY, x, y, this.paint);
canvas.drawCircle(x, y, 10, this.paint);
canvas.drawText(String("C"), x, y, this.paint);
};
};
};
canvas.drawText(String(this.LL), w / 2, h / 5, this.paint);
});
this.TouchPointStart = new Array;
this.TouchPointCurrent = new Array;
this.CC = {
ox: 0,
oy: 0,
r: 0,
};
this.SP = new Array;
this.LL;
this.V1 = 2;
this.V2 = 10;
this.VC = this.V1 / (this.V2 - this.V1);
this.V1S = this.V1 / (this.V1 + this.V2);
this.V2S = this.V2 / (this.V1 + this.V2);
canvasView.setOnTouchListener(new android.view.View.OnTouchListener((view, event) => {
try {
var W = view.getWidth();
var H = view.getHeight();
var PC = event.getPointerCount();
switch (event.getActionMasked()) {
case event.ACTION_MOVE:
for (let i = 0; i < PC; i++) {
let id = event.getPointerId(i);
let X = event.getX(i);
let Y = event.getY(i);
this.TouchPointCurrent[i * 2] = X;
this.TouchPointCurrent[i * 2 + 1] = Y;
};
var BX = W / 2;
var BY = H / 10;
var AX = this.TouchPointStart[0];
var AY = this.TouchPointStart[1];
var CX = this.TouchPointCurrent[0];
var CY = this.TouchPointCurrent[1];
var S = this.weiyi([AX - BX, AY - BY]);
var S0 = this.VC * S;
var S1 = this.V1S * S;
var S2 = this.V2S * S;
var R = (S0 + S1) / 2;
var OB = R + S2;
var O_ary = this.getsd(OB, [AX - BX, AY - BY]);
var OX = BX + O_ary[0];
var OY = BY + O_ary[1];
var AB_ary = this.XYTOAB(AX, AY, CX, CY);
this.LL = [Math.round(AB_ary[0] * 100) / 100, Math.round(AB_ary[1] * 100) / 100];
//log(OX,OB,R);
this.CC = {
ox: OX,
oy: OY,
r: R,
};
this.SP = this.SolvePos(OX, OY, R, AB_ary[0], AB_ary[1]);
break;
case event.ACTION_CANCEL:
log("CANCEL");
this.TouchPointStart = new Array;
this.TouchPointCurrent = new Array;
break;
case event.ACTION_OUTSIDE:
log("OUTSIDE");
break;
default:
var I = Math.floor(event.getAction() / 256);
var ID = event.getPointerId(I);
var X = event.getX(I);
var Y = event.getY(I);
switch (event.getActionMasked()) {
case event.ACTION_DOWN:
//第一个手指按下。
log("down");
this.TouchPointStart.splice(I * 2, 0, X, Y);
this.TouchPointCurrent.splice(I * 2, 0, X, Y);
this.CC = {
ox: X,
oy: Y,
r: 0,
};
break;
case event.ACTION_UP:
//最后一个手指抬起。
log("up");
this.TouchPointStart = new Array;
this.TouchPointCurrent = new Array;
this.SP = new Array;
break;
case event.ACTION_POINTER_DOWN:
log("POINTER_DOWN");
this.TouchPointStart.splice(I * 2, 0, X, Y);
this.TouchPointCurrent.splice(I * 2, 0, X, Y);
break;
case event.ACTION_POINTER_UP:
log("POINTER_UP");
this.TouchPointStart.splice(I * 2, 2);
this.TouchPointCurrent.splice(I * 2, 2);
break;
};
};
} catch (e) {
log("0: " + e);
};
return true;
}));
this.反色 = function(color) {
return (-1 - colors.argb(0, colors.red(color), colors.green(color), colors.blue(color)));
};
this.toJavaArray = function(type, ary) {
//var Ary = java.lang.reflect.Array.newInstance( java.lang.Float.TYPE, 4);
var Ary = util.java.array(type, ary.length);
for (let i in ary) {
Ary[i] = ary[i];
};
return Ary;
};
this.SolvePos = function(a, b, r, k, c) {
let a1 = k * k + 1;
let b1 = 2 * k * (c - b) - 2 * a;
let c1 = a * a + (c - b) * (c - b) - r * r;
let delta = b1 * b1 - 4 * a1 * c1;
let result = [];
if (delta == 0) {
let x0 = Math.sqrt(delta);
let x1 = -b1 / (2 * a1);
let y1 = k * x1 + c;
result.push(x1, y1);
} else if (delta > 0) {
l
没有合适的资源?快使用搜索试试~ 我知道了~
AutoJs源码-预判算法(1)(1)
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共1个文件
js:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 1 0 下载量 7 浏览量
2022-11-16
21:44:11
上传
评论
收藏 3KB 7Z 举报
温馨提示
AutoJs源码-预判算法(1)(1)。本资源购买前提醒:本源码都是实际autojs项目模板,安装好autojs直接运行即可打开。1、支持低版本autojs。2、资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!。3、安装过程详见具体资源,不会使用autojs谨慎下载
资源推荐
资源详情
资源评论
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 1 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
[虚幻私塾】
- 粉丝: 335
- 资源: 1559
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)