@itwin/core-common
Version:
iTwin.js components common to frontend and backend
72 lines • 3.97 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Rendering
*/
import { ColorDef } from "./ColorDef";
/** Contains types related to display of hilited elements within a [[Viewport]].
* @public
*/
export var Hilite;
(function (Hilite) {
/** Describes the width of the outline applied to hilited geometry. The outline is drawn around the union of all hilited geometry and is visible behind non-hilited geometry.
* @see [[Hilite.Settings]]
*/
let Silhouette;
(function (Silhouette) {
/** No outline. */
Silhouette[Silhouette["None"] = 0] = "None";
/** 1-pixel-wide outline. */
Silhouette[Silhouette["Thin"] = 1] = "Thin";
/** 2-pixel-wide outline. */
Silhouette[Silhouette["Thick"] = 2] = "Thick";
})(Silhouette = Hilite.Silhouette || (Hilite.Silhouette = {}));
/**
* Describes how the hilite effect is applied to elements within a [[Viewport]].
* The hilite effect is applied to elements contained in the [[IModelConnection]]'s [[SelectionSet]].
* It is designed to draw attention to those elements. The effect is produced as follows:
* 1. All hilited elements are drawn as normal, except that their element color is mixed with the hilite color.
* 2. The union of the regions of the screen corresponding to hilited elements is computed.
* 3. A silhouette is drawn using the hilite color around the boundaries of the hilited region. This silhouette is visible behind other geometry.
* 4. The hilite color is mixed with the color of each pixel within the hilited region. This enables surfaces of hilited geometry to be visible behind other geometry.
*
* The Settings allow an application to customize how this effect is applied.
* @see [[Viewport.hilite]]
*/
class Settings {
/** The color that is used to draw the outline and which is mixed with element color. */
color;
/** The ratio of hilite color to element color used when drawing unobscured portions of hilited geometry, in the range [0, 1].
* A ratio of 0.0 uses only the element color. A ratio of 1.0 uses only the hilite color. A ratio of 0.5 mixes the hilite color and element color evenly.
*/
visibleRatio;
/** The ratio of hilite color to screen color used when drawing the hilited region overtop of the screen contents, in the range [0, 1]. */
hiddenRatio;
/** The type of outline to be drawn around the boundaries of the hilited region. */
silhouette;
static clamp(value) { return Math.min(1.0, Math.max(0.0, value)); }
constructor(color = ColorDef.from(0x23, 0xbb, 0xfc), visibleRatio = 0.25, hiddenRatio = 0.0, silhouette = Silhouette.Thin) {
this.color = color;
this.silhouette = silhouette;
this.visibleRatio = Settings.clamp(visibleRatio);
this.hiddenRatio = Settings.clamp(hiddenRatio);
}
}
Hilite.Settings = Settings;
/** Compare two Settings objects for equivalence. */
function equalSettings(lhs, rhs) {
return lhs.color.equals(rhs.color)
&& lhs.visibleRatio === rhs.visibleRatio
&& lhs.hiddenRatio === rhs.hiddenRatio
&& lhs.silhouette === rhs.silhouette;
}
Hilite.equalSettings = equalSettings;
/** Create a copy of a Settings object. */
function cloneSettings(settings) {
return new Settings(settings.color, settings.visibleRatio, settings.hiddenRatio, settings.silhouette);
}
Hilite.cloneSettings = cloneSettings;
})(Hilite || (Hilite = {}));
//# sourceMappingURL=Hilite.js.map