Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <div id="app">
  <div>{{ message}}</div>
  <!-- Canvas -->
  <div id="zim"></div>
  <!-- Add Rectangle Button -->
  <div>
    <button @click="drawRect">Add Rect</button>
    <button @click="subWidth">-</button>
    <button @click="addWidth">+</button>
  </div>
</div>
              
            
!

CSS

              
                #app {
  padding: 20px;
  margin: 20px;
}

              
            
!

JS

              
                    const app = new Vue({
        el: '#app',
        data: {
            message: 'Vue + ZIM',
            rectWidth: 200
        },
        mounted() {
            // store a reference to vue for inside the ZIM Frame
            const vue = this;
            const frame = new Frame("zim", 300, 200, yellow);
            frame.on("ready", ()=>{
                
                // store refrerences to the stage and rect 
                // so VUE can access them from its methods
                // store local variables if we want to access them in the ZIM code
                const stage = vue.stage = frame.stage;   
                
                // we do not add the rect yet - as there is a VUE button to do that
                // access the VUE rectWidth data
                const rect = vue.rect = new Rectangle(vue.rectWidth, 150, purple);               
            
                stage.update(); // if there was something to update - which there is not in this simple example
            });
        },
        methods: {
            drawRect() {
                this.rect.center();
                this.stage.update();  
            },
            addWidth() {
                // widthOnly is the ZIM property 
                // setting width would proportially set the height 
                this.rect.widthOnly += 10;
                this.rect.center(); // optional
                this.stage.update();   
            },
            subWidth() {
                this.rect.widthOnly -= 10;
                this.rect.center();
                this.stage.update();    
            }
        }
    });




              
            
!
999px

Console