color verde inscripciones
This commit is contained in:
parent
608800823a
commit
4183326b86
@ -4,6 +4,29 @@ const moment = require("moment");
|
|||||||
|
|
||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
|
|
||||||
|
const luma = (color) => { // color can be a hx string or an array of RGB values 0-255
|
||||||
|
const rgb = (typeof color === 'string') ? hexToRGBArray(color) : color;
|
||||||
|
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]); // SMPTE C, Rec. 709 weightings
|
||||||
|
}
|
||||||
|
|
||||||
|
const hexToRGBArray = (color) => {
|
||||||
|
if (color.length === 3)
|
||||||
|
color = color.charAt(0) + color.charAt(0) + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2);
|
||||||
|
else if (color.length !== 6)
|
||||||
|
console.debug('Invalid hex color: ' + color);
|
||||||
|
|
||||||
|
const rgb = [];
|
||||||
|
for (var i = 0; i <= 2; i++)
|
||||||
|
rgb[i] = parseInt(color.substr(i * 2, 2), 16);
|
||||||
|
return rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
const calculateContrastingColor = (color) => {
|
||||||
|
const _color = (typeof color === 'string') ? color.replace('#', '') : color;
|
||||||
|
return (luma(_color) >= 165) ? '#000' : '#fff';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.getInscriptionQRCodeUrl = function (inscriptionId) {
|
module.exports.getInscriptionQRCodeUrl = function (inscriptionId) {
|
||||||
return encodeURI(`${config.server.public_url}/inscriptions/${inscriptionId}/qrimage`);
|
return encodeURI(`${config.server.public_url}/inscriptions/${inscriptionId}/qrimage`);
|
||||||
};
|
};
|
||||||
@ -34,7 +57,7 @@ module.exports.getInscriptionQRCode = function (params) {
|
|||||||
options = _.assign(options, {
|
options = _.assign(options, {
|
||||||
color: {
|
color: {
|
||||||
light: params.color ? colourNameToHex(params.color) : "#000000",
|
light: params.color ? colourNameToHex(params.color) : "#000000",
|
||||||
dark: "#ffffff",
|
dark: calculateContrastingColor(params.color), //"#ffffff",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ function _generateMarketingDTO(dataInscription) {
|
|||||||
inscriptionDTO.validated = inscription.validated;
|
inscriptionDTO.validated = inscription.validated;
|
||||||
|
|
||||||
inscriptionDTO.reservation_code = reservation ? reservation.reservation_code : null;
|
inscriptionDTO.reservation_code = reservation ? reservation.reservation_code : null;
|
||||||
inscriptionDTO.color = reservation ? reservation.color : 'green';
|
inscriptionDTO.color = reservation ? reservation.color : "darkgreen";
|
||||||
inscriptionDTO.description = (reservation ? reservation.description : "Entrada").toUpperCase();
|
inscriptionDTO.description = (reservation ? reservation.description : "Entrada").toUpperCase();
|
||||||
inscriptionDTO.qrConfig = null;
|
inscriptionDTO.qrConfig = null;
|
||||||
inscriptionDTO.qrCode = null;
|
inscriptionDTO.qrCode = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user