API: AB P5 1.0

API Uses canvas Graphics libraries AB framework Worlds using this API Starter Worlds
AB P5 1.0 Yes P5 Yes 20 Worlds Starter Worlds


This API is for P5 Worlds. It comes with an Ancient Brain framework to make writing Worlds easier. This would require changes to existing P5 worlds. So this is really for writing new P5 Worlds for this platform.

This API has the following features:

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

  • Automatically creates a canvas in a div in the run window.
  • The author can use P5 functions to create graphics on the canvas.
  • The Ancient Brain framework ("newRun" and "nextStep") conflicts with the P5 way of doing things ("setup" and "draw"). So this is really for writing new P5 Worlds for this platform.
  • For run control, the author can use either P5 framework or Ancient Brain framework. See below.
  • No built-in user camera control.

Related APIs



Global variables

This API defines the following global variables:
 

 ABWorld;       // instance of class ABWorldClass - basic functionality for this API
 

The "ABWorld" object

The public variables and methods of "ABWorld" are as follows:

 
		
  // create canvas with some background color	
  // this defines a setup() function and calls P5's createCanvas() function
  
	ABWorld.init ( color );  
	
	
  // The object returned by P5's createCanvas() function

	ABWorld.p5canvas;	

	
 // The object corresponding to p5canvas.canvas 
 
	ABWorld.canvas;		
				


Important: Do not define a setup() function

P5 uses global functions setup() and draw(). This API defines its own setup() function internally to create the canvas. Hence in your World:

  1. Do not define a setup() function.
  2. The World can define optional beforesetup() and aftersetup() functions for code it wants run just before canvas creation and just after canvas creation.

The draw() function is optional. This API uses nextStep() or takeAction() to do the run loop, so you can put the code in there, or in a draw() function.



Templates


Examples

Examples of Worlds that use this API:


Scare the Fishes!
By Enhanced  
Scare the fishes with your mouse ! If you click they will flee even further away. Includes twea...
P5 Mouse tracker
By Starter user  
Example of P5 World integrated with AB framework. Desktop: Draw ellipse wherever the mouse hover...
The Game of Life
By Enhanced  
The famous Game of Life. Click on the screen to place the initial cells and then click start ! ...

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

© 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