Advertisement
Mangus875

Color Functions

Dec 11th, 2023
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getType(obj) {
  2.     if (obj === null) return 'null';
  3.     if (obj === undefined) return 'undefined';
  4.     return obj.__proto__.constructor.name;
  5. }
  6.  
  7. const color = {};   // table to hold different color related classes and functions
  8. color.mono = class mono {
  9.     constructor(v) {
  10.         this.v = this.value = v;
  11.     }
  12. }
  13. color.rgb = class rgb {
  14.     constructor(r, g, b) {
  15.         this.r = this.red = r;
  16.         this.g = this.green = g;
  17.         this.b = this.blue = b;
  18.     }
  19.     get G() {
  20.         return `Green: '${this.g}'`;
  21.     }
  22.     get GRN = G;
  23. }
  24. color.toHex = function toHex(col) {
  25.     console.log(getType(col));
  26. }
  27. color.map = class map { // an object to store and create color gradients
  28.     constructor(numRange, colRange, interpFunc) {
  29.     }
  30. }
  31.  
  32. new color.rgb(255, 189, 20).G;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement