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

              
                <h1>
  Welcome to CodePen, Vaqcoders!
  <img width="35px" src="https://vaqcoders.github.io/website/cgi-bin/logo.png">
</h1>

<h3>HTML</h3>
<p>This environment uses three languages to create a simulated webpage. What you are reading is written in HTML, short for HyperText Markup Language; 'Markup' because you <i>see what you write</i>. Please refer to <a target="_blank" href="https://www.w3schools.com/html/default.asp">w3Schools</a> for help regarding HTML.</p>

<h3>JS</h3>
<p>The most interesting and functional, however, is the third window, JS, standing for JavaScript. JavaScript is a <a target="_blank" href="https://en.wikipedia.org/wiki/High-level_programming_language">high-level</a> programming language mainly used on the web. If you are here to learn programming, you should focus on JavaScript out of these three languages. Please refer to <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript">MDN</a> for help regarding native JavaScript. If you wish to use a more simplified environment which exclusively focuses on JavaScript, please use <a target="_blank" href="https://www.khanacademy.org/computer-programming/new/pjs">Khan Academy</a> or the <a target="_blank" href="https://editor.p5js.org/">p5js Editor</a>.</p>

<h3>CSS</h3>
<p>The CSS window in the middle is for <i>style</i>. CSS (Cascading Style Sheet) is the main utility used in webdesign and is primarily used to beautify webpages. Please refer to <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS">MDN</a> for help regarding CSS.</p>

<h3>Vaqcoders,</h3>
<p>So, I am aware that this all may seem scary or too ambitious of a task to take on. Learning to program takes a lot of self-teaching, failure, patience, practice, and frustration, but mainly, <i>self-integrity</i>. This can be compared to exercise, in that you cannot cheat yourself out of working out. If you are truly curious and excited about programming, you will succeed.</p>
<p>Anyways, I invite anyone to <i>fork</i> this pen, get rid of all the code you don't need and initialize a project of your own. This pen already has the <a target="_blank" href="https://p5js.org/reference/">p5.js library</a> and <a target="_blank" href="https://api.jquery.com/">jQuery library</a> built in so that you can have access to drawing capabilities as found on Khan Academy. Also, always remember to save and take breaks here and there, get good grades this year, and have fun! Visit the <a target="_blank" href="https://discord.gg/QjEEs7V">Vaqcoders Discord</a> if you have any questions or wanna chill.</p>

<h3>The Canvas</h3>
<!-- This code here is all you need in order to use the JavaScript canvas -->
<div id="canvas-container"></div>
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
              
            
!

CSS

              
                /* Welcome to CSS. This is the file that styles everything on the HTML file. They communicate with each other to help you make beautiful creations. */

/* Right here, I added some fonts to the global scope of my css file, meaning I can use it throughout the file now by calling it by its name. To do this yourself, visit https://fonts.google.com/, select a few fonts, copy the @import option, and paste it at the top of this file. */
@import url('https://fonts.googleapis.com/css?family=Courgette|Work+Sans');

body {
  /* Here I changed the background color of the entire page to a named color. */
  background-color: palegreen;
}

h1 {
  /* Here I changed the font of my heading element to Courgette with a fallback of Cursive. */
  font-family: 'Courgette', cursive;
  /* Here I center-justified the text in my heading element. */
  text-align: center;
}

h3 {
  /* Here I changed the font of all of my subheading elements to Work Sans with a fallback of Sans-Serif. */
  font-family: 'Work Sans', sans-serif;
  /* Here I changed the margin to align the subheading with the paragraphs. */
  margin-left: 25vw;
}

p {
  /* Here I changed the font of all of my paragraph elements to Work Sans with a fallback of Sans-Serif. */
  font-family: 'Work Sans', sans-serif;
  /* Here I added a small line-spacing. */
  margin-bottom: 1em;
  /* And here, I added an indent for each paragraph. */
  text-indent: 1em;
  /* Here I specified the width of my paragraph elements. */
  max-width: 45vw;
  /* Here I changed the margin to center the text in the middle of the page. */
  margin-left: 25vw;
}

div {
  /* Here I changed the margin to center the text in the middle of the page. */
  margin-left: 25vw;
}
              
            
!

JS

              
                // WELCOME TO JAVASCRIPT
// So, you may be wondering, "Where do I get started?" Well, you're in luck because you are a Vaqcoder!
// The following is just an example. You do not have to understand every little piece of it just yet.
// If you are inspired to learn more, please vist https://www.khanacademy.org/hourofcode/

let cnv, ball;

function setup() {
  cnv = createCanvas(400, 400);
  cnv.parent("canvas-container");
  
  // Here I created a ball object.
  ball = {
    "x": width / 2, // This is ball's x position; it starts in the middle of cnv
    "y": height / 2, // This is ball's y position; it starts in the middle of cnv
    "vx": Math.random() + 1, // This is ball's x velocity; it begins randomly
    "vy": Math.random() + 1, // This is ball's y velocity; it begins randomly
    "r": 50 // This is ball's radius
  };
}

// "What are you doing?" you may be asking. So far, I set up by creating a canvas. 
// I declared the canvas as a variable with the name of cnv.
// The canvas can be seen in the webpage below. I gave it a width of 400px and a height of 400px.
// I assigned its placement to be within a specific div element with an id of 'canvas-container' which can be seen in the HTML.

// This is the draw loop.
// Everything in here happens many times per second, just like the frames of a video.
function draw() {
  
  // This is the background function. It fills the canvas with a specified color.
  // The color is determined by three arguments: red, green, and blue. These numbers range from 0 to 255.
  // For example, 0,0,0 is black, 255,255,255 is white, 0,0,255 is green, and 255,255,0 is yellow.
  background(0, 0, 0);
  //         ^r ^g ^b
  
  // Here, I update the position of ball according to its current velocity.
  ball.x += ball.vx;
  ball.y += ball.vy;
  
  // Here, I check to see if ball collides with the edges of cnv.
  // If it does collide, then it must bonk.
  if (ball.x - ball.r <= 0  || ball.x + ball.r >= width)  ball.vx *= -1;
  if (ball.y  - ball.r <= 0 || ball.y + ball.r >= height) ball.vy *= -1;
  
  // Here, I draw the ball by using the ellipse function.
  // The ellipse function takes four arguments: x position, y position, width across, and height across.
  ellipse(ball.x, ball.y, ball.r * 2, ball.r * 2);
  //      ^ x     ^ y     ^ width     ^ height
}

// Visit https://p5js.org/reference/ for extra info and for discovering other functions to use. If you have any questions, please do not hesitate to ask the Discord server.
// If things begin to seem limited on codepen and Khan Academy, I invite you to visit https://editor.p5js.org/ for a different experience.
// Keep in mind that the setup function and draw function must both be declared in the js file in order to use the p5 library as intended.
              
            
!
999px

Console