p5实现立体圆环俯视交换位置动画效果代码

代码语言:html

所属分类:动画

代码描述:p5实现立体圆环俯视交换位置动画效果代码

代码标签: p5 立体 圆环 俯视 交换 位置 动画

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  


  
  
<style>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: black;
}
</style>

  
</head>

<body >
  
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.4.0.js"></script>
      <script>

let img1, img2;
let goods;
let cnt = 0;

function preload() {
  img1 = loadImage("//repo.bfw.wiki/bfwrepo/images/exchange/exchange.jpg");
  img2 = loadImage("//repo.bfw.wiki/bfwrepo/images/exchange/star.png");
}

function setup() {
  createCanvas(600, 600);
  strokeWeight(0.5);
  angleMode(DEGREES);
  stroke(80, 68, 97);
  imageMode(CENTER);
  fill(200, 200, 255, 10);
  noStroke();
  goods = [];
  nI = 15;
  r = 150;
  for (let i = 0; i < nI; i++) {
    goods.push(new Item(r * cos((i * 360) / nI), r * sin((i * 360) / nI), i));
  }
  n1 = floor(random(0, nI - 0.001));
  n2 = floor(random(0, nI - 0.001));
  p1 = createVector(goods[n1].x, goods[n1].y);
  p2 = createVector(goods[n2].x, goods[n2].y);
}

function draw() {
  translate(width / 2, height / 2);
  t = frameCount / 2;
  push();
  cnt++;
  rotate(-cnt / 40);
  image(img1, 0, 0, 900, 900);
  pop();
  // stroke(255);
  strokeWeight(0.8);.........完整代码请登录后点击上方下载按钮下载查看

网友评论0