processing实现canvas飞龙在天动画效果代码

代码语言:html

所属分类:动画

代码描述:processing实现canvas飞龙在天动画效果代码,一直西方的龙在天空中飞翔。

代码标签: processing canvas飞龙 天空 飞翔 动画

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


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

<head>

  <meta charset="UTF-8">

  
  
  
<style>
* {
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
}

body {
  background: #fff;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
body canvas {
  box-shadow: 0.2em 0.2em 2em #0008;
  border: none;
  outline: none;
  border-radius: 1em;
}
</style>



</head>

<body  >
  <canvas id="canvas"></canvas>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/processing.min.js"></script>
  
      <script id="rendered-js" >
var sketchProc = function(processingInstance) {
     with (processingInstance) {
        size(600, 600); 
       
        frameRate(60);
       
        var scene;

        var Dragon = function() {
            this.x = 200;
            this.y = 200;
            this.w = 150;
            this.h = 100;
            this.vx = 0;
            this.vy = 0;
            this.segments = [];
            this.timer = 0;
            this.speed = 4;
            this.lift = 3;
            this.showLegs = true;
            this.wing = {
                x1: 0,
                y1: 0,
                x2: 0,
                y2: 0,
                x3: 0,
                y3: 0,
                x4: 0,
                y4: 0,
                spines: {
                    a: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 0
                    },
                    b: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 0
                    },
                    c: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 0
                    },
                    d: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 0
                    }
                }
            };
            this.nodes = [
                10,
                14,
                12,
                18,
                23,
                28,
                37,
                42,
                50,
                50,
                46,
                42,
                35,
                28,
                22,
                18,
                15,
                14,
                11,
                9,
                8,
                7,
                5,
                3,
                2,
                1,
                1,
                1
            ];
            this.m = 0;
            this.m2 = 0;
            this.diff = 0;
            this.colorThemes = {
                red: {
                    spikes: color(71, 14, 7),
                    black: color(56, 55, 46),
                    body: color(128, 14, 14),
                    wingArm: color(107, 8, 8),
                    wingArmSpike: color(76, 77, 76),
                    wingUpper: color(122, 32, 16),
                    wingLower: color(148, 46, 33),
                    wingSpines: color(71, 70, 71, 150),
                    legsBehind: color(110, 13, 13)
                },
                green: {
                    spikes: color(18, 46, 4),
                    black: color(120, 110, 20),
                    body: color(33, 82, 16),
                    wingArm: color(39, 77, 10),
                    wingArmSpike: color(76, 77, 76),
                    wingUpper: color(44, 82, 15),
                    wingLower: color(49, 110, 25),
                    wingSpines: color(71, 70, 71, 150),
                    legsBehind: color(30, 77, 14)
                },
                black: {
                    spikes: color(55, 56, 55),
                    black: color(99, 96, 67),
                    body: color(31, 29, 31),
                    wingArm: color(60, 71, 51),
                    wingArmSpike: color(76, 77, 76),
                    wingUpper: color(22, 23, 21),
                    wingLower: color(38, 46, 35),
                    wingSpines: color(64, 64, 64, 150),
                    legsBehind: color(3, 3, 3)
                }
            };
            this.colors = this.colorThemes.red;

            this.setup = function() {
                for(var i = 0; i <= 27; i++) {
                    this.segments.push({
                       x: this.x + this.w * i / 27,
                       y: this.y
                    });
              .........完整代码请登录后点击上方下载按钮下载查看

网友评论0