AIGameAIGame
首页
API文档
UI框架
下载软件
首页
API文档
UI框架
下载软件
  • API文档

    • $global - 全局函数
    • $act - 手势动作
      • 01.手势动作 - $act
      • 02.节点选择器 - UiSelector
      • 03.节点 - Node
    • $ag - 图色框架
    • $app - 应用操作
    • $arc - 悬浮菜单按钮
      • 01.悬浮菜单 - $arc
      • 02.悬浮容器 - MenuBody
      • 03.菜单按钮 - MenuItem
    • $bus - 消息总线
    • $color - 颜色操作
    • $crypt - 加密算法
    • $date - 日期工具
    • $device - 设备信息
    • $ext - dex,jar,so文件加载
    • $draw - 全局绘制
    • $engine - 脚本引擎
      • 01.任务信息 - JsTaskInfo
      • 02.脚本对象 - $task
    • $fc - 文件选择器
    • $file - 文件操作
    • $floaty - 悬浮窗
      • 01.可调节悬浮窗 - AdjFloaty
      • 02.系统级悬浮窗 - SysFloaty
      • 03.应用级悬浮窗 - AppFloaty
    • $img - 图片操作
    • $log - 日志框架
    • $ocr - 文字识别
    • $permit - 权限工具
    • $qr - 二维码工具
    • $res - 资源管理器
    • $root - ROOT与Shell命令
    • $screen - 屏幕操作
    • $storage - 应用内存储
    • $str - 字符串工具类
    • $sys - 系统操作
    • $thread - 并发编程
    • $tip - 对话框
    • $tts - 文字阅读
    • $yolo - 目标检测
    • $yolox - 目标检测

$draw

  • 更新时间:2025-07-25 17:09:18

全屏绘制

getPermit()

获取悬浮窗权限

  • 返回 : {boolean} 是否有权限
  • 版本 : 1.0.0
$draw.getPermit();

rect(rect)

绘制一个方框

  • 参数 : rect {Rect} opencv的Rect对象
  • 版本 : 1.0.0
//绘制矩形
$draw.rect(rect);

rect(node)

绘制一个方框

  • 参数 : node {AccessibilityNodeInfo} 节点信息
  • 版本 : 1.0.0
//绘制矩形
$draw.rect(node);

rect(x, y, w, h)

绘制一个方框

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : w {int} 宽度
  • 参数 : h {int} 高度
  • 版本 : 1.0.0
//绘制矩形
$draw.rect(200, 200, 200, 100);

rect(x, y, w, h, color)

绘制一个方框

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : w {int} 宽度
  • 参数 : h {int} 高度
  • 参数 : color {string} 颜色
  • 版本 : 1.1.1
//绘制矩形
$draw.rect(200, 200, 200, 100, "#FF0000");

rect(x, y, w, h, ext)

绘制方框

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : w {int} 宽度
  • 参数 : h {int} 高度
  • 参数 : ext {int} 向四周拓展
  • 版本 : 1.0.0
//绘制一个向外拓展50像素的矩阵
$draw.rect(200, 200, 200, 100, 50);

rect(x, y, w, h, ext, color)

绘制方框

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : w {int} 宽度
  • 参数 : h {int} 高度
  • 参数 : ext {int} 向四周拓展
  • 参数 : color {string} 颜色
  • 版本 : 1.1.0
//绘制一个向外拓展50像素的矩阵
$draw.rect(200, 200, 200, 100, 50, "#FF0000");

rect(x, y, w, h, ext, color)

绘制方框

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : w {int} 宽度
  • 参数 : h {int} 高度
  • 参数 : ext {int} 向四周拓展
  • 参数 : color {int} 颜色
  • 版本 : 1.1.1
//绘制一个向外拓展50像素的矩阵
$draw.rect(200, 200, 200, 100, 50, $color.RED);

rect(result)

绘制yolox结果集合

  • 参数 : result {YoloxResult} yolox结果
  • 版本 : 1.1.6
