@lunit/heatmap
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -7,3 +7,6 @@ import { SVGProps } from 'react'; | ||
} | ||
/** | ||
* `width x height` 형태의 Rectangle SVG <image/>. <svg> 내에서 사용할 수 있다. | ||
*/ | ||
export declare function HeatmapScaleSVGImage({ threshold, width, height, ...imageProps }: HeatmapScaleImageProps): JSX.Element | null; | ||
export {}; |
@@ -6,3 +6,6 @@ interface UseHeatmapScaleImageURIParameters { | ||
} | ||
/** | ||
* `width x height` 사이즈의 Reactangle Image를 만들어준다. Image는 Data URI 형태로 전달되기 때문에 `<img src={uri}/>`나 `<image xlink:href={uri}/>`로 사용할 수 있다. | ||
*/ | ||
export declare function useHeatmapScaleImageURI({ width, height, threshold }: UseHeatmapScaleImageURIParameters): string | null; | ||
export {}; |
export * from './components/HeatmapScaleSVGImage'; | ||
export * from './components/useHeatmapScaleImageURI'; | ||
export * from './getAlpha'; | ||
export * from './getRGBAArray'; | ||
export * from './getRGBArray'; | ||
export * from './getAlpha'; | ||
export * from './posMapToImageData'; |
74
index.js
@@ -129,5 +129,4 @@ (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap | ||
b = 0; | ||
} //tslint:disable-next-line:no-bitwise | ||
} | ||
return [r * 255 << 0, g * 255 << 0, b * 255 << 0]; | ||
@@ -166,2 +165,6 @@ } | ||
/** | ||
* `width x height` 사이즈의 Reactangle Image를 만들어준다. Image는 Data URI 형태로 전달되기 때문에 `<img src={uri}/>`나 `<image xlink:href={uri}/>`로 사용할 수 있다. | ||
*/ | ||
function useHeatmapScaleImageURI(_ref) { | ||
@@ -203,2 +206,6 @@ var width = _ref.width, | ||
/** | ||
* `width x height` 형태의 Rectangle SVG <image/>. <svg> 내에서 사용할 수 있다. | ||
*/ | ||
function HeatmapScaleSVGImage(_ref) { | ||
@@ -222,7 +229,66 @@ var _ref$threshold = _ref.threshold, | ||
} | ||
// CONCATENATED MODULE: ./src/_packages/@lunit/heatmap/posMapToImageData.ts | ||
function posMapToImageData_slicedToArray(arr, i) { return posMapToImageData_arrayWithHoles(arr) || posMapToImageData_iterableToArrayLimit(arr, i) || posMapToImageData_nonIterableRest(); } | ||
function posMapToImageData_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function posMapToImageData_iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function posMapToImageData_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
/** | ||
* posMap data를 ImageData 객체로 변환한다 | ||
*/ | ||
function posMapToImageData(ctx, posMap, threshold) { | ||
var width = posMap[0].length; | ||
var height = posMap.length; | ||
var imageData = ctx.createImageData(width, height); // [r, g, b, a, r, g, b, a, ...] | ||
var imageDataRgbaMap = imageData.data; | ||
var y = -1; | ||
while (++y < height) { | ||
var x = -1; | ||
while (++x < width) { | ||
// rgba array index position | ||
var pos = (y * width + x) * 4; | ||
var stop = posMap[y][x]; | ||
if (stop < threshold) { | ||
imageDataRgbaMap[pos] = 0; | ||
imageDataRgbaMap[pos + 1] = 0; | ||
imageDataRgbaMap[pos + 2] = 0; | ||
imageDataRgbaMap[pos + 3] = 0; | ||
} else { | ||
// eg. threshold = 0.1 / stop = 0.3 | ||
// <threshold를 제외한 stop 값>(0.3 - 0.1) / <threshold를 제외한 max 값>(1 - 0.1) | ||
// 0.2 / 0.9 = 0.222222222 | ||
var value = (stop - threshold) / (1 - threshold); | ||
var _getRGBArray = getRGBArray(value), | ||
_getRGBArray2 = posMapToImageData_slicedToArray(_getRGBArray, 3), | ||
r = _getRGBArray2[0], | ||
g = _getRGBArray2[1], | ||
b = _getRGBArray2[2]; | ||
imageDataRgbaMap[pos] = r; | ||
imageDataRgbaMap[pos + 1] = g; | ||
imageDataRgbaMap[pos + 2] = b; | ||
imageDataRgbaMap[pos + 3] = value * 196 << 0; | ||
} | ||
} | ||
} | ||
return imageData; | ||
} | ||
// CONCATENATED MODULE: ./src/_packages/@lunit/heatmap/index.ts | ||
/* concated harmony reexport HeatmapScaleSVGImage */__webpack_require__.d(__webpack_exports__, "HeatmapScaleSVGImage", function() { return HeatmapScaleSVGImage; }); | ||
/* concated harmony reexport useHeatmapScaleImageURI */__webpack_require__.d(__webpack_exports__, "useHeatmapScaleImageURI", function() { return useHeatmapScaleImageURI; }); | ||
/* concated harmony reexport getAlpha */__webpack_require__.d(__webpack_exports__, "getAlpha", function() { return getAlpha; }); | ||
/* concated harmony reexport getRGBAArray */__webpack_require__.d(__webpack_exports__, "getRGBAArray", function() { return getRGBAArray; }); | ||
/* concated harmony reexport getRGBArray */__webpack_require__.d(__webpack_exports__, "getRGBArray", function() { return getRGBArray; }); | ||
/* concated harmony reexport getAlpha */__webpack_require__.d(__webpack_exports__, "getAlpha", function() { return getAlpha; }); | ||
/* concated harmony reexport posMapToImageData */__webpack_require__.d(__webpack_exports__, "posMapToImageData", function() { return posMapToImageData; }); | ||
@@ -233,3 +299,5 @@ | ||
/***/ }) | ||
/******/ ]))); |
{ | ||
"name": "@lunit/heatmap", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Heatmap Library", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14198
10
295