cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="canvas-wrap">
    <canvas id="sineCanvas" width="1920" height="240"></canvas>
</div>


            
          
!
            
              body {
  margin: 0;
  padding: 0;
}

#canvas-wrap {
    padding-top: 360px;
    background-image: url(http://creatornote.nakweb.com/wp-content/themes/giraffe/images/wave.jpg);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}
canvas {
    width: 100%;
    height: 240px;
    vertical-align: top;
}

@media only screen and (max-width: 959px) {

#canvas-container {
    padding-top: 100px;
}
canvas {
    height: 200px;
}

}
            
          
!
            
              (function () {

var unit = 100,
    canvas, context, canvas2, context2,
    height, width, xAxis, yAxis,
    draw;

function init() {
canvas = document.getElementById("sineCanvas");
canvas.width = document.documentElement.clientWidth; 
//キャンバスをウィンドウの幅に合わせる
canvas.height = 240;
context = canvas.getContext("2d");
height = canvas.height;
width = canvas.width;
    
xAxis = Math.floor(height/2);
yAxis = 0;
 draw();
}

function draw() {
 // キャンバスの描画を一度クリアにする
 context.clearRect(0, 0, width, height);
//波~
    drawWave('#ffffff', 0.3, 3, 0);
    drawWave('#ffffff', 0.4, 2, 250);
    drawWave('#ffffff', 0.2, 1.6, 100);
    
    draw.seconds = draw.seconds + .014;
    draw.t = draw.seconds*Math.PI;
    setTimeout(draw, 35);
};
draw.seconds = 0;
draw.t = 0;

/**
* 波(色,波幅のzoom,  不透明度, 波の開始位置の遅れを指示)
*/
function drawWave(color, alpha, zoom, delay) {
    context.fillStyle = color;
    context.globalAlpha = alpha;

    context.beginPath(); //パススタート
    drawSine(draw.t / 0.5, zoom, delay);
    context.lineTo(width + 10, height); //右下へ
    context.lineTo(0, height); //左下へ
    context.closePath() //パスエンド
    context.fill(); //塗りつぶし
}


function drawSine(t, zoom, delay) {
    var x = t; //時間軸を横に
    var y = Math.sin(x)/zoom;
    context.moveTo(yAxis, unit*y+xAxis); //パスをスタートに置く
    
    // 横幅の波を描く
    for (i = yAxis; i <= width + 10; i += 10) {
        x = t+(-yAxis+i)/unit/zoom;
        y = Math.sin(x - delay)/3;
        context.lineTo(i, unit*y+xAxis);
    }
}
init();  
})();
            
          
!
999px
Loading ..................

Console