$screen.getPermit();
$draw.closeAll();
let result = $yolox.init("yolox/yolox-nano.bin", "yolox/yolox-nano.param", "yolox/label.text", false);
if (result.success) {
    alert("初始化成功", "初始化成功");
    //先显示
    showImg("yolox/t02.png");
    sleep(1000);
    //检测整个屏幕
    let res = $yolox.detect();
    alert("检测结果", res);
    //直接绘制yolox的结果集合
    $draw.rect(res);
} else {
    alert("初始化失败", result.des);
}

rect(result)

cross(point)

绘制一个十字准心

  • 参数 : point {point} 位置
  • 版本 : 1.0.0
//绘制准心
$draw.cross(point);

cross(index)

绘制一个十字准心

  • 参数 : index {int[]} 位置
  • 版本 : 1.0.0
//绘制准心
$draw.cross([400, 500]);

cross(node)

绘制一个十字准心

  • 参数 : node {AccessibilityNodeInfo} 节点信息
  • 版本 : 1.0.0
//绘制准心
$draw.cross(node);

cross(node)

绘制一个十字准心

  • 参数 : node {Node} 节点信息
  • 版本 : 1.0.0
//绘制准心
$draw.cross(node);

cross(x, y)

绘制一个十字准心

  • 参数 : x {int} 中心x
  • 参数 : y {int} 中心y
  • 版本 : 1.0.0
//绘制准心
$draw.cross(400, 500);

cross(x, y, color)

绘制一个十字准心

  • 参数 : x {int} 中心x
  • 参数 : y {int} 中心y
  • 参数 : color {string} 颜色
  • 版本 : 1.1.0
//绘制准心
$draw.cross(400, 500, "#FF0000");

cross(x, y, color)

绘制一个十字准心

  • 参数 : x {int} 中心x
  • 参数 : y {int} 中心y
  • 参数 : color {int} 颜色值
  • 版本 : 1.1.1
//绘制准心
$draw.cross(400, 500, $color.RED);

dot(index)

绘制一个点

  • 参数 : index {int[]} 点
  • 版本 : 1.0.0
$draw.dot([400, 500]);

dot(point)

绘制一个点

  • 参数 : point {point} 点
  • 版本 : 1.0.0
$draw.dot(point);

dot(x, y)

绘制一个点

  • 参数 : x {int} 点x
  • 参数 : y {int} 点y
  • 版本 : 1.0.0
//绘制一个点
$draw.dot(400, 500);

dot(x, y, color)

绘制一个点

  • 参数 : x {int} 点x
  • 参数 : y {int} 点y
  • 参数 : color {string} 颜色
  • 版本 : 1.0.0
//绘制一个点
$draw.dot(400, 500);

dot(x, y, color)

绘制一个点

  • 参数 : x {int} 点x
  • 参数 : y {int} 点y
  • 参数 : color {int} 颜色值
  • 版本 : 1.1.1
//绘制一个点
$draw.dot(400, 500, $color.RED);

text(text, x, y)

绘制文字

  • 参数 : text {String} 文字
  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 版本 : 1.0.0
//绘制文字
$draw.text("Hello aigame !", 400, 300);

text(text, x, y, size)

绘制文字

  • 参数 : text {String} 文字
  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : size {float} 字体大小
  • 版本 : 1.0.0
//绘制文字(大小为20像素)
$draw.text("Hello aigame !", 400, 400, 20);

text(text, x, y, size, color)

绘制文字

  • 参数 : text {String} 文字
  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : size {int} 字体大小
  • 参数 : color {string} 颜色
  • 版本 : 1.1.1
//绘制文字(大小为20像素)
$draw.text("Hello aigame !", 400, 400, 20, "#FF0000");

text(text, x, y, size, color)

绘制文字

  • 参数 : text {String} 文字
  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : size {int} 字体大小
  • 参数 : color {int} 颜色值
  • 版本 : 1.1.1
