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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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>

              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,

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;

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);
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................