Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <canvas id="c"></canvas>
              
            
!

CSS

              
                @import "compass/css3";

@import "compass/reset";
@import "compass/css3";

body{
  overflow: hidden;
}

canvas{
  width: 100%;
  height: 100%;
}
              
            
!

JS

              
                var l1Pt0 = [
    [0.6905, 0.534],
    [0.648, 0.534],
    [0.638, 0.565],
    [0.6154999999999999, 0.565],
    [0.6579999999999999, 0.4445],
    [0.6809999999999999, 0.4445],
    [0.7234999999999999, 0.565],
    [0.701, 0.565],
    [0.6905, 0.534]
];
var l1Pt1 = [
    [0.6695, 0.46549999999999997],
    [0.6695, 0.46549999999999997, 0.667, 0.4775, 0.6645, 0.484],
    [0.654, 0.5165],
    [0.6855000000000001, 0.5165],
    [0.6750000000000002, 0.484],
    [0.6725, 0.4775, 0.6695, 0.46549999999999997, 0.6695, 0.46549999999999997],
    [0.6695, 0.46549999999999997]
];
var l2Pt0 = [
    [0.7559999999999999, 0.4445],
    [0.795, 0.4445],
    [0.8079999999999999, 0.4445, 0.8140000000000001, 0.44550000000000006, 0.8195, 0.44800000000000006],
    [0.8315, 0.4535, 0.8390000000000001, 0.4650000000000001, 0.8390000000000001, 0.48100000000000004],
    [0.8390000000000001, 0.49550000000000005, 0.8315, 0.509, 0.8185000000000001, 0.514],
    [0.8185000000000001, 0.5145],
    [0.8185000000000001, 0.5145, 0.8200000000000002, 0.5159999999999999, 0.8225000000000001, 0.5205],
    [0.8475000000000001, 0.5655],
    [0.8230000000000001, 0.5655],
    [0.799, 0.5205],
    [0.7780000000000001, 0.5205],
    [0.7780000000000001, 0.5655],
    [0.7560000000000001, 0.5655],
    [0.7559999999999999, 0.4445],
    [0.7559999999999999, 0.4445]
];
var l2Pt1 = [
    [0.7975, 0.501],
    [0.809, 0.501, 0.8165, 0.494, 0.8165, 0.48200000000000004],
    [0.8165, 0.47050000000000003, 0.8115000000000001, 0.4635, 0.7945, 0.4635],
    [0.778, 0.4635],
    [0.778, 0.501],
    [0.7975, 0.501],
    [0.7975, 0.501]
];
var l3Pt0 = [
    [0.885, 0.4445],
    [0.9259999999999999, 0.4445],
    [0.963, 0.4445, 0.9875, 0.4665000000000001, 0.9875, 0.5045000000000001],
    [0.9875, 0.5425, 0.963, 0.565, 0.9259999999999999, 0.565],
    [0.885, 0.565],
    [0.885, 0.4445]
];
var l3Pt1 = [
    [0.9245, 0.5465],
    [0.9490000000000001, 0.5465, 0.9645, 0.5319999999999999, 0.9645, 0.505],
    [0.9645, 0.478, 0.9485000000000001, 0.4635, 0.9245, 0.4635],
    [0.9065000000000001, 0.4635],
    [0.9065000000000001, 0.5465000000000001],
    [0.9245, 0.5465000000000001]
];
var l4 = [
    [1.0265, 0.534],
    [1.0265, 0.534, 1.0395, 0.5469999999999999, 1.0565, 0.5469999999999999],
    [1.0655000000000001, 0.5469999999999999, 1.074, 0.5425, 1.074, 0.5325],
    [1.074, 0.5109999999999999, 1.0170000000000001, 0.5145, 1.0170000000000001, 0.4774999999999999],
    [1.0170000000000001, 0.4574999999999999, 1.0345, 0.44249999999999995, 1.0575, 0.44249999999999995],
    [1.0815000000000001, 0.44249999999999995, 1.0935, 0.4554999999999999, 1.0935, 0.4554999999999999],
    [1.0839999999999999, 0.47349999999999987],
    [1.0839999999999999, 0.47349999999999987, 1.0724999999999998, 0.4629999999999999, 1.0574999999999999, 0.4629999999999999],
    [1.0474999999999999, 0.4629999999999999, 1.0394999999999999, 0.4689999999999999, 1.0394999999999999, 0.4774999999999999],
    [1.0394999999999999, 0.4989999999999999, 1.0964999999999998, 0.49349999999999994, 1.0964999999999998, 0.5325],
    [1.0964999999999998, 0.5514999999999999, 1.0819999999999999, 0.568, 1.0565, 0.568],
    [1.0294999999999999, 0.568, 1.015, 0.5514999999999999, 1.015, 0.5514999999999999],
    [1.0265, 0.534]
];
var l5 = [
    [0.4435, 0.4445],
    [0.4235, 0.528],
    [0.42200000000000004, 0.535, 0.4215, 0.5405000000000001, 0.4215, 0.5405000000000001],
    [0.42100000000000004, 0.5405000000000001],
    [0.42100000000000004, 0.5405000000000001, 0.42050000000000004, 0.5345, 0.419, 0.528],
    [0.3975, 0.4445],
    [0.3785, 0.4445],
    [0.3565, 0.528],
    [0.3545, 0.535, 0.3545, 0.5405000000000001, 0.3545, 0.5405000000000001],
    [0.354, 0.5405000000000001],
    [0.354, 0.5405000000000001, 0.35350000000000004, 0.5345, 0.352, 0.528],
    [0.33799999999999997, 0.4655],
    [0.3275, 0.511],
    [0.341, 0.565],
    [0.3665, 0.565],
    [0.385, 0.4935],
    [0.387, 0.48550000000000004, 0.38799999999999996, 0.4775, 0.38799999999999996, 0.4775],
    [0.38849999999999996, 0.4775],
    [0.38849999999999996, 0.4775, 0.38949999999999996, 0.4855, 0.3914999999999999, 0.4935],
    [0.4099999999999999, 0.565],
    [0.435, 0.565],
    [0.466, 0.4445],
    [0.4435, 0.4445],
    [0.4435, 0.4445]
];
var l6 = [
    [0.5795, 0.4445],
    [0.5595, 0.528],
    [0.558, 0.535, 0.5575, 0.5405000000000001, 0.5575, 0.5405000000000001],
    [0.557, 0.5405000000000001],
    [0.557, 0.5405000000000001, 0.5565000000000001, 0.5345, 0.555, 0.528],
    [0.5335, 0.4445],
    [0.5145000000000001, 0.4445],
    [0.4925, 0.528],
    [0.4905, 0.535, 0.4905, 0.5405000000000001, 0.4905, 0.5405000000000001],
    [0.49, 0.5405000000000001],
    [0.49, 0.5405000000000001, 0.48950000000000005, 0.5345, 0.488, 0.528],
    [0.474, 0.465],
    [0.4635, 0.5105],
    [0.47700000000000004, 0.565],
    [0.5025, 0.565],
    [0.521, 0.4935],
    [0.523, 0.48550000000000004, 0.524, 0.4775, 0.524, 0.4775],
    [0.5245, 0.4775],
    [0.5245, 0.4775, 0.5255, 0.4855, 0.5275, 0.4935],
    [0.5459999999999999, 0.565],
    [0.5714999999999999, 0.565],
    [0.6024999999999999, 0.4445],
    [0.5795, 0.4445],
    [0.5795, 0.4445]
];
var l7 = [
    [0.13, 0.534],
    [0.0875, 0.534],
    [0.0775, 0.565],
    [0.055, 0.565],
    [0.0975, 0.4445],
    [0.12050000000000001, 0.4445],
    [0.163, 0.565],
    [0.1405, 0.565],
    [0.13, 0.534],
    [0.109, 0.46549999999999997],
    [0.109, 0.46549999999999997, 0.1065, 0.4775, 0.10400000000000001, 0.484],
    [0.0935, 0.5165],
    [0.125, 0.5165],
    [0.11449999999999999, 0.484],
    [0.11199999999999999, 0.4775, 0.109, 0.46549999999999997, 0.109, 0.46549999999999997],
    [0.109, 0.46549999999999997]
];
var l8 = [
    [0.2825, 0.528],
    [0.2845, 0.535, 0.2845, 0.5405, 0.2845, 0.5405],
    [0.285, 0.5405],
    [0.285, 0.5405, 0.28550000000000003, 0.5345, 0.287, 0.528],
    [0.307, 0.44449999999999995],
    [0.3295, 0.44449999999999995],
    [0.2985, 0.565],
    [0.273, 0.565],
    [0.2545, 0.4935],
    [0.2525, 0.48550000000000004, 0.2515, 0.4775, 0.2515, 0.4775],
    [0.251, 0.4775],
    [0.251, 0.4775, 0.24999999999999997, 0.4855, 0.24799999999999997, 0.4935],
    [0.22949999999999998, 0.565],
    [0.204, 0.565],
    [0.174, 0.4445],
    [0.19649999999999998, 0.4445],
    [0.21549999999999997, 0.528],
    [0.21699999999999997, 0.535, 0.21749999999999997, 0.5405000000000001, 0.21749999999999997, 0.5405000000000001],
    [0.21799999999999997, 0.5405000000000001],
    [0.21799999999999997, 0.5405000000000001, 0.21849999999999997, 0.5345, 0.21999999999999997, 0.528],
    [0.24199999999999997, 0.4445],
    [0.26099999999999995, 0.4445],
    [0.2825, 0.528]
];