//绘制文字(大小为20像素)
$draw.text("Hello aigame !", 400, 400, 20, $color.RED);

circle(x, y)

绘制一个圆形 半径默认为50像素

  • 参数 : x {int} 圆心x
  • 参数 : y {int} 圆心y
  • 版本 : 1.1.1
//绘制半径为50像素的圆形
$draw.circle(350, 400);

circle(x, y, r)

绘制一个圆形

  • 参数 : x {int} 圆心x
  • 参数 : y {int} 圆心y
  • 参数 : r {int} 圆形半径
  • 版本 : 1.0.0
//绘制半径为100像素的圆形
$draw.circle(350, 400, 100);

circle(x, y, r, ext)

绘制一个圆形

  • 参数 : x {int} 圆心x
  • 参数 : y {int} 圆心y
  • 参数 : r {int} 圆形半径
  • 参数 : ext {int} 圆形向四周拓展
  • 版本 : 1.0.0
//向外拓展50像素
$draw.circle(350, 400, 100, 50);

circle(x, y, r, ext, color)

绘制一个圆形

  • 参数 : x {int} 圆心x
  • 参数 : y {int} 圆心y
  • 参数 : r {int} 圆形半径
  • 参数 : ext {int} 圆形向四周拓展
  • 参数 : color {string} 颜色
  • 版本 : 1.0.0
//向外拓展50像素
$draw.circle(350, 400, 100, 50, "#FF0000");

circle(x, y, r, ext, color)

绘制一个圆形

  • 参数 : x {int} 圆心x
  • 参数 : y {int} 圆心y
  • 参数 : r {int} 圆形半径
  • 参数 : ext {int} 圆形向四周拓展
  • 参数 : color {int} 颜色值
  • 版本 : 1.1.1
//向外拓展50像素
$draw.circle(350, 400, 100, 50, $color.RED);

img(img, x, y, w, h)

绘制图片

  • 参数 : img {Image} 图片对象
  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : w {int} 宽度(绘制后的图片宽度)
  • 参数 : h {int} 高度(绘制后的图片宽度)
  • 版本 : 1.1.0

line(x, y, toX, toY)

绘制一条线

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : toX {int} 目标x
  • 参数 : toY {int} 目标y
  • 版本 : 1.0.0
//绘制一条线
$draw.line(300, 0, 100, 1000);

line(x, y, toX, toY, color)

绘制一条线

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : toX {int} 目标x
  • 参数 : toY {int} 目标y
  • 参数 : color {string} 颜色
  • 版本 : 1.1.1
//绘制一条线
$draw.line(300, 0, 100, 1000, "#FF0000");

line(x, y, toX, toY, color)

绘制一条线

  • 参数 : x {int} 起点x
  • 参数 : y {int} 起点y
  • 参数 : toX {int} 目标x
  • 参数 : toY {int} 目标y
  • 参数 : color {int} 颜色值
  • 版本 : 1.1.1
//绘制一条线
$draw.line(300, 0, 100, 1000, $color.RED);

path(data)

绘制路径,传入的就是x和y的数组

  • 参数 : data {int[][]} 二维数组,第二维数组是坐标
  • 版本 : 1.0.0
//国际通用手势
$draw.path([
    [100, 800],
    [120, 750],
    [150, 720],
    [180, 750],
    [200, 800],
    [200, 800],
    [220, 700],
    [250, 680],
    [280, 700],
    [300, 800],
    [300, 800],
    [320, 250],
    [350, 200],
    [380, 250],
    [400, 800],
    [400, 800],
    [420, 740],
    [450, 730],
    [480, 740],
    [500, 800],
    [500, 800],
    [520, 770],
    [550, 760],
    [580, 770],
    [600, 800]
]);

path(data, color)

绘制路径,传入的就是x和y的数组

  • 参数 : data {int[][]} 二维数组,第二维数组是坐标
  • 参数 : color {string} 颜色
  • 版本 : 1.1.1
//国际通用手势
$draw.path([
    [100, 800],
    [120, 750],
    [150, 720],
    [180, 750],
    [200, 800],
    [200, 800],
    [220, 700],
    [250, 680],
    [280, 700],
    [300, 800],
    [300, 800],
    [320, 250],
    [350, 200],
    [380, 250],
    [400, 800],
    [400, 800],
    [420, 740],
    [450, 730],
    [480, 740],
    [500, 800],
    [500, 800],
    [520, 770],
    [550, 760],
    [580, 770],
    [600, 800]
], "#FF0000");

path(data, color)

绘制路径,传入的就是x和y的数组

  • 参数 : data {int[][]} 二维数组,第二维数组是坐标
  • 参数 : color {int} 颜色值
  • 版本 : 1.1.1
//国际通用手势
$draw.path([
    [100, 800],
    [120, 750],
    [150, 720],
    [180, 750],
    [200, 800],
    [200, 800],
    [220, 700],
    [250, 680],
    [280, 700],
    [300, 800],
    [300, 800],
    [320, 250],
    [350, 200],
    [380, 250],
    [400, 800],
    [400, 800],
    [420, 740],
    [450, 730],
    [480, 740],
    [500, 800],
    [500, 800],
    [520, 770],
    [550, 760],
    [580, 770],
    [600, 800]
], $color.RED);

i(text, x, y, size)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.i("信息", 400, 300, 40);

i(text, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.i("信息", 400, 300);

i(text)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.i("信息");

d(text, x, y, size)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.i("调试", 400, 300, 40);

d(text, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.d("调试", 400, 300);

d(text)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.d("调试");

w(text, x, y, size)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.w("警告", 400, 300, 40);

w(text, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.w("警告", 400, 300);

w(text)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.w("警告");

e(text, x, y, size)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.e("错误", 400, 300, 40);

e(text, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.e("错误", 400, 300);

e(text)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.e("错误");

v(text, x, y, size)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.v("信息", 400, 300, 40);

v(text, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.v("信息", 400, 300);

v(text)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.v("信息");

log(text, color, x, y, size)

绘制日志文字

  • 参数 : text {String} 文字
  • 参数 : color {String} 颜色
  • 参数 : x {int} 位置x
  • 参数 : y {int} 位置y
  • 参数 : size {float} 字体大小
  • 版本 : 1.0.0
$draw.log("信息", "#57965C", 400, 300, 40);

log(text, color, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 参数 : color {String} 颜色
  • 参数 : x {int} 位置x
  • 参数 : y {int} 位置y
  • 版本 : 1.0.0
$draw.log("信息", "#57965C", 400, 300);

log(text, color)

绘制日志文字

  • 参数 : text {String} 文字
  • 参数 : color {String} 颜色
  • 版本 : 1.0.0
$draw.log("信息", "#57965C");

log(text)

绘制日志文字

  • 参数 : text {String} 文字
  • 版本 : 1.0.0
$draw.log("信息");

log(text, x, y)

绘制日志文字

  • 参数 : text {String} 文字
  • 参数 : x {int} 位置x
  • 参数 : y {int} 位置y
  • 版本 : 1.0.0
$draw.log("信息", 400, 300);

closeAll()

关闭绘制日志的悬浮窗

  • 版本 : 1.0.0
//关闭所有绘制图案
$draw.closeAll();

closeAll(delay)

关闭绘制日志的悬浮窗

  • 版本 : 1.0.0
$draw.closeAll(1000);

closeLog(delay)

关闭绘制日志的悬浮窗

  • 版本 : 1.0.0
$draw.closeLog(1000);

closeLog()

关闭绘制日志的悬浮窗

  • 版本 : 1.0.0
$draw.closeLog();
最近更新: 2025/5/14 08:43
Contributors: 孑小白
Prev
$ext - dex,jar,so文件加载
Next
$engine - 脚本引擎