doc: update to lastest
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 261
|
||||
versionName "3.1.1 Alpha5"
|
||||
versionCode 262
|
||||
versionName "3.1.1 Alpha6"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Index | Auto.js 3.0.0 文档</title>
|
||||
<title>Canvas | Auto.js 3.0.0 文档</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
<link rel="stylesheet" href="assets/sh.css">
|
||||
@@ -73,11 +73,34 @@
|
||||
|
||||
<div id="toc">
|
||||
<h2>目录</h2>
|
||||
|
||||
<ul>
|
||||
<li><span class="stability_undefined"><a href="#canvas_canvas">Canvas</a></span></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="apicontent">
|
||||
|
||||
<h1>Canvas<span><a class="mark" href="#canvas_canvas" id="canvas_canvas">#</a></span></h1>
|
||||
<p>canvas提供了使用画布进行2D画图的支持,可用于简单的小游戏开发或者图片编辑。使用canvas可以轻松地在一张图片或一个界面上绘制各种线与图形。</p>
|
||||
<p>canvas的坐标系为平面直角坐标系,以屏幕左上角为原点,屏幕上边为x轴正方向,屏幕左边为y轴正方向。例如分辨率为1920*1080的屏幕上,画一条从屏幕左上角到屏幕右下角的线段为:</p>
|
||||
<pre><code>canvas.drawLine(0, 0, 1080, 1920, paint);
|
||||
</code></pre><p>canvas的绘制依赖于画笔Paint, 通过设置画笔的粗细、颜色、填充等可以改变绘制出来的图形。例如绘制一个红色实心正方形为:</p>
|
||||
<pre><code>var paint = new Paint();
|
||||
//设置画笔为填充,则绘制出来的图形都是实心的
|
||||
paint.setStyle(Paint.STYLE.FILL);
|
||||
//设置画笔颜色为红色
|
||||
paint.setColor(colors.RED);
|
||||
//绘制一个从坐标(0, 0)到坐标(100, 100)的正方形
|
||||
canvas.drawRect(0, 0, 100, 100, paint);
|
||||
</code></pre><p>如果要绘制正方形的边框,则通过设置画笔的Style来实现:</p>
|
||||
<pre><code>var paint = new Paint();
|
||||
//设置画笔为描边,则绘制出来的图形都是轮廓
|
||||
paint.setStyle(Paint.STYLE.STROKE);
|
||||
//设置画笔颜色为红色
|
||||
paint.setColor(colors.RED);
|
||||
//绘制一个从坐标(0, 0)到坐标(100, 100)的正方形
|
||||
canvas.drawRect(0, 0, 100, 100, paint);
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -125,10 +125,8 @@ http.get("www.baidu.com", {}, function(res, err){
|
||||
<pre><code>console.show();
|
||||
var r = http.get("www.baidu.com", {
|
||||
headers: {
|
||||
"Accept-Language": "zh-cn,zh;q=0.5",
|
||||
"User-Agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X
|
||||
10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56
|
||||
Safari/535.11"
|
||||
'Accept-Language': 'zh-cn,zh;q=0.5',
|
||||
'User-Agent': 'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11'
|
||||
}
|
||||
});
|
||||
log("code = " + r.statusCode);
|
||||
|
||||
@@ -75,11 +75,11 @@
|
||||
<h2>目录</h2>
|
||||
<ul>
|
||||
<li><span class="stability_2"><a href="#shell_shell">shell函数</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#shell_shell_cmd_root_false">shell(cmd[, root = false])</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#shell_shell_cmd_root">shell(cmd[, root])</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><span class="stability_2"><a href="#shell_shell_1">Shell</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#shell_shell_root_false">Shell(root = false)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#shell_new_shell_root">new Shell(root)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#shell_shell_exec_cmd">Shell.exec(cmd)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#shell_shell_exit">Shell.exit()</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#shell_shell_exitandwaitfor">Shell.exitAndWaitFor()</a></span></li>
|
||||
@@ -155,7 +155,7 @@
|
||||
<li>通过内嵌终端模拟器执行(RootAutomator, Shell等对象)</li>
|
||||
</ul>
|
||||
<h1>shell函数<span><a class="mark" href="#shell_shell" id="shell_shell">#</a></span></h1>
|
||||
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><h2>shell(cmd[, root = false])<span><a class="mark" href="#shell_shell_cmd_root_false" id="shell_shell_cmd_root_false">#</a></span></h2>
|
||||
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><h2>shell(cmd[, root])<span><a class="mark" href="#shell_shell_cmd_root" id="shell_shell_cmd_root">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li>cmd <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要执行的命令</li>
|
||||
<li>root <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><Boolean></a> 是否以root权限运行,默认为false。</li>
|
||||
@@ -177,9 +177,9 @@ if(result.code == 0){
|
||||
}
|
||||
</code></pre><h1>Shell<span><a class="mark" href="#shell_shell_1" id="shell_shell_1">#</a></span></h1>
|
||||
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><p>shell函数通过用来一次性执行单条命令并获取结果。如果有多条命令需要执行,用Shell对象的效率更高。这是因为,每次运行shell函数都会打开一个单独的shell进程并在运行结束后关闭他,这个过程需要一定的时间;而Shell对象自始至终使用同一个shell进程。</p>
|
||||
<h2>Shell(root = false)<span><a class="mark" href="#shell_shell_root_false" id="shell_shell_root_false">#</a></span></h2>
|
||||
<h2>new Shell(root)<span><a class="mark" href="#shell_new_shell_root" id="shell_new_shell_root">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li>root <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><Boolean></a> 是否以root权限运行一个shell进程。这将会影响其后使用该Shell对象执行的命令的权限</li>
|
||||
<li>root <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><Boolean></a> 是否以root权限运行一个shell进程,默认为false。这将会影响其后使用该Shell对象执行的命令的权限</li>
|
||||
</ul>
|
||||
</div><p>Shell对象的"构造函数"。</p>
|
||||
<pre><code>var sh = new Shell(true);
|
||||
|
||||
@@ -103,7 +103,7 @@ storages无法像Web开发中LocalStorage一样提供根据域名独立的存储
|
||||
</ul>
|
||||
</div><p>创建一个本地存储并返回一个<code>Storage</code>对象。不同名称的本地存储的数据是隔开的,而相同名称的本地存储的数据是共享的。</p>
|
||||
<p>例如在一个脚本中,创建名称为ABC的存储并存入a=123:</p>
|
||||
<pre><code>var storage = stroages.create("ABC");
|
||||
<pre><code>var storage = storages.create("ABC");
|
||||
storage.put("a", 123);
|
||||
</code></pre><p>而在另一个脚本中是可以获取到ABC以及a的值的:</p>
|
||||
<pre><code>var storage = storages.create("ABC");
|
||||
|
||||
@@ -143,8 +143,14 @@
|
||||
<li><span class="stability_undefined"><a href="#ui_circle">circle</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><span class="stability_undefined"><a href="#ui_vertical">垂直布局: vertical</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#ui_horizontal">水平布局: horizontal</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#ui_vertical">垂直布局: vertical</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#ui_layout_weight">layout_weight</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><span class="stability_undefined"><a href="#ui_horizontal">水平布局: horizontal</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#ui_layout_weight_1">layout_weight</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><span class="stability_undefined"><a href="#ui_linear">线性布局: linear</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#ui_frame">帧布局: frame</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#ui_relative">相对布局: relative</a></span></li>
|
||||
@@ -621,12 +627,80 @@ ui.layout(
|
||||
<p>指定该图片控件的图片是否剪切为圆形显示。如果为<code>true</code>,则图片控件会使其宽高保持一致(如果宽高不一致,则保持高度等于宽度)并使圆形的半径为宽度的一半。</p>
|
||||
<p>例如,圆形的Auto.js图标:<code><img w="100" h="100" circle="true" bg="white" src="http://www.autojs.org/assets/uploads/profile/3-profileavatar.png" /></code></p>
|
||||
<h1>垂直布局: vertical<span><a class="mark" href="#ui_vertical" id="ui_vertical">#</a></span></h1>
|
||||
<p>垂直布局是一种比较简单的布局,会把在它里面的控件按照垂直方向依次摆放,如下图所示:</p>
|
||||
<p>垂直布局:</p>
|
||||
<p> —————</p>
|
||||
<p>| 控件1 |</p>
|
||||
<p>| 控件2 |</p>
|
||||
<p>| 控件3 |</p>
|
||||
<p>| ............ |</p>
|
||||
<p> ——————</p>
|
||||
<h2>layout_weight<span><a class="mark" href="#ui_layout_weight" id="ui_layout_weight">#</a></span></h2>
|
||||
<p>垂直布局中的控件可以通过<code>layout_weight</code>属性来控制控件高度占垂直布局高度的比例。如果为一个控件指定<code>layout_weight</code>, 则这个控件的高度=垂直布局剩余高度 * layout_weight / weightSum;如果不指定weightSum, 则weightSum为所有子控件的layout_weight之和。所谓"剩余高度",指的是垂直布局中减去没有指定layout_weight的控件的剩余高度。
|
||||
例如:</p>
|
||||
<pre><code>"ui";
|
||||
ui.layout(
|
||||
<vertical h="100dp">
|
||||
<text layout_weight="1" text="控件1" bg="#ff0000"/>
|
||||
<text layout_weight="1" text="控件2" bg="#00ff00"/>
|
||||
<text layout_weight="1" text="控件3" bg="#0000ff"/>
|
||||
</vertical>
|
||||
);
|
||||
</code></pre><p>在这个布局中,三个控件的layout_weight都是1,也就是他们的高度都会占垂直布局高度的1/3,都是33.3dp.
|
||||
再例如:</p>
|
||||
<pre><code>"ui";
|
||||
ui.layout(
|
||||
<vertical h="100dp">
|
||||
<text layout_weight="1" text="控件1" bg="#ff0000"/>
|
||||
<text layout_weight="2" text="控件2" bg="#00ff00"/>
|
||||
<text layout_weight="1" text="控件3" bg="#0000ff"/>
|
||||
</vertical>
|
||||
);
|
||||
</code></pre><p>在这个布局中,第一个控件高度为1/4, 第二个控件为2/4, 第三个控件为1/4.
|
||||
再例如:</p>
|
||||
<pre><code>"ui";
|
||||
ui.layout(
|
||||
<vertical h="100dp" weightSum="5">
|
||||
<text layout_weight="1" text="控件1" bg="#ff0000"/>
|
||||
<text layout_weight="2" text="控件2" bg="#00ff00"/>
|
||||
<text layout_weight="1" text="控件3" bg="#0000ff"/>
|
||||
</vertical>
|
||||
);
|
||||
</code></pre><p>在这个布局中,因为指定了weightSum为5, 因此第一个控件高度为1/5, 第二个控件为2/5, 第三个控件为1/5.
|
||||
再例如:</p>
|
||||
<pre><code>"ui";
|
||||
ui.layout(
|
||||
<vertical h="100dp">
|
||||
<text h="40dp" text="控件1" bg="#ff0000"/>
|
||||
<text layout_weight="2" text="控件2" bg="#00ff00"/>
|
||||
<text layout_weight="1" text="控件3" bg="#0000ff"/>
|
||||
</vertical>
|
||||
);
|
||||
</code></pre><p>在这个布局中,第一个控件并没有指定layout_weight, 而是指定高度为40dp, 因此不加入比例计算,此时布局剩余高度为60dp。第二个控件高度为剩余高度的2/3,也就是40dp,第三个控件高度为剩余高度的1/3,也就是20dp。</p>
|
||||
<p>垂直布局的layout_weight属性还可以用于控制他的子控件高度占满剩余空间,例如:</p>
|
||||
<pre><code>"ui";
|
||||
ui.layout(
|
||||
<vertical h="100dp">
|
||||
<text h="40dp" text="控件1" bg="#ff0000"/>
|
||||
<text h="40dp" text="控件2" bg="#00ff00"/>
|
||||
<text layout_weight="1" text="控件3" bg="#0000ff"/>
|
||||
</vertical>
|
||||
);
|
||||
</code></pre><p>在这个布局中,第三个控件的高度会占满除去控件1和控件2的剩余空间。</p>
|
||||
<h1>水平布局: horizontal<span><a class="mark" href="#ui_horizontal" id="ui_horizontal">#</a></span></h1>
|
||||
<p>水平布局是一种比较简单的布局,会把在它里面的控件按照水平方向依次摆放,如下图所示:
|
||||
水平布局:
|
||||
————————————————————————————</p>
|
||||
<p>| 控件1 | 控件2 | 控件3 | ... |</p>
|
||||
<p> ————————————————————————————</p>
|
||||
<h2>layout_weight<span><a class="mark" href="#ui_layout_weight_1" id="ui_layout_weight_1">#</a></span></h2>
|
||||
<p>水平布局中也可以使用layout_weight属性来控制子控件的<strong>宽度</strong>占父布局的比例。和垂直布局中类似,不再赘述。</p>
|
||||
<h1>线性布局: linear<span><a class="mark" href="#ui_linear" id="ui_linear">#</a></span></h1>
|
||||
<p>实际上,垂直布局和水平布局都属于线性布局。线性布局有一个orientation的属性,用于指定布局的方向,可选的值为<code>vertical</code>和<code>horizontal</code>。</p>
|
||||
<p>例如<code><linear orientation="vertical"></linear></code>相当于<code><vertical></vertical></code>。</p>
|
||||
<p>线性布局的默认方向是横向的,因此,一个没有指定orientation属性的线性布局就是横向布局。</p>
|
||||
<h1>帧布局: frame<span><a class="mark" href="#ui_frame" id="ui_frame">#</a></span></h1>
|
||||
<p>帧布局</p>
|
||||
<h1>相对布局: relative<span><a class="mark" href="#ui_relative" id="ui_relative">#</a></span></h1>
|
||||
<h1>勾选框控件: checkbox<span><a class="mark" href="#ui_checkbox" id="ui_checkbox">#</a></span></h1>
|
||||
<h1>选择框控件: radio<span><a class="mark" href="#ui_radio" id="ui_radio">#</a></span></h1>
|
||||
|
||||
Reference in New Issue
Block a user