Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              var sketchProc = function(processingInstance) {
	with(processingInstance) {
		size(400, 400);
		var Winston = function(nickname, age, x, y) {
			this.nickname = nickname;
			this.age = age + "yrs old";
			this.x = x;
			this.y = y;
		//1.1 prototype 連接建構子與畫圖函數
		//1.2 裡面的物件資料要用this指定
		Winston.prototype.draw = function() {
			// face
			fill(255, 255, 0);
			ellipse(this.x, this.y, 90, 90); 
			fill(46, 46, 41);
			// eyes
			ellipse(this.x - 20, this.y - 20, 15, 15); 
			ellipse(this.x + 24, this.y - 25, 15, 15);
			fill(252, 65, 65);
			// mouth
			ellipse(this.x + 13, this.y + 18, 40, 40); 
			var txt = this.nickname + ", " + this.age;
			text(txt, this.x-40, this.y - 60);
		//3 嘗試接其他函數:talk
		Winston.prototype.talk = function() {
			text("I'm Winston!", this.x-30, this.y+70);
		//new 呼叫建構子函數
		var winstonTeen = new Winston("Winsteen", 15, 100, 200);
		var winstonAdult = new Winston("Mr. Winst-a-lot", 30, 229, 200);
		//2 prototype接好後,呼叫draw
		//4 呼叫talk函數


// Get the canvas that Processing-js will use
var canvas = document.getElementById("mycanvas");
// Pass the function sketchProc (defined in myCode.js) to Processing's constructor.
var processingInstance_ = new Processing(canvas, sketchProc);
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.