Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lunit/heatmap

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lunit/heatmap - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

109

index.js

@@ -105,5 +105,6 @@ (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap

// CONCATENATED MODULE: ./src/_packages/@lunit/heatmap/draw/getAlpha.ts
function getAlpha(_ref) {
var stop = _ref.stop,
threshold = _ref.threshold;
function getAlpha({
stop,
threshold
}) {
return stop < threshold ? 0 : (stop - threshold) * 0.75 / (1 - threshold);

@@ -113,6 +114,6 @@ }

function getRGBArray(value) {
var r = 1.0;
var g = 1.0;
var b = 1.0;
var v = Math.max(Math.min(value, 1), 0);
let r = 1.0;
let g = 1.0;
let b = 1.0;
const v = Math.max(Math.min(value, 1), 0);

@@ -146,16 +147,17 @@ if (v < 0.25) {

function getRGBAArray(_ref) {
var stop = _ref.stop,
threshold = _ref.threshold;
var alpha = getAlpha({
stop: stop,
threshold: threshold
function getRGBAArray({
stop,
threshold
}) {
const alpha = getAlpha({
stop,
threshold
});
if (alpha <= 0) return [0, 0, 0, 0];
var _getRGBArray = getRGBArray(stop),
_getRGBArray2 = _slicedToArray(_getRGBArray, 3),
r = _getRGBArray2[0],
g = _getRGBArray2[1],
b = _getRGBArray2[2];
const _getRGBArray = getRGBArray(stop),
_getRGBArray2 = _slicedToArray(_getRGBArray, 3),
r = _getRGBArray2[0],
g = _getRGBArray2[1],
b = _getRGBArray2[2];

@@ -171,24 +173,25 @@ return [r, g, b, alpha];

*/
function useHeatmapScaleImageURI(_ref) {
var width = _ref.width,
height = _ref.height,
threshold = _ref.threshold;
return Object(external_react_["useMemo"])(function () {
var canvas = document.createElement('canvas');
function useHeatmapScaleImageURI({
width,
height,
threshold
}) {
return Object(external_react_["useMemo"])(() => {
const canvas = document.createElement('canvas');
if (!canvas) return null;
var ratio = window.devicePixelRatio;
var w = width * ratio;
var h = height * ratio;
const ratio = window.devicePixelRatio;
const w = width * ratio;
const h = height * ratio;
canvas.setAttribute('width', w.toString());
canvas.setAttribute('height', h.toString());
var ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d');
if (!ctx) return null;
var i = w + 1;
let i = w + 1;
while (--i >= 0) {
ctx.beginPath();
ctx.fillStyle = "rgba(".concat(getRGBAArray({
ctx.fillStyle = `rgba(${getRGBAArray({
stop: i / w,
threshold: threshold
}), ")");
threshold
})})`;
ctx.fillRect(i, 0, 1, h);

@@ -213,3 +216,3 @@ ctx.closePath();

function HeatmapScaleSVGImage(_ref) {
var _ref$threshold = _ref.threshold,
let _ref$threshold = _ref.threshold,
threshold = _ref$threshold === void 0 ? 0 : _ref$threshold,

@@ -220,6 +223,6 @@ width = _ref.width,

var dataUri = useHeatmapScaleImageURI({
width: width,
height: height,
threshold: threshold
const dataUri = useHeatmapScaleImageURI({
width,
height,
threshold
});

@@ -247,18 +250,18 @@ return dataUri ? external_react_default.a.createElement("image", Object.assign({}, imageProps, {

function posMapToImageData(posMap, threshold) {
var width = posMap[0].length;
var height = posMap.length;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var imageData = ctx.createImageData(width, height); // [r, g, b, a, r, g, b, a, ...]
const width = posMap[0].length;
const height = posMap.length;
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const imageData = ctx.createImageData(width, height); // [r, g, b, a, r, g, b, a, ...]
var imageDataRgbaMap = imageData.data;
var y = -1;
const imageDataRgbaMap = imageData.data;
let y = -1;
while (++y < height) {
var x = -1;
let x = -1;
while (++x < width) {
// rgba array index position
var pos = (y * width + x) * 4;
var stop = posMap[y][x];
const pos = (y * width + x) * 4;
const stop = posMap[y][x];

@@ -274,9 +277,9 @@ if (stop < threshold) {

// 0.2 / 0.9 = 0.222222222
var value = (stop - threshold) / (1 - threshold);
const value = (stop - threshold) / (1 - threshold);
var _getRGBArray = getRGBArray(value),
_getRGBArray2 = posMapToImageData_slicedToArray(_getRGBArray, 3),
r = _getRGBArray2[0],
g = _getRGBArray2[1],
b = _getRGBArray2[2];
const _getRGBArray = getRGBArray(value),
_getRGBArray2 = posMapToImageData_slicedToArray(_getRGBArray, 3),
r = _getRGBArray2[0],
g = _getRGBArray2[1],
b = _getRGBArray2[2];

@@ -283,0 +286,0 @@ imageDataRgbaMap[pos] = r;

{
"name": "@lunit/heatmap",
"version": "1.0.2",
"version": "1.0.3",
"description": "Heatmap Library",

@@ -9,3 +9,3 @@ "author": {

},
"repository": "lunit-io/opt-tool-frontend",
"repository": "lunit-io/frontend-components",
"license": "MIT",

@@ -12,0 +12,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc