Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.sound.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <script src="sketch.js"></script>
  </body>
</html>

              
            
!

CSS

              
                html, body {
  margin: 0;
  padding: 0;
}

              
            
!

JS

              
                function setup() {
	createCanvas(windowWidth, windowHeight);
}

// reverse the hex() --> RGB()
let toRGB = (color16String) =>{
	let colorRBG = {
		R:0,
		G:0,
		B:0
	}
	colorRBG.R = parseInt(color16String.substring(0,2),16);
	colorRBG.G = parseInt(color16String.substring(2,4),16);
	colorRBG.B = parseInt(color16String.substring(4,6),16);
	return colorRBG;
}

let secondsColor = toRGB('FD2065');
let minitesColor = toRGB('C4FF02');
let hoursColor = toRGB('03FFA9');
let backgroundColor = toRGB('333366');
let radius = 150;
let distance = 0;
let secondsAngle = 0;
let minitesAngle = 0;
let hoursAngle = 0;
function draw() {
  
	// background is the first thing you have to do
	// before you draw anything else
	background(0);	
	strokeWeight(43);
	noFill();

	// get the time now
	let nowTime = new Date();
  // get the millisecond to smooth the seconds angle
	let secondes = nowTime.getSeconds() * 1000 + nowTime.getMilliseconds();
	let minites = nowTime.getMinutes();
	let hours = nowTime.getHours();
  
	// mapping the time to the angle
	secondsAngle = map(secondes, 0, 60 * 1000, 1, 360);
	minitesAngle = map(minites, 0, 60, 1, 360);
	hoursAngle = map(hours % 12, 0, 12, 1, 360);
  
  // secondes circle
	stroke(secondsColor.R, secondsColor.G, secondsColor.B);	
	arc(windowWidth / 2, windowHeight / 2, radius * 2, radius * 2, - PI / 2, secondsAngle * PI / 180 - PI / 2);
  
	// minites circle
	stroke(minitesColor.R, minitesColor.G, minitesColor.B);	
	arc(windowWidth / 2, windowHeight / 2, radius * 2 - 100, radius * 2 - 100, -PI / 2, minitesAngle * PI / 180 - PI / 2)
  
	// hours circle
	stroke(hoursColor.R, hoursColor.G, hoursColor.B);	
	arc(windowWidth / 2, windowHeight / 2, radius * 2 - 200, radius * 2 - 200, -PI / 2, hoursAngle * PI / 180 - PI / 2)
}	
              
            
!
999px

Console