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.


Auto Save

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.


                <p><h2>Rect with fill opacity but stroke unaltered </h2></p>
  <input type="range" id="opacity" name="opacity"
         min="0" max="100" value="50" step="0.01">
  <label for="opacity">Fill opacity</label>

<p><span id="scaleTbl"></span><span id="scaleMsg"></span></p>
<div id='container'  ></div>  
<script src=""></script> 


                body {
  margin: 14px;
  padding: 10px;
  font: 12pt Verdana, Arial, sans-serif;
#container {
  width: 400px;
  height: 200px;
  border: 1px solid red;
p {
  margin: 4px;


                const settings = {
    stroke: 'red',
    fill: 'lime',
    opacity: 0.5

// add a stage
let stage = new Konva.Stage({container: 'container', width: 400, height: 200 }),
    layer = new Konva.Layer({ draggable: true}), // Add a layer and group to draw on
    rect = new Konva.Rect({x: 50, y: 50, width: 100, height: 100, strokeWidth: 10, stroke: settings.stroke, fill: settings.fill}),
    rect2 = rect.clone({x: 250})

layer.add(rect, rect2);
$('#opacity').on('input', function(){
  const opacity = parseInt($(this).val()) / 100;
  // Use Konva.Util to get the color parts
  const colorParts = Konva.Util.getRGB(settings.fill); 

  function getHex(val){
        return (val.toString(16).length < 2)?'0'+ val.toString(16) : val.toString(16);
  const fill = '#' + getHex(colorParts.r) + getHex(colorParts.g) +  getHex(colorParts.b) + getHex(Math.floor(255 * opacity));

  // Notice - no opacity property is set here now !!
  rect.setAttrs({fill: fill})