栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

剑气纵横-autojs动画

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

剑气纵横-autojs动画

牙叔教程 简单易懂

"ui";
engines.all().map((scriptEngine) => {
  if (engines.myEngine().toString() !== scriptEngine.toString()) {
    scriptEngine.forceStop();
  }
});
importClass("android.animation.ValueAnimator");
importClass("android.content.Context");
importClass("android.graphics.Matrix");
importClass("android.graphics.PorterDuffXfermode");
importClass("android.graphics.PorterDuff");
importClass("android.graphics.Color");
importClass("android.util.AttributeSet");
importClass("android.view.View");
importClass("android.view.animation.RotateAnimation");
ui.layout(
  
    
  
);

// 设置画笔参数
let paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
color = colors.parseColor("#ffffff");
paint.setColor(color);

// 设置动画参数
let anim = ValueAnimator.ofFloat(0, -360);
anim.repeatCount = android.view.animation.Animation.INFINITE;
anim.setDuration(1000);
anim.setInterpolator(null);
anim.start();
let camera = android.graphics.Camera();
let rotateMatrix = Matrix();
let xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OUT);
/* -------------------------------------------------------------------------- */
ui.post(function () {
  let width = ui.board.getWidth();
  let height = ui.board.getHeight();
  // log(width.toFloat());
  ui.board.on("draw", function (canvas) {
    canvas.drawColor(Color.BLACK);
    color = "#ff0000";
    drawSword(canvas, 35, -45, 0, width, height, color);
    color = "#00ff00";
    drawSword(canvas, 50, 10, 120, width, height, color);
    color = "#0000ff";
    drawSword(canvas, 35, 55, 240, width, height, color);
  });
});

function drawSword(canvas, rotateX, rotateY, startValue, width, height, color) {
  let colorNum = colors.parseColor(color);
  paint.setColor(colorNum);
  let layerId = canvas.saveLayer(0, 0, width, height, null, android.graphics.Canvas.ALL_SAVE_FLAG);
  rotateMatrix.reset();
  camera.save();
  /* ----------------相机旋转---------------------------------------------------------- */
  camera.rotateX(rotateX);
  camera.rotateY(rotateY);
  camera.rotateZ(anim.animatedValue + startValue);
  camera.getMatrix(rotateMatrix);
  camera.restore();
  /* -------------------------------------------------------------------------- */

  let halfW = width / 2;
  let halfH = height / 2;
  let radius = Math.min(width, height) / 4;
  rotateMatrix.preTranslate(-halfW, -halfH);
  rotateMatrix.postTranslate(halfW, halfH);
  canvas.concat(rotateMatrix);
  canvas.drawCircle(halfW, halfH, radius, paint);
  paint.xfermode = xfermode;
  canvas.drawCircle(halfW, halfH - 0.05 * radius, radius * 1.01, paint);
  canvas.restoreToCount(layerId);
  paint.xfermode = null;
}

活动

官方渠道免费领取爱奇艺7天vip会员,真实有效!!!

参考

Android 炫酷自定义 View - 剑气加载

名人名言

思路是最重要的, 其他的百度, bing, stackoverflow, 安卓文档, autojs文档, 最后才是群里问问
— 牙叔教程

声明

部分内容来自网络
本教程仅用于学习, 禁止用于其他用途

bilibili

牙叔教程

微信公众号 牙叔教程

QQ群

747748653

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/287824.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号