Skip to content

Instantly share code, notes, and snippets.

@osteele
Created May 4, 2021 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osteele/3e6dc02251ed0cf5f663a021046ca1e3 to your computer and use it in GitHub Desktop.
Save osteele/3e6dc02251ed0cf5f663a021046ca1e3 to your computer and use it in GitHub Desktop.
CCLab Spring 2021 Exercise 13.1
let HORIZONTAL = "HORIZONTAL";
let VERTICAL = "VERTICAL";
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
let whiteColor = color(255, 255, 255);
let blackColor = color(0, 0, 0);
let redColor = color(255, 0, 0);
let greenColor = color(0, 255, 0);
let blueColor = color(0, 0, 255);
gradientRect(10, 20, 100, 50, redColor, blackColor, HORIZONTAL);
gradientRect(10, 100, 100, 50, redColor, whiteColor, VERTICAL);
gradientRect(150, 20, 100, 50, blackColor, greenColor, HORIZONTAL);
gradientRect(150, 100, 100, 50, whiteColor, greenColor, VERTICAL);
gradientRect(300, 20, 100, 50, blueColor, makeTransparent(blueColor), HORIZONTAL);
gradientRect(300, 100, 100, 50, blueColor, makeTransparent(blueColor), VERTICAL);
}
function gradientRect() {
}
function makeTransparent(c) {
return colorWithAlpha(c, 0);
}
function colorWithAlpha(c, a) {
return color(red(c), green(c), blue(c), a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment