123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SColor = void 0;
- var lib_1 = require("@persagy-web/base/lib");
- var SColor = (function () {
- function SColor(r, g, b, a) {
- this._value = 0xff;
- if (r == undefined) {
- this._value = 0xff;
- }
- else if (typeof r == "string") {
- this.value = r;
- }
- else if (r instanceof SColor) {
- this._value = r._value;
- }
- else if (a == undefined) {
- this.setRgb(r, g, b);
- }
- else {
- this.setRgba(r, g, b, a);
- }
- }
- SColor.rgb = function (r, g, b) {
- return new SColor(r, g, b);
- };
- SColor.rgba = function (r, g, b, a) {
- return new SColor(r, g, b, a);
- };
- Object.defineProperty(SColor.prototype, "red", {
- get: function () {
- return (this._value >> 24) & 0xff;
- },
- set: function (v) {
- var r = (Math.floor(v) & 0xff) << 24;
- this._value = (this._value & 0x00ffffff) | r;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(SColor.prototype, "green", {
- get: function () {
- return (this._value >> 16) & 0xff;
- },
- set: function (v) {
- var r = (Math.floor(v) & 0xff) << 16;
- this._value = (this._value & 0xff00ffff) | r;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(SColor.prototype, "blue", {
- get: function () {
- return (this._value >> 8) & 0xff;
- },
- set: function (v) {
- var r = (Math.floor(v) & 0xff) << 8;
- this._value = (this._value & 0xffff00ff) | r;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(SColor.prototype, "alpha", {
- get: function () {
- return this._value & 0xff;
- },
- set: function (v) {
- var r = Math.floor(v) & 0xff;
- this._value = (this._value & 0xffffff00) | r;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(SColor.prototype, "value", {
- get: function () {
- return "#" + lib_1.SStringUtil.num2Hex(this._value, 8);
- },
- set: function (v) {
- if (v.substr(0, 1) != "#") {
- return;
- }
- this._value = parseInt(v.substr(1), 16);
- if (v.length == 7) {
- this._value = (this._value << 8) + 0xff;
- }
- },
- enumerable: false,
- configurable: true
- });
- SColor.prototype.setRgb = function (r, g, b) {
- this._value =
- (r << 24) +
- (g << 16) +
- (b << 8) +
- 0xff;
- };
- SColor.prototype.setRgba = function (r, g, b, a) {
- this._value =
- (r << 24) +
- (g << 16) +
- (b << 8) +
- a;
- };
- SColor.Transparent = new SColor("#00000000");
- SColor.Black = new SColor("#000000");
- SColor.DarkBlue = new SColor("#000080");
- SColor.Blue = new SColor("#0000FF");
- SColor.DarkGreen = new SColor("#008000");
- SColor.Green = new SColor("#00FF00");
- SColor.DarkCyan = new SColor("#008080");
- SColor.Cyan = new SColor("#00FFFF");
- SColor.DarkRed = new SColor("#800000");
- SColor.Red = new SColor("#FF0000");
- SColor.DarkMagenta = new SColor("#800080");
- SColor.Magenta = new SColor("#FF00FF");
- SColor.DarkYellow = new SColor("#808000");
- SColor.Yellow = new SColor("#FFFF00");
- SColor.White = new SColor("#FFFFFF");
- SColor.DarkGray = new SColor("#808080");
- SColor.Gray = new SColor("#A0A0A0");
- SColor.LightGray = new SColor("#C0C0C0");
- return SColor;
- }());
- exports.SColor = SColor;
|