/*
软件作者:https://xuhss.com/oxox/pro
*/
"ui";
ui.layout(
<drawer id="drawer">
<vertical>
<appbar>
<toolbar id="toolbar" title="色组生成器" h="40dp"/>
</appbar>
<canvas id="canvas" margin="5" layout_weight="1"/>
<horizontal>
<vertical layout_weight="1"h="100dp">
<button id="set_maxColors" text="最大点数" w="*" layout_weight="1"/>
<button id="set_A" text="生成找色代码" w="*" layout_weight="1"/>
</vertical>
<vertical layout_weight="1"h="100dp">
<button id="to_" text="移动切换" w="*" layout_weight="1"/>
<button id="toAry" text="保存数组" w="*" layout_weight="1"/>
</vertical>
<vertical layout_weight="1"h="100dp">
<button id="set_J" text="记点模式" w="*" layout_weight="1"/>
<button id="set_go" text="重置" w="*" layout_weight="1"/>
</vertical>
</horizontal>
</vertical>
<vertical layout_gravity="left" bg="#ffffff" w="280">
<text text="颜色匹配函数" textSize="25sp" margin="5" gravity="center"/>
<input id="in_fun" w="*" h="*" layout_weight="1" textSize="16sp" bg="#dddddd" margin="5"/>
<button id="save_fun" text="保存函数" w="*"/>
<button id="open_img" text="打开图片" w="*"/>
</vertical>
</drawer>
);
toastLog("注意侧拉菜单");
//var img = images.read("/storage/emulated/0/建记/图片/img04.jpg");
var canvasAD = new 图片查看(ui.canvas);
threads.start(function() {
console.show();
});
//让工具栏左上角可以打开侧拉菜单
ui.toolbar.setupWithDrawer(ui.drawer);
ui.in_fun.setText(canvasAD.isColor.toString());
ui.save_fun.click(function() {
var txt = ui.in_fun.getText();
if (txt) {
try {
var fun = eval("(" + txt + ")");
} catch (e) {
toastLog(e);
};
if (typeof fun == "function") {
canvasAD.isColor = fun;
toast("OK");
} else {
toastLog("不是一个函数");
};
};
});
ui.open_img.click(function() {
选择图片(function(path) {
var IMG = 加载图片(path);
canvasAD.setImg(IMG);
Script_data.imgPath = path;
//IMG.recycle();
});
});
ui.set_maxColors.click(function() {
var max = canvasAD.maxColors;
threads.start(function() {
var num = parseInt(dialogs.prompt("修改最大点数", String(max)));
if (num > 20) {
canvasAD.maxColors = num;
Script_data.max = num;
toastLog("已修改");
} else {
toastLog("点数过少");
};
});
});
ui.set_A.click(function() {
var colorData=canvasAD.getColors();
setClip("var colorData=" + JSON.stringify(colorData) + ";\nvar p = images.findMultiColors(img, colorData.color, colorData.ary);");
if(colorData.ary.length){
toast("已复制");
}else{
toast("数据为空,失败");
};
});
ui.to_.click(function() {
canvasAD.toMode();
});
ui.toAry.click(function() {
var colorData=canvasAD.getColors();
setClip(JSON.stringify(colorData));
if(colorData.ary.length){
toast("已复制");
}else{
toast("数据为空,失败");
};
});
ui.set_J.click(function() {
canvasAD.colorMode();
});
ui.set_go.click(function() {
canvasAD.resetColor();
});
var storage = storages.create("取色_多点");
var Script_data = storage.get("data", {});
events.on("exit", function() {
Script_data.fun = canvasAD.isColor.toString();
storage.put("data", Script_data);
});
if (Script_data.fun) {
try {
var fun = eval("(" + Script_data.fun + ")");
} catch (e) {
toastLog(e);
};
if (typeof fun == "function") {
canvasAD.isColor = fun;
toast("OK");
};
};
if (Script_data.max) {
canvasAD.maxColors = parseInt(Script_data.max);
};
thread = threads.start(function() {
sleep(1000);
if (Script_data.imgPath) {
var IMG = 加载图片(Script_data.imgPath);
canvasAD.setImg(IMG);
};
});
var fileType = {
文本: {
img: "format_text.png",
ends: ["js", "txt", "json"]
},
图片: {
img: "format_picture.png",
ends: ["png", "jpg"]
},
音乐: {
img: "format_music.png",
ends: ["mp3", "m4a"]
},
视频: {
img: "format_media.png",
ends: ["mp4"]
},
安装包: {
img: "format_apk.png",
ends: ["apk"]
},
压缩包: {
img: "format_zip.png",
ends: ["zip"]
},
数据: {
img: "format_unkown.png",
ends: ["abc"]
}
};
function nameToType(name) {
var Extension = name.split(".").pop();
for (var i in fileType) {
for (var a = 0; a < fileType[i].ends.length; a++) {
if (Extension == fileType[i].ends[a]) {
return i;
};
}
};
return "unkown";
};
function 加载图片(A) {
if (files.isFile(A)) {
imagePath = A;
return images.read(A);
};
};
function 选择图片(fun) {
ui.run(() => {
importPackage(org.autojs.autojs.ui.explorer);
importPackage(org.autojs.autojs.model.explorer);
var explorerView = new ExplorerView(new android.view.ContextThemeWrapper(context, org.autojs.autojs.R.style.AppTheme));
explorerView.setExplorer(Explorers.workspace(), ExplorerDirPage.createRoot("/sdcard"));
explorerView.setDirectorySpanSize(2);
var dialog = new org.autojs.autojs.theme.dialog.ThemeColorMaterialDialogBuilder(context)
.title("选择图片文件")
.customView(explorerView, false)
.positiveText("取消")
.build();
explorerView.setOnItemClickListener(function(view, item) {
if (nameToType(String(item.toScriptFile())) == "图片") {
fun(String(item.toScriptFile()));
dialog.dismiss();
} else {
toastLog("不是图片");
};
});
com.stardust.app.DialogUtils.showDialog(dialog);
});
};
function 图片查看(canvasView, img) {
this.maxColors = 300;
this.mode = 0;
this.toMode = function() {
if (this.mode == 0) {
this.mode = 1;
} else {
this.mode = 0;
};
};
this.isColor = function(color) {
return colors.isSimilar(color, "#ff0000", 127);
};
this.view = {
x: canvasView.getX(),
y: canvasView.getY(),
w: canvasView.getWidth(),
h: canvasView.getHeight()
};
this.canvasRect = new android.graphics.RectF(0, 0, this.view.w || device.width, this.view.h || device.height);
this.paint = new Paint;
this.paint.setTextAlign(Paint.Align.CENTER);
this.paint.setStrokeWidth(5);
this.paint.setARGB(127, 0, 0, 0);
//this.paint.setStyle(Paint.Style.STROKE);
this.paint.setStyle(Paint.Style.FILL);
this.textSize = 20;
this.paint.setTextSize(this.textSize);
this.matrix = new android.graphics.Matrix();
this.imginvertMatrix = new android.graphics.Matrix();
this.imgRect;
this.colorsMatrix = new android.graphics.Matrix();
this.colorsinvertMatrix = new android.graphics.Matrix();
this.colorsData = {
x: 0,
y: 0,
first: false,
color: 0,
ary: new Array
};
this.PointsAry = {
rectAry: new Array,
XYAry: new Array,
imgAry
没有合适的资源?快使用搜索试试~ 我知道了~
AutoJs源码-取色-多点v1209
![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)
需积分: 9 0 下载量 101 浏览量
2022-11-15
12:06:07
上传
评论
收藏 5KB 7Z 举报
温馨提示
AutoJs源码-取色_多点v1209。本资源购买前提醒:本源码都是实际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)
![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)