/*
软件作者:https://xuhss.com/oxox/pro
*/
/**
* 原文链接: https://blog.csdn.net/zzy1078689276/article/details/46042627
* 翻译: 家
* QQ: 203118908
*/
"ui";
ui.layout(
<vertical>
<canvas id="board" layout_weight="1"/>
</vertical>
);
//线程
var t; // private Thread
//弧度
PI = Math.PI / 180; // private static final double
//图片
offScreenImage = null; // Image
//绘图
offScreenBuffer = null; // Graphics
//定义绘图域的宽和高
width = 600, height = 600;
//判断状态
dstatus = true;
//设定初始值
D = -10, K = 40;
var myPaint = new Paint();
myPaint.setColor(colors.RED);
myPaint.setStrokeWidth(5);
ui.board.on("draw", function(canvas) {
canvas.drawColor(colors.BLACK);
javaPaint(canvas,myPaint)
});
// g是canvas
//开始绘图 g Graphics
function javaPaint(g,myPaint) {
myPaint.setColor(rndColor());
//枝条的左右摆幅
if (dstatus) {
D += 0.2;
if (D >= 10) {
dstatus = false;
}
} else {
D -= 0.2;
if (D <= -10) {
dstatus = true;
}
}
//摆动的速率
if (K < 60) {
K += 0.2;
}
//清空绘图区域
// offScreenBuffer.clearRect(0, 0, width, height);
//绘图方法
drawSilkTreeLeaf(g, 220, 350, 30, 270, K, D,myPaint);
//绘图
}
//绘图方法 Graphics g,double x,double y,double L,double a,float K,float D
function drawSilkTreeLeaf(g, x, y, L, a, K, D) {
var x1, y1, x2, y2, x1L, y1L, x1R, y1R, x2L, y2L, x2R, y2R;
if (L > 2) {
//主干
x2 = x + L * Math.cos(a * PI);
y2 = y + L * Math.sin(a * PI);
//左上侧树枝
x2L = x2 + L / 3 * Math.cos((a - K) * PI);
y2L = y2 + L / 3 * Math.sin((a - K) * PI);
//右上侧树枝
x2R = x2 + L / 3 * Math.cos((a + K) * PI);
y2R = y2 + L / 3 * Math.sin((a + K) * PI);
//主干较短
x1 = x + L / 3 * Math.cos(a * PI);
y1 = y + L / 3 * Math.sin(a * PI);
//左下侧树枝
x1L = x1 + L / 3 * Math.cos((a - K) * PI);
y1L = y1 + L / 3 * Math.sin((a - K) * PI);
//右下侧树枝
x1R = x1 + L / 3 * Math.cos((a + K) * PI);
y1R = y1 + L / 3 * Math.sin((a + K) * PI);
// g.setColor(Color.blue);
//画出枝条
// log(g)
g.drawLine(x, y, x2, y2,myPaint);
g.drawLine(x2, y2, x2L, y2L,myPaint);
g.drawLine(x2, y2, x2R, y2R,myPaint);
g.drawLine(x, y, x1, y1,myPaint);
g.drawLine(x1, y1, x1L, y1L,myPaint);
g.drawLine(x1, y1, x1R, y1R,myPaint);
//迭代绘图
drawSilkTreeLeaf(g, x2, y2, L / 1.1, a + D, K, D);
drawSilkTreeLeaf(g, x2L, y2L, L / 3, a - K, K, D);
drawSilkTreeLeaf(g, x2R, y2R, L / 3, a + K, K, D);
drawSilkTreeLeaf(g, x1L, y1L, L / 3, a - K, K, D);
drawSilkTreeLeaf(g, x1R, y1R, L / 3, a + K, K, D);
}
}
function rndColor() {
return colors.rgb(random(0, 255), random(0, 255), random(0, 255))
}
没有合适的资源?快使用搜索试试~ 我知道了~
AutoJs源码-叶子。本资源购买前提醒:本源码都是实际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)
![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)
收起资源包目录
![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)