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

              
                
              
            
!

CSS

              
                /* these styles remove the space & scrollbars around the canvas */  
body {margin:0; padding:0;}  
canvas {display:block;}
              
            
!

JS

              
                //THE SUN 001

//GLOBAL VARS
var radius = 50;
var layers = 5;
var lines_each = 200;
var weight = 1;

var origin_set = [0, 0]

//SETUP
function setup() {  
    // initialize the canvas & graphics state:  
  canvas = createCanvas(windowWidth, windowHeight);
	translate(width/2, height/2);	//this is what (0,0) is considered to be
  background(255);
	strokeWeight(weight);
	strokeCap(SQUARE);
	stroke(0);
	fill(0);
	
	origin_set = [width/2, height/2];

	drawImage(0,0);
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
	origin_set = [width/2, height/2]
	background(255);
	drawImage(origin_set[0], origin_set[1]);
}

//FUNCTIONS

//(x,y) is for the desired center position of this generated image
function drawImage(x,y){
	//this loop is for each LAYER
	for(let q=0; q<layers; q++){
		//this loop is for each LINE
		for(let w=0; w<lines_each; w++){
			//randomize a new angle for the next line
			let theta = random(TWO_PI);
			//draw the next line
			line(
				//from
				q * radius * sin(theta) + x,
				q * radius * cos(theta) + y,
				//to
				(q+1) * radius * sin(theta) + x,
				(q+1) * radius * cos(theta) + y
			);
		}
	}
	
}

function mouseReleased(){
	//if the mouse is pressed down and then released, re-draw the image
	background(255);
	drawImage(origin_set[0], origin_set[1]);
}

//SAVE A SCREENSHOT BY PRESSING S
function keyTyped() {
  if (key === 's' || key === 'S') {
    saveCanvas('myCanvas', 'png');
  	}
  }

              
            
!
999px

Console