dxf-viewer
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "dxf-viewer", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "JavaScript DXF file viewer", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -57,2 +57,3 @@ # DXF viewer | ||
* Block instancing in a grid. Grid attributes are ignored now. | ||
* Dimensions | ||
* Many less commonly used DXF features. |
@@ -211,3 +211,3 @@ import * as three from "three" | ||
for (const lyr of this.layers.values()) { | ||
result.push({name: lyr.name, color: lyr.color}) | ||
result.push({name: lyr.name, color: this._TransformColor(lyr.color)}) | ||
} | ||
@@ -577,19 +577,30 @@ return result | ||
} | ||
/* Just black and white inversion. */ | ||
const bkgLum = Luminance(this.clearColor) | ||
if (color === 0xffffff && bkgLum >= 0.8) { | ||
return 0 | ||
} | ||
if (color === 0 && bkgLum <= 0.2) { | ||
return 0xffffff | ||
} | ||
if (!this.options.colorCorrection) { | ||
/* Just black and white inversion. */ | ||
const bkgLum = Luminance(this.clearColor) | ||
if (color === 0xffffff && bkgLum >= 0.8) { | ||
return 0 | ||
return color | ||
} | ||
const fgLum = Luminance(color) | ||
const MIN_TARGET_RATIO = 1.5 | ||
const contrast = ContrastRatio(color, this.clearColor) | ||
const diff = contrast >= 1 ? contrast : 1 / contrast | ||
if (diff < MIN_TARGET_RATIO) { | ||
let targetLum | ||
if (bkgLum > 0.5) { | ||
targetLum = bkgLum / 2 | ||
} else { | ||
targetLum = bkgLum * 2 | ||
} | ||
if (color === 0 && bkgLum <= 0.2) { | ||
return 0xffffff | ||
if (targetLum > fgLum) { | ||
color = Lighten(color, targetLum / fgLum) | ||
} else { | ||
color = Darken(color, fgLum / targetLum) | ||
} | ||
return color | ||
} | ||
//XXX not implemented | ||
// const MIN_TARGET_RATIO = 1.5 | ||
// const contrast = ContrastRatio(color, this.clearColor) | ||
// const diff = contrast >= 1 ? contrast : 1 / contrast | ||
// if (diff < MIN_TARGET_RATIO) { | ||
// } | ||
return color | ||
@@ -596,0 +607,0 @@ } |
246258
6499
59