Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Update version number
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavjitChauhan committed Mar 7, 2021
1 parent 167d6f9 commit ef3a01c
Show file tree
Hide file tree
Showing 23 changed files with 1,202 additions and 1,205 deletions.
240 changes: 120 additions & 120 deletions build/color-essentials-ka.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,79 @@ if (typeof ESSENTIALS_CORE === 'undefined') {
if (!_silent_ && !_color_initialized_) console.info('%cColor Essentials', 'font-family:system-ui;font-size:0.75rem;');
}

angularGradient = function (x, y, width, height, startColor, endColor) {
circularGradient = function (x, y, width, height, startColor, endColor) {
var angle = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
var step = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 5;
angle -= 90;
var dTheta = Math.ceil(e.degrees(Math.atan(step / Math.max(width, height))) * 10) / 10;
push();

if (step == 1) {
e.strokeWeight(1.5);

for (var i = angle; i < angle + 359; i += dTheta) {
e.stroke(e.lerpColor(startColor, endColor, (i - angle) / 360));
for (var i = angle - 1; i < angle + 180; i += dTheta) {
e.stroke(e.lerpColor(startColor, endColor, Math.abs((i - angle) / 180)));
r = e.radians(i);
e.line(x + width / 2, y + height / 2, e.map(Math.cos(r), -1, 1, x, x + width), e.map(Math.sin(r), -1, 1, y, y + height));
}

for (var _i = angle - 1; _i > angle - 180; _i -= dTheta) {
e.stroke(e.lerpColor(startColor, endColor, Math.abs((_i - angle) / 180)));
r = e.radians(_i);
e.line(x + width / 2, y + height / 2, e.map(Math.cos(r), -1, 1, x, x + width), e.map(Math.sin(r), -1, 1, y, y + height));
}
} else {
e.strokeWeight(1);

for (var _i = angle; _i < angle + 359; _i += dTheta) {
var _c = e.lerpColor(startColor, endColor, (_i - angle) / 360);
for (var _i2 = angle - 1; _i2 < angle + 180; _i2 += dTheta) {
var _c = e.lerpColor(startColor, endColor, Math.abs((_i2 - angle) / 180));

e.stroke(_c);
e.fill(_c);
r1 = e.radians(_i);
r2 = e.radians(_i - dTheta);
r1 = e.radians(_i2);
r2 = e.radians(_i2 - dTheta);
e.triangle(x + width / 2, y + height / 2, e.map(Math.cos(r1), -1, 1, x, x + width), e.map(Math.sin(r1), -1, 1, y, y + height), e.map(Math.cos(r2), -1, 1, x, x + width), e.map(Math.sin(r2), -1, 1, y, y + height));
}

r1 = e.radians(angle - 180);
r2 = e.radians(angle - 180 - dTheta);
e.stroke(endColor);
e.fill(endColor);
e.triangle(x + width / 2, y + height / 2, e.map(Math.cos(r1), -1, 1, x, x + width), e.map(Math.sin(r1), -1, 1, y, y + height), e.map(Math.cos(r2), -1, 1, x, x + width), e.map(Math.sin(r2), -1, 1, y, y + height));

for (var _i3 = angle - 1; _i3 > angle - 180; _i3 -= dTheta) {
var _c2 = e.lerpColor(startColor, endColor, Math.abs((_i3 - angle) / 180));

e.stroke(_c2);
e.fill(_c2);
r1 = e.radians(_i3);
r2 = e.radians(_i3 - dTheta);
e.triangle(x + width / 2, y + height / 2, e.map(Math.cos(r1), -1, 1, x, x + width), e.map(Math.sin(r1), -1, 1, y, y + height), e.map(Math.cos(r2), -1, 1, x, x + width), e.map(Math.sin(r2), -1, 1, y, y + height));
}
}

pop();
};

circularGradient = function (x, y, width, height, startColor, endColor) {
angularGradient = function (x, y, width, height, startColor, endColor) {
var angle = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
var step = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 5;
angle -= 90;
var dTheta = Math.ceil(e.degrees(Math.atan(step / Math.max(width, height))) * 10) / 10;
push();

if (step == 1) {
e.strokeWeight(1.5);

for (var i = angle - 1; i < angle + 180; i += dTheta) {
e.stroke(e.lerpColor(startColor, endColor, Math.abs((i - angle) / 180)));
for (var i = angle; i < angle + 359; i += dTheta) {
e.stroke(e.lerpColor(startColor, endColor, (i - angle) / 360));
r = e.radians(i);
e.line(x + width / 2, y + height / 2, e.map(Math.cos(r), -1, 1, x, x + width), e.map(Math.sin(r), -1, 1, y, y + height));
}

for (var _i2 = angle - 1; _i2 > angle - 180; _i2 -= dTheta) {
e.stroke(e.lerpColor(startColor, endColor, Math.abs((_i2 - angle) / 180)));
r = e.radians(_i2);
e.line(x + width / 2, y + height / 2, e.map(Math.cos(r), -1, 1, x, x + width), e.map(Math.sin(r), -1, 1, y, y + height));
}
} else {
e.strokeWeight(1);

for (var _i3 = angle - 1; _i3 < angle + 180; _i3 += dTheta) {
var _c2 = e.lerpColor(startColor, endColor, Math.abs((_i3 - angle) / 180));

e.stroke(_c2);
e.fill(_c2);
r1 = e.radians(_i3);
r2 = e.radians(_i3 - dTheta);
e.triangle(x + width / 2, y + height / 2, e.map(Math.cos(r1), -1, 1, x, x + width), e.map(Math.sin(r1), -1, 1, y, y + height), e.map(Math.cos(r2), -1, 1, x, x + width), e.map(Math.sin(r2), -1, 1, y, y + height));
}

r1 = e.radians(angle - 180);
r2 = e.radians(angle - 180 - dTheta);
e.stroke(endColor);
e.fill(endColor);
e.triangle(x + width / 2, y + height / 2, e.map(Math.cos(r1), -1, 1, x, x + width), e.map(Math.sin(r1), -1, 1, y, y + height), e.map(Math.cos(r2), -1, 1, x, x + width), e.map(Math.sin(r2), -1, 1, y, y + height));

for (var _i4 = angle - 1; _i4 > angle - 180; _i4 -= dTheta) {
var _c3 = e.lerpColor(startColor, endColor, Math.abs((_i4 - angle) / 180));
for (var _i4 = angle; _i4 < angle + 359; _i4 += dTheta) {
var _c3 = e.lerpColor(startColor, endColor, (_i4 - angle) / 360);

e.stroke(_c3);
e.fill(_c3);
Expand All @@ -92,6 +92,22 @@ circularGradient = function (x, y, width, height, startColor, endColor) {
pop();
};

hexToRGB = function (hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function (_m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
result = result ? result.splice(1).map(function (i) {
return parseInt(i, 16);
}) : null;
push();
e.colorMode(e.RGB);
result = e.color.apply(e, result);
pop();
return result;
};

RED = e.color(255, 0, 0);
GREEN = e.color(0, 128, 0);
BLUE = e.color(0, 0, 255);
Expand Down Expand Up @@ -232,22 +248,6 @@ BROWN = e.color(165, 42, 42);
MAROON = e.color(128, 0, 0);
TRANSPARENT = e.color(255, 0);

hexToRGB = function (hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function (_m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
result = result ? result.splice(1).map(function (i) {
return parseInt(i, 16);
}) : null;
push();
e.colorMode(e.RGB);
result = e.color.apply(e, result);
pop();
return result;
};

HSBToRGB = function (x, s, v) {
if (arguments.length == 1) {
c = x;
Expand Down Expand Up @@ -294,6 +294,32 @@ HSBToRGB = function (x, s, v) {
return e.color.apply(e, result);
};

radialGradient = function (x, y, width, height, startColor, endColor) {
var step = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 5;
push();
e.strokeWeight(1);
var maxRadius = Math.max(width, height);

if (step == 1) {
e.noFill();

for (var i = 0; i < maxRadius; i++) {
e.stroke(e.lerpColor(endColor, startColor, i / maxRadius));
e.arc(x, y, width - e.map(i, 0, maxRadius, 0, width), height - e.map(i, 0, maxRadius, 0, height), 0, 360);
}
} else {
for (var _i5 = 0; _i5 < maxRadius; _i5 += step) {
var _c4 = e.lerpColor(endColor, startColor, _i5 / maxRadius);

e.stroke(_c4);
e.fill(_c4);
e.ellipse(x, y, width - e.map(_i5, 0, maxRadius, 0, width), height - e.map(_i5, 0, maxRadius, 0, height));
}
}

pop();
};

linearGradient = function (x, y, width, height, startColor, endColor) {
var direction = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : RIGHT;
var step = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 5;
Expand All @@ -315,16 +341,16 @@ linearGradient = function (x, y, width, height, startColor, endColor) {
e.line(x + i, y, x + i, y + height);
}
} else {
for (var _i5 = 0; _i5 < width; _i5 += step) {
var _c4 = e.lerpColor(startColor, endColor, _i5 / width);
for (var _i6 = 0; _i6 < width; _i6 += step) {
var _c5 = e.lerpColor(startColor, endColor, _i6 / width);

e.stroke(_c4);
e.fill(_c4);
e.stroke(_c5);
e.fill(_c5);

if (_i5 + step > width) {
e.rect(x + _i5, y, width - _i5, height);
if (_i6 + step > width) {
e.rect(x + _i6, y, width - _i6, height);
} else {
e.rect(x + _i5, y, step, height);
e.rect(x + _i6, y, step, height);
}
}
}
Expand All @@ -342,21 +368,21 @@ linearGradient = function (x, y, width, height, startColor, endColor) {
}

if (step == 1) {
for (var _i6 = 0; _i6 < height; _i6++) {
e.stroke(e.lerpColor(startColor, endColor, _i6 / height));
e.line(x, y + _i6, x + width, y + _i6);
for (var _i7 = 0; _i7 < height; _i7++) {
e.stroke(e.lerpColor(startColor, endColor, _i7 / height));
e.line(x, y + _i7, x + width, y + _i7);
}
} else {
for (var _i7 = 0; _i7 < height; _i7 += step) {
var _c5 = e.lerpColor(startColor, endColor, _i7 / height);
for (var _i8 = 0; _i8 < height; _i8 += step) {
var _c6 = e.lerpColor(startColor, endColor, _i8 / height);

e.stroke(_c5);
e.fill(_c5);
e.stroke(_c6);
e.fill(_c6);

if (_i7 + step > width) {
e.rect(x, y + _i7, width, height - _i7);
if (_i8 + step > width) {
e.rect(x, y + _i8, width, height - _i8);
} else {
e.rect(x, y + _i7, width, step);
e.rect(x, y + _i8, width, step);
}
}
}
Expand All @@ -372,31 +398,31 @@ linearGradient = function (x, y, width, height, startColor, endColor) {
}

if (step == 1) {
for (var _i8 = 0; _i8 < width; _i8++) {
e.stroke(e.lerpColor(startColor, endColor, _i8 / width / 2));
e.line(x + _i8, y, x, y + e.map(_i8, 0, width, 0, height));
for (var _i9 = 0; _i9 < width; _i9++) {
e.stroke(e.lerpColor(startColor, endColor, _i9 / width / 2));
e.line(x + _i9, y, x, y + e.map(_i9, 0, width, 0, height));
}

for (var _i9 = 0; _i9 < width; _i9++) {
e.stroke(e.lerpColor(startColor, endColor, _i9 / width / 2 + 0.5));
e.line(x + _i9, y + height, x + width, y + e.map(_i9, 0, width, 0, height));
for (var _i10 = 0; _i10 < width; _i10++) {
e.stroke(e.lerpColor(startColor, endColor, _i10 / width / 2 + 0.5));
e.line(x + _i10, y + height, x + width, y + e.map(_i10, 0, width, 0, height));
}
} else {
var side = Math.max(width, height) * Math.sqrt(2);
showGraphics(x, y, width, height, function () {
this.angleMode = 'degrees';
this.rotate(-45);

for (var _i10 = 0; _i10 < side; _i10 += step) {
var _c6 = this.lerpColor(startColor, endColor, _i10 / side);
for (var _i11 = 0; _i11 < side; _i11 += step) {
var _c7 = this.lerpColor(startColor, endColor, _i11 / side);

this.stroke(_c6);
this.fill(_c6);
this.stroke(_c7);
this.fill(_c7);

if (_i10 + step > side) {
this.rect(-side / 2, _i10, side, side - _i10);
if (_i11 + step > side) {
this.rect(-side / 2, _i11, side, side - _i11);
} else {
this.rect(-side / 2, _i10, side, step);
this.rect(-side / 2, _i11, side, step);
}
}
});
Expand All @@ -413,14 +439,14 @@ linearGradient = function (x, y, width, height, startColor, endColor) {
}

if (step == 1) {
for (var _i11 = 0; _i11 < width; _i11++) {
e.stroke(e.lerpColor(startColor, endColor, _i11 / width / 2));
e.line(x + width - _i11, y, x + width, y + e.map(_i11, 0, width, 0, height));
for (var _i12 = 0; _i12 < width; _i12++) {
e.stroke(e.lerpColor(startColor, endColor, _i12 / width / 2));
e.line(x + width - _i12, y, x + width, y + e.map(_i12, 0, width, 0, height));
}

for (var _i12 = 0; _i12 < width; _i12++) {
e.stroke(e.lerpColor(startColor, endColor, _i12 / width / 2 + 0.5));
e.line(x + width - _i12, y + height, x, y + e.map(_i12, 0, width, 0, height));
for (var _i13 = 0; _i13 < width; _i13++) {
e.stroke(e.lerpColor(startColor, endColor, _i13 / width / 2 + 0.5));
e.line(x + width - _i13, y + height, x, y + e.map(_i13, 0, width, 0, height));
}
} else {
var _side = Math.max(width, height) * Math.sqrt(2);
Expand All @@ -429,16 +455,16 @@ linearGradient = function (x, y, width, height, startColor, endColor) {
this.angleMode = 'degrees';
this.rotate(45);

for (var _i13 = 0; _i13 < _side; _i13 += step) {
var _c7 = this.lerpColor(startColor, endColor, _i13 / _side);
for (var _i14 = 0; _i14 < _side; _i14 += step) {
var _c8 = this.lerpColor(startColor, endColor, _i14 / _side);

this.stroke(_c7);
this.fill(_c7);
this.stroke(_c8);
this.fill(_c8);

if (_i13 + step > _side) {
this.rect(0, _i13 - _side / 2, _side, _side - _i13);
if (_i14 + step > _side) {
this.rect(0, _i14 - _side / 2, _side, _side - _i14);
} else {
this.rect(0, _i13 - _side / 2, _side, step);
this.rect(0, _i14 - _side / 2, _side, step);
}
}
});
Expand All @@ -449,32 +475,6 @@ linearGradient = function (x, y, width, height, startColor, endColor) {
pop();
};

radialGradient = function (x, y, width, height, startColor, endColor) {
var step = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 5;
push();
e.strokeWeight(1);
var maxRadius = Math.max(width, height);

if (step == 1) {
e.noFill();

for (var i = 0; i < maxRadius; i++) {
e.stroke(e.lerpColor(endColor, startColor, i / maxRadius));
e.arc(x, y, width - e.map(i, 0, maxRadius, 0, width), height - e.map(i, 0, maxRadius, 0, height), 0, 360);
}
} else {
for (var _i14 = 0; _i14 < maxRadius; _i14 += step) {
var _c8 = e.lerpColor(endColor, startColor, _i14 / maxRadius);

e.stroke(_c8);
e.fill(_c8);
e.ellipse(x, y, width - e.map(_i14, 0, maxRadius, 0, width), height - e.map(_i14, 0, maxRadius, 0, height));
}
}

pop();
};

RGBToHex = function (x, g, b) {
if (arguments.length == 1) {
c = x;
Expand Down
Loading

0 comments on commit ef3a01c

Please sign in to comment.