Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource


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


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.


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.


                <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(;
  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);