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.
//this code is in need of clean up and commenting.
let warpR = [];
let warpG = [];
let warpB = [];
let weftR = [];
let weftG = [];
let weftB = [];
let rnd = 1
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
}
function draw() {
background(0)
setColor()
for (let i=0;i<40;i++){
fill(warpR[i],warpG[i],warpB[i])
rect(5+25*i,0,20,width)
}//warp
t = frameCount*5;
for(let k=0;k<30;k++){
fill(weftR[k],weftG[k],weftB[k])
p = 0
if (k%2 == 0){
p = 30
}
rect(0,5+k*25,t,20)//weft
for(let i=0;i<40;i++){
fill(warpR[i],warpG[i],warpB[i])
p = 5
if (k%2 ==0 && i%2!=0){
rect(p+25*i,p+k*25,20,20)
if(k>0&&i>0)
fill(warpR[i-1],warpG[i-1],warpB[i-1])
rect(p+25*i-25,p+(k-1)*25,20,20)
}
}
}
if (frameCount*3 > width){
frameCount = 0;
rnd = rnd +1;
if (rnd == 11){
rnd = 1;
}
}
}
function setColor(){
round1()
round2()
round3()
round4()
round5()
round6()
round7()
round8()
round9()
round10()
round11()
}
function round1(){
if (rnd == 1){
for (let i=0;i<40;i++){
warpR[i]=255
warpG[i]=255
warpB[i]=255
weftR[i]=200
weftG[i]=200
weftB[i]=255
if (i%2 ==0){
weftR[i]=100
weftG[i]=200
weftB[i]=255
}
}
}
}
function round2(){
if (rnd == 2){
for (let i=0;i<40;i++){
warpR[i]=7*i
warpG[i]=255-15*i
warpB[i]=255-10*i
weftR[i]=15*i
weftG[i]=255-20*i
weftB[i]=255-15*i
}
}
}
function round3(){
if (rnd == 3){
for (let i=0;i<40;i++){
warpR[i]=255
warpG[i]=255
warpB[i]=255
weftR[i]=240
weftG[i]=240
weftB[i]=245
if (i%3 ==0){
warpR[i]=250
warpG[i]=200
warpB[i]=200
}
if(i%3 ==0){
weftR[i]=230
weftG[i]=180
weftB[i]=180
}
}
}
}
function round4(){
if (rnd == 4){
for (let i=0;i<40;i=i+3){
warpR[i]=10
warpG[i]=110
warpB[i]=160
warpR[i+1]=30
warpG[i+1]=150
warpB[i+1]=200
warpR[i+2]=50
warpG[i+2]=200
warpB[i+2]=255
weftR[i]=00
weftG[i]=100
weftB[i]=150
weftR[i+1]=20
weftG[i+1]=140
weftB[i+1]=190
weftR[i+2]=40
weftG[i+2]=180
weftB[i+2]=240
}
}
}
function round5(){
if (rnd == 4){
for (let i=0;i<40;i=i+4){
warpR[i]=10
warpG[i]=110
warpB[i]=160
warpR[i+1]=255
warpG[i+1]=255
warpB[i+1]=255
warpR[i+2]=100
warpG[i+2]=200
warpB[i+2]=255
warpR[i+3]=10
warpG[i+3]=110
warpB[i+3]=160
weftR[i]=00
weftG[i]=100
weftB[i]=150
weftR[i+1]=240
weftG[i+1]=240
weftB[i+1]=240
weftR[i+2]=40
weftG[i+2]=180
weftB[i+2]=240
weftR[i+3]=40
weftG[i+3]=180
weftB[i+3]=240
}
}
}
function round6(){
if (rnd == 6){
for (let i=0;i<40;i++){
warpR[i]=200
warpG[i]=200
warpB[i]=200
weftR[i]=210
weftG[i]=210
weftB[i]=210
if (i%4 ==0){
warpR[i]=200
warpG[i]=100
warpB[i]=100
weftR[i]=210
weftG[i]=110
weftB[i]=110
}
}
}
}
function round7(){
if (rnd == 7){
for (let i=0;i<40;i++){
warpR[i]=200
warpG[i]=200
warpB[i]=200
weftR[i]=210
weftG[i]=210
weftB[i]=210
if (i%5 ==0){
warpR[i]=200
warpG[i]=100
warpB[i]=100
weftR[i]=210
weftG[i]=110
weftB[i]=110
}
}
}
}
function round8(){
if (rnd == 8){
for (let i=0;i<40;i++){
warpR[i]=200
warpG[i]=200
warpB[i]=200
weftR[i]=210
weftG[i]=210
weftB[i]=210
if (i%6 ==0||i%2==0){
warpR[i]=200
warpG[i]=100
warpB[i]=100
weftR[i]=210
weftG[i]=110
weftB[i]=110
}
if (i%5 ==0 || i%4==0){
warpR[i]=100
warpG[i]=100
warpB[i]=100
weftR[i]=110
weftG[i]=110
weftB[i]=110
}
}
}
}
function round9(){
if (rnd == 9){
for (let i=0;i<40;i++){
warpR[i]=i*3
warpG[i]=i*4
warpB[i]=i*5
weftR[i]=i*3.1
weftG[i]=i*4.1
weftB[i]=i*5.1
if (i%2 ==0){
warpR[i]=i*3
warpG[i]=i*2
warpB[i]=i*1.5
weftR[i]=i*3.1
weftG[i]=i*2.1
weftB[i]=i*1.6
}
}
}
}
function round10(){
if (rnd == 10){
for (let i=0;i<40;i++){
warpR[i]=40
warpG[i]=80
warpB[i]=40
weftR[i]=50
weftG[i]=90
weftB[i]=50
if (i>0){
warpR[i]=40 + 30*(i%5)
warpG[i]=80 + 30*(i%5)
warpB[i]=40 + 30*(i%5)
weftR[i]=50 + 30*(i%5)
weftG[i]=90 + 30*(i%5)
weftB[i]=50 + 30*(i%5)
}
}
}
}
function round11(){
if (rnd == 11){
for (let i=0;i<40;i++){
warpR[i]=100
warpG[i]=50
warpB[i]=40
weftR[i]=110
weftG[i]=60
weftB[i]=50
if (i>0){
warpR[i]=100 + 30*(i%3)
warpG[i]=50 + 30*(i%3)
warpB[i]=40 + 30*(i%3)
weftR[i]=110 + 30*(i%3)
weftG[i]=60 + 30*(i%3)
weftB[i]=50 + 30*(i%3)
}
}
}
}
Also see: Tab Triggers