API: Plain P5 1.0

API Uses canvas Graphics libraries AB framework Worlds using this API Starter Worlds
Plain P5 1.0 Yes P5 No 195 Worlds Starter Worlds

This API is for P5 Worlds. It has no Ancient Brain framework. Anything written in P5 should run using this API without change.

This API has the following features:

  • Includes P5 graphics library, release 0.7.1.
  • Includes jQuery 3.3.1.

  • No Ancient Brain framework.
  • World has to do everything. It has to create its own canvas. It has to do its own camera control.
  • World author writes normal P5 code, with setup() and draw().
  • Run header on RHS. Many P5 worlds use fixed small dimension canvas, which will go in top LHS. So this API puts run header on RHS.
  • If World uses Minds, World author must call the Mind themselves inside the draw function:
     ABRun.mind.getAction ( state );  

Related APIs

Optional: The "ABWorld" object

This API defines the following "ABWorld" global variable. World authors can ignore the existence of ABWorld entirely.

	ABWorld;                 // instance of class ABWorldClass  
// Data and methods of ABWorld:
	ABWorld.canvas;          // to point to the canvas  		
	// useful functions for creating/resizing canvas:

	ABWorld.fullwidth();     // return full width of window on desktop / screen on mobile 
	ABWorld.fullheight();    // return full height of window on desktop / screen on mobile

World code can normally createCanvas() and ignore return. The created canvas should display in the run window. The AB system will find the canvas automatically (e.g. when it needs to do a screenshot). If the canvas does not display normally, or if the AB system fails to find the canvas, you can help it out by creating the canvas as follows:

	var canvas = createCanvas ( width, height );		 

	ABWorld.setCanvas ( canvas );           // tell the AB system where the canvas is 



Examples of Worlds that use this API:

One Cube World (P5)
By Starter user  
Simple starter World (P5 version). No camera control. So cube rotates to show 3D.
Tutorial 7.8
By "Coding Train" p...  
Objects and Images. On Ancient Brain you can upload your own images. Try it!
P5 Particle System
By Starter user  
Port of P5 site's "Particle System" example with almost no change. P5 plain API. No AB framework...
P5 chase World
By Starter user  
Example of World with Mind on P5 plain API. No AB framework. Have to call Mind yourself. Mind mo...
Tutorial 7.8 variant
By "Coding Train" p...  
Tutorial 7.8 with music and other uploaded images, including from other users. Click on the images.
Tutorial 2.1
By "Coding Train" p...  
Variables in p5.js (mouseX, mouseY)
Tutorial 18.7
By "Coding Train" p...  
Tutorial 18.7 with full canvas, resized model, sound. Texture on box is image from another user.

The background is a program, showing the JavaScript graphics used on this site.

© Ancient Brain Ltd. All rights reserved.

Ancient Brain ™ is a trademark of Ancient Brain Ltd.

Beta      Contact      Stats      The name      Terms and conditions

Bug bounty      Course in Dublin      Call for partners