HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
// ZIM is a JavaScript Canvas Framework for coding creativity!
// https://zimjs.com - please visit to start a wonderful coding journey.
// The main site has banner sections of TEN excellent uses of ZIM.
// ZIM provides many conveniences, components and controls
// to help designers, developers and artists create interactive media
// https://zimjs.com/about.html - why ZIM, features, applications
// https://zimjs.com/docs.html - expand open any feature for info and examples
// Here are CodePen examples with comments for learning:
// https://codepen.io/zimjs/pens/public - ZIM CodePen
// https://codepen.io/danzen/pens/public - ZIM Founder's CodePen
// https://codepen.io/zimjs/post/welcome-to-zim-on-codepen
// There are also many tutorials, videos and references here:
// https://zimjs.com/learn.html - ZIM Skool, ZIM Kids, ZIM Badges, etc.
// https://zimjs.com/code.html - ZIM Template, tools and more
// https://zimjs.com/slack/ - join us on *** Slack *** for discussion and support
// -----------------
// ZIM is powered by CreateJS so we import CreateJS and ZIM in CodePen settings
// We make a Frame object which makes a stage on an HTML canvas
// We then add objects to the stage and update the stage to see them
const scaling = "fit"; // this will resize to fit inside the screen dimensions
const width = 1024;
const height = 768;
const color = green;
const outerColor = yellow;
// as of ZIM 5.5.0 you do not need to put zim before ZIM functions and classes
const frame = new Frame(scaling, width, height, color, outerColor);
frame.on("ready", ()=>{
zog("ready from ZIM Frame"); // logs in console (F12 - choose console)
const stage = frame.stage;
const stageW = frame.width;
const stageH = frame.height;
const darkgreen = "#84a131";
const darkergreen = "#55691d";
const darkBlue = "#449188";
const darkPink = "#c65ba8";
// Create the data for the RadialMenu
// SIMPLE HIERARCHY with EXTRA
// allows addition of styles - to style specific rings
// and use ZIM PICK (VEE) to style colors for specific buttons
const data = {
list:{ // use object literal if list has more lists inside
"smooth things":{
list:{
"shapes":{
// use array literal if all items are leaf nodes (end nodes)
list:["oval","circle","wave","petal","arc","feather"],
styles:{backgroundColor:darkPink}
},
"materials":{
list:["velvet","velour","angora","silk","microfiber","spandex"],
styles:{backgroundColor:darkPink}
},
"gigolos":{
list:["hey baby","come here often","see my etchings","what's your sign"],
styles:{backgroundColor:darkPink}
},
"sounds":{
list:["jazz","world","new wave","trance","ambient","tango"],
styles:{backgroundColor:darkPink}
}
},
styles:{
backgroundColor:pink,
rollBackgroundColor:darkPink,
rollColor:white,
selectedBackgroundColor:darkPink,
selectedRollBackgroundColor:darkPink
}
},
"sharp things":{
list:{
"shapes":{
// an array is okay as all items are leaf nodes (end nodes)
list:["triangle","spike","spade","saw-tooth","crescent","star"],
styles:{backgroundColor:darkBlue}
},
"items":{
list:["swords","pins","knives","glass","tacks","cheese"],
styles:{backgroundColor:darkBlue}
},
"sounds":{
list:["bang","snap","crash","clap","snap","ring"],
styles:{backgroundColor:darkBlue}
}
},
styles:{
backgroundColor:blue,
rollBackgroundColor:darkBlue,
rollColor:white,
selectedBackgroundColor:darkBlue,
selectedRollBackgroundColor:darkBlue
}
},
},
styles:{
// first ring
rollColor:white,
selectedRollColor:white,
backgroundColor:series(pink, blue),
rollBackgroundColor:series(pink, blue),
selectedBackgroundColor:series(pink, blue),
selectedRollBackgroundColor:series(pink, blue)
}
}
var menu = new RadialMenu({
menu:data,
open:true,
gradient:.1,
// default colors - may be overridden by styles in menu data
backgroundColor:dark,
selectedBackgroundColor:dark,
selectedRollColor:white,
rollBackgroundColor:white,
rollColor:dark,
// totalAngle:320,
// startAngle:-160
})
.center()
.mov(-20,30)
.sca(0)
.animate({
wait:2500,
time:500,
ease:"backOut",
props:{scale:.8}
})
.tap(()=>{ // also a change() method
if (menu.leafNode) {
new Tip({
text:menu.text,
align:RIGHT,
valign:MIDDLE,
backgroundColor:grey
}).sca(.7).show();
}
});
// TITLE WORK using LabelLetters() to animate each letter
const title = new Label({
text:"ZIM can be smooth, loose and groovy",
color:purple
}).loc(30,40).alp(.6);
// LabelLetters breaks label up into individual letters
// here, each gets a registration point at the center and bottom
const one = new LabelLetters(title, CENTER, BOTTOM, 0)
.alp(.6)
.loc(title)
.animate({
props:{y:"20"}, // relative 20 from current y
wait:100,
time:320,
sequence:30,
rewind:true,
call:function(target){
// leaving two copies of text on text slightly reduces quality
// so remove copies after animating and bring up alpha of original
one.removeFrom();
two.removeFrom();
title.alp(.9)
}
});
const two = one.clone()
.addTo() // clone keeps location and alpha properties too
.animate({
props:{y:"-20"},
wait:100, // try a wait of 800
time:320,
sequence:30,
rewind:true
});
const titleTwo = new Label({
text:"or ZIM can be sharp, fast and serious!",
color:darker
});
new LabelLetters(titleTwo)
.sca(.76)
.alp(.6)
.loc(30,90)
.animate({
from:true,
wait:1900,
time:100,
set:{scaleY:4},
props:{alpha:0, scaleY:1},
sequence:12
});
// DOCS FOR ITEMS USED
// https://zimjs.com/docs.html?item=Frame
// https://zimjs.com/docs.html?item=Label
// https://zimjs.com/docs.html?item=Tip
// https://zimjs.com/docs.html?item=tap
// https://zimjs.com/docs.html?item=change
// https://zimjs.com/docs.html?item=animate
// https://zimjs.com/docs.html?item=loc
// https://zimjs.com/docs.html?item=mov
// https://zimjs.com/docs.html?item=alp
// https://zimjs.com/docs.html?item=sca
// https://zimjs.com/docs.html?item=addTo
// https://zimjs.com/docs.html?item=removeFrom
// https://zimjs.com/docs.html?item=center
// https://zimjs.com/docs.html?item=timeout
// https://zimjs.com/docs.html?item=zog
// FOOTER
// call remote script to make ZIM Foundation for Creative Coding icon
createIcon();
timeout(3500, ()=>{
createGreet();
});
}); // end of ready
Also see: Tab Triggers