var kenjiArr = [l1Pt0, l1Pt1, l2Pt0, l2Pt1, l3Pt0, l3Pt1, l4, l5, l6, l7, l8];

var size = 400;
if (size > window.innerHeight) size = window.innerHeight * .8;
var textNumber = 90;
var kenjiPtArrs = [];

for (var ii = 0; ii < kenjiArr.length; ii++) {
    kenjiPtArrs[ii] = [];

    var kankakuDuration = parseInt(textNumber / kenjiArr[ii].length) + 1;
    var curNumber = textNumber;

    for (var jj = 0; jj < kenjiArr[ii].length; jj++) {
        for (var kk = 0; kk < kankakuDuration; kk++) {
            var ptX, ptY;

            var rate = kk / kankakuDuration;
            var curNum = jj;
            var nextNum = (jj + 1) % kenjiArr[ii].length;

            if (kenjiArr[ii][nextNum].length == 6) {
                //ptX = kenjiArr[ii][curNum][0] * size * (1 - rate) +  kenjiArr[ii][nextNum][0] * size * rate;
                //ptY = kenjiArr[ii][curNum][1] * size * (1 - rate) +  kenjiArr[ii][nextNum][1] * size * rate;
                var x1, y1, x2, y2, x3, y3, x4, y4;
                if (kenjiArr[ii][curNum].length == 2) {
                    x1 = kenjiArr[ii][curNum][0] * size;
                    y1 = kenjiArr[ii][curNum][1] * size;
                } else if (kenjiArr[ii][curNum].length == 6) {
                    x1 = kenjiArr[ii][curNum][4] * size;
                    y1 = kenjiArr[ii][curNum][5] * size;
                }

                x2 = kenjiArr[ii][nextNum][0] * size;
                y2 = kenjiArr[ii][nextNum][1] * size;
                x3 = kenjiArr[ii][nextNum][2] * size;
                y3 = kenjiArr[ii][nextNum][3] * size;
                x4 = kenjiArr[ii][nextNum][4] * size;
                y4 = kenjiArr[ii][nextNum][5] * size;


                ptX = x1 * (1 - rate) * (1 - rate) * (1 - rate) + x2 * 3 * (1 - rate) * (1 - rate) * rate + x3 * 3 * (1 - rate) * rate * rate + rate * rate * rate * x4;
                ptY = y1 * (1 - rate) * (1 - rate) * (1 - rate) + y2 * 3 * (1 - rate) * (1 - rate) * rate + y3 * 3 * (1 - rate) * rate * rate + rate * rate * rate * y4;

            } else {
                if (kenjiArr[ii][curNum].length == 2) {
                    ptX = kenjiArr[ii][curNum][0] * size * (1 - rate) + kenjiArr[ii][nextNum][0] * size * rate;
                    ptY = kenjiArr[ii][curNum][1] * size * (1 - rate) + kenjiArr[ii][nextNum][1] * size * rate;
                } else if (kenjiArr[ii][curNum].length == 6) {
                    ptX = kenjiArr[ii][curNum][4] * size * (1 - rate) + kenjiArr[ii][nextNum][0] * size * rate;
                    ptY = kenjiArr[ii][curNum][5] * size * (1 - rate) + kenjiArr[ii][nextNum][1] * size * rate;
                }
            }

            var pos = {x: ptX - size / 2 - 35, y: ptY - size / 2};
            kenjiPtArrs[ii].push(pos);
        }
        curNumber -= kankakuDuration;
        if (kankakuDuration > curNumber) kankakuDuration = curNumber;
    }
}


// --------------------------

var width, height, prevTime;
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var rot = 0;

width = window.innerWidth;
height = window.innerHeight;

canvas.width = width;
canvas.height = height;


// ================

var Line = function () {

    this.height = 150;
    this.width  = 500;

    this.top =  (height - this.height)/2;
    this.bot = this.top + this.height;
    this.left = (width  - this.width)/2;


    this.x0 = this.left;
    this.x1 = this.width + this.left;

    this.velY = 2;

    this.y = this.top;
};

Line.prototype = {
    update: function () {
        this.y += this.velY;

        if (this.y > this.bot) {
            this.y = this.bot;
            this.velY = -2;
        }

        if (this.y < this.top) {
            this.y = this.top;
            this.velY = 2;
        }
    },

    draw: function () {

        ctx.save();
        ctx.strokeStyle = "#19A598";
        ctx.moveTo(this.x0, this.y);
        ctx.lineTo(this.x1, this.y);
        ctx.stroke();


        ctx.strokeRect(this.left, this.top, this.width, this.height);
        ctx.restore();
    }


};

// ================


var rate;
var line;

init();
loop();


function init() {
    line = new Line();

    prevTime = +new Date;

    //setTimeout(timer, 500);
}

function loop() {
    line.update();

    rot += .1;
    var curTime = +new Date;
    var duration = (curTime - prevTime) / 1000;
    prevTime = curTime;

    ctx.globalCompositeOperation = "source-over";
    ctx.fillStyle = 'rgba(30, 30, 30, .3)';
    ctx.fillRect(0, 0, width, height);



    var biv;

    for(var jj = 0; jj < kenjiPtArrs.length; jj++) {
        ctx.save();
        ctx.beginPath();

        ctx.translate(width / 2, height / 2)

        ctx.strokeStyle = "#19A598";


        for (var i = 0; i < kenjiPtArrs[jj].length; i+= 1) {


            if (line.y - height / 2 > kenjiPtArrs[jj][i].y) biv = 0;
            else                       biv = 10;

            if (i == 0) ctx.moveTo(kenjiPtArrs[jj][i].x + (Math.random() -.5)* biv, kenjiPtArrs[jj][i].y + (Math.random() -.5) * biv);
            else        ctx.lineTo(kenjiPtArrs[jj][i].x + (Math.random() -.5) * biv, kenjiPtArrs[jj][i].y + (Math.random() -.5) * biv);

        }


        if (line.y - height / 2 > kenjiPtArrs[jj][0].y) biv = 0;
        else                       biv = 10;

        ctx.moveTo(kenjiPtArrs[jj][0].x + (Math.random() -.5)* biv, kenjiPtArrs[jj][0].y + (Math.random() -.5) * biv);

        ctx.closePath();
        ctx.stroke();
        ctx.restore();
    }


    //}

    line.draw();

    requestAnimationFrame(loop);
}

function timer() {
    rate = 0;
    TweenLite.to(this, .75, {rate: 1, onUpdate: onUpdateTweenHandler, onComplete: onCompleteTwennHandler, ease: Elastic.easeInOut});

    setTimeout(timer, 1000);
}

function onUpdateTweenHandler() {
    var nextCount = (count + 1) % kenjiPtArrs.length;
    for (var i = 0; i < 360; i++) {

        var xPos = kenjiPtArrs[count][i].x * (1 - rate) + kenjiPtArrs[nextCount][i].x * rate;
        var yPos = kenjiPtArrs[count][i].y * (1 - rate) + kenjiPtArrs[nextCount][i].y * rate;
        curPtArr[i] = {x: xPos, y: yPos};
    }

}

function onCompleteTwennHandler() {
    count = (count + 1) % kenjiPtArrs.length;
}

window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame
              
            
!
999px

Console