[][src]Static p5_sys::global::cylinder

pub static cylinder: CylinderInternalType

Draw a cylinder with given radius and height

DetailX and detailY determines the number of subdivisions in the x-dimension and the y-dimension of a cylinder. More subdivisions make the cylinder seem smoother. The recommended maximum value for detailX is 24. Using a value greater than 24 may cause a warning or slow down the browser.

Examples

// draw a spinning cylinder
// with radius 20 and height 50
function setup() {
  createCanvas(100, 100, WEBGL);
}

function draw() {
  background(205, 105, 94);
  rotateX(frameCount * 0.01);
  rotateZ(frameCount * 0.01);
  cylinder(20, 50);
}
// slide to see how detailX works
let detailX;
function setup() {
  createCanvas(100, 100, WEBGL);
  detailX = createSlider(3, 24, 3);
  detailX.position(10, height + 5);
  detailX.style('width', '80px');
}

function draw() {
  background(205, 105, 94);
  rotateY(millis() / 1000);
  cylinder(20, 75, detailX.value(), 1);
}
// slide to see how detailY works
let detailY;
function setup() {
  createCanvas(100, 100, WEBGL);
  detailY = createSlider(1, 16, 1);
  detailY.position(10, height + 5);
  detailY.style('width', '80px');
}

function draw() {
  background(205, 105, 94);
  rotateY(millis() / 1000);
  cylinder(20, 75, 16, detailY.value());
}

Parameters

radius? radius of the surface

height? height of the cylinder

detailX? number of subdivisions in x-dimension; default is 24

detailY? number of subdivisions in y-dimension; default is 1

bottomCap? whether to draw the bottom of the cylinder

topCap? whether to draw the top of the cylinder