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. 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

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

              
                <h2>Animate text around a curved path</h2>
<div>
  <label for="my-text-input">Animated text:</label>
  <input id="my-text-input" class="text-controls" type="text" value="Hello world! Type your text here"/>
</div>

<canvas id="mycanvas" width="600" height="600"></canvas>

<div>
  <label for="spiral-size">Spiral rotation:</label>
  <input id="spiral-roll" class="spiral-controls"  type="range" value="0" min="0" max="360" step="0.1"/>
</div>

<div>
  <label for="spiral-size">Spiral scale:</label>
  <input id="spiral-scale" class="spiral-controls"  type="range" value="40" min="20" max="60" step="0.02"/>
</div>

<div>
  <label for="my-text-size">Font size:</label>
  <input id="my-text-size" class="text-controls"  type="range" value="30" min="16" max="40" step="0.05"/>
</div>

<div>
  <label for="my-text-font">Font family:</label>
      <select class="text-controls" id="my-text-font">
        <option value="sans-serif">sans-serif</option>
        <option value="serif">serif</option>
        <option value="monospace">monospace</option>
        <option value="cursive">cursive</option>
        <option value="fantasy">fantasy</option>
      </select>
</div>

<div>
  <label for="my-text-offset">Font offset:</label>
  <input id="my-text-offset" class="text-controls"  type="range" value="50" min="0" max="80" step="0.1"/>
</div>


              
            
!

CSS

              
                canvas {
  border: 1px dashed red;
  margin-bottom: 1em;
}

input {
  font: 16px monospace;
  margin-bottom: 1em;
  width: 600px;
}

select {
  font: 16px monospace;
  margin-bottom: 1em;
  width: 300px;
}

label {
  font: 16px sans-serif;
  display: block;
}

h2 {
  font-family: sans-serif;  
}
              
            
!

JS

              
                import scrawl from "https://unpkg.com/scrawl-canvas@8.5.2";

let canvas = scrawl.library.canvas.mycanvas;

canvas
  .set({
    backgroundColor: "lemonchiffon"
  })
  .setAsCurrentCanvas();

// Create Gradient
let mygradient = scrawl
  .makeGradient({
    name: "gradient-1",

    endY: "100%",

    paletteStart: 10,
    paletteEnd: 990,

    delta: {
      paletteStart: -2,
      paletteEnd: -2
    },

    cyclePalette: true
  })
  .updateColor(0, "black")
  .updateColor(300, "black")
  .updateColor(499, "red")
  .updateColor(699, "black")
  .updateColor(999, "black");

let spiral = scrawl.makeSpiral({
  name: "spiral-path",

  strokeStyle: "darkgreen",
  method: "draw",

  startX: "center",
  startY: "center",
  handleX: "center",
  handleY: "center",

  loops: 5,
  loopIncrement: 1,
  drawFromLoop: 2,

  scale: 40,
  scaleOutline: false,

  flipUpend: true,
  roll: 30,

  useAsPath: true
});

let pathText = scrawl.makePhrase({
  name: "myPhrase",

  text: "Hello world! Type your text here",
  font: "30px sans-serif",
  justify: "center",

  handleY: "50%",

  fillStyle: mygradient,
  lockFillStyleToEntity: true,

  textPath: spiral,
  textPathPosition: 0.5,

  delta: {
    textPathPosition: -0.0005
  }
});

scrawl.makeRender({
  name: "my-animation",
  target: canvas,
  commence: () => mygradient.updateByDelta()
});

scrawl.observeAndUpdate({
  event: ["input", "change"],
  origin: ".text-controls",

  target: pathText,

  useNativeListener: true,
  preventDefault: true,

  updates: {
    "my-text-input": ["text", "raw"],
    "my-text-size": ["size", "px"],
    "my-text-font": ["family", "raw"],
    "my-text-offset": ["handleY", "%"]
  }
});

scrawl.observeAndUpdate({
  event: ["input", "change"],
  origin: ".spiral-controls",

  target: spiral,

  useNativeListener: true,
  preventDefault: true,

  updates: {
    "spiral-roll": ["roll", "float"],
    "spiral-scale": ["scale", "float"]
  }
});

              
            
!
999px

Console