From t-o-f

P5js: Dessiner en fonction de la taille du canevas

Variables de système de la taille du canevas

width
height

Trouver le centre avec une multiplication

var centreHorizontal = width * 0.5;
var centreVertical = height * 0.5;

Trouver le centre avec une division

var centreHorizontal = width / 2;
var centreVertical = height / 2;

Exemples

Récupéré sur http://wiki.t-o-f.info/P5js/DessinerEnFonctionDeLaTailleDuCanevas
Page mise à jour le 24 January 2017 à 16h23