canvas实现连杆机械拼字动画效果代码

代码语言:html

所属分类:动画

代码描述:canvas实现连杆机械拼字动画效果代码

代码标签: canvas 连杆 机械 拼字 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    body{
  height:100%;
  /*background: radial-gradient(#00d2ff, #3a7bd5);*/
  background:black;
}
canvas{
  display:block;
  margin:0 auto;
  margin:calc(50vh - 150px) auto;
}
</style>

</head>
<body>
<!-- partial:index.partial.html -->
<canvas id="canvas">Su navegador no soporta canvas :( </canvas>
<!-- partial -->
  <script >
      
      var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var cw = canvas.width = 500,
  cx = cw / 2;
var ch = canvas.height = 300,
  cy = ch / 2;
var rad = Math.PI / 180;
var tim = .025;
var hate = true;
ctx.fillStyle = "hsla(45,90%,50%,.7)";
ctx.strokeStyle = "hsla(45,60%,40%,1)";


function Segment(x,y,w,h,rot){
  this.x = x;
  this.y = y;
  this.w = w;
  this.h = h;
  this.rot = rot*rad;
  this.pin = this.getPin();
  this.bool = true;
}
Segment.prototype.draw = function(){
  var h = this.h;
  var w = this.w;
  //var d = w + h;// diagonal ???
  var cr = h/2 // corner radius
  
  ctx.save();
  ctx.fillStyle = Grd();
  ctx.translate(this.x,this.y);
  ctx.rotate(this.rot);
  ctx.scale(this.scalex,this.scaley)
  ctx.beginPath();
  ctx.moveTo(0, -.........完整代码请登录后点击上方下载按钮下载查看

网友评论0