Prizm Content Connect
Namespace: Util

Namespace: Util

PCCViewer. Util

This object provides some common helper functions.

Methods

<static> calculateNonOverlappingSelections(selections, backgroundColor) → {Array.<selection>}

This method takes several selection objects -- ranges of start indices and lengths -- and determines if and split overlapping ranges into separate selections objects. It will also interpret the new color in the overlapping regions using PCCViewer.Util.layerColors. The non-overlapping selections from this function should be used when highlighting text inside marks to ensure the best display. See PCCViewer.Mark#highlightText.

Parameters:
Name Type Description
selections Array.<Object> | Object

An array of objects or a single object that defines a highlight.

Each object has the following properties:

* startIndex {number} - required
    * The start index of the selection, in a 0-based index of string characters.
    * The valid range is `startIndex >= 0`.
* length {number} - required
    * The length of the selection, in characters.
    * The valid range is `length > 0`.
* color {string} - required
    * Specifies the Hexadecimal color for the selection.
    * Valid values are any 7-character string representing a color. The first letter must be a "#" symbol and the other six characters must be hexadecimal digits representing the red, green, and blue portions of the color.
* opacity {number} - required
    * Specifies the opacity of the selection.
    * Valid values are from 0 to 255 (inclusive).
backgroundColor string

A valid 7-character Hexadecimal color string. The first letter must be a "#" symbol and the other six characters must be hexadecimal digits representing the red, green, and blue portions of the color.

See:
Throws:
  • If any of the selection objects have an invalid startIndex number, or the value is undefined.

    Type
    Error
  • If any of the selection objects have an invalid length number, or the value is undefined.

    Type
    Error
  • If any of the selection objects have an invalid color Hex string, or the value is undefined.

    Type
    Error
  • If any of the selection objects have an invalid opacity number, or the value is undefined.

    Type
    Error
  • If the backgroundColor argument is not a valid Hex string, or the value is undefined.

    Type
    Error
Returns:

A collection of non-overlapping selection objects, representing the same selections that were passed into the function.

Type
Array.<selection>

<static> layerColors(colors, backgroundColor) → {string}

This method takes an ordered list of colored layers, and calculates the flat color resulting from stacking all the layers.

Note: this stacking order calculation uses the W3C specification for simple alpha compositing, and is therefore not a complete color mixing solution. Instead, it calculates RGB color composition to browser specification.

Parameters:
Name Type Description
colors Array.<Object> | Object

An array of objects or a single object that defines a color layer. Note that the first element in the array will be the topmost layer in the stacking order, and the last element will be the bottom-most layer.

Each object has the following properties:

* color {string} - required
    * Specifies the Hexadecimal color for the highlight.
    * Valid values are any 7-character string representing a color. The first letter must be a "#" symbol and the other six characters must be hexadecimal digits representing the red, green, and blue portions of the color.
* opacity {number} - required
    * Specifies the opacity of the highlight.
    * Valid values are from 0 to 255 (inclusive).
backgroundColor string

A valid 7-character Hexadecimal color string. The first letter must be a "#" symbol and the other six characters must be hexadecimal digits representing the red, green, and blue portions of the color.

Throws:
  • If any of the color objects have an invalid color Hex string, or the value is undefined.

    Type
    Error
  • If any of the color objects have an invalid opacity number, or the value is undefined.

    Type
    Error
  • If the backgroundColor argument is not a valid Hex string, or the value is undefined.

    Type
    Error
Returns:

The resulting flat color produced by stacking all of the layers on top of the background color. This value will be a 7-character Hexadecimal color.

Type
string

<static> save(filename, stringValue)

Triggers file saving functionality with data generated on the client side. This method handles browser-specific differences in file generation. As such, it may have slightly different behavior in the various browsers. The end result provides a common interface for triggering a file save.

Parameters:
Name Type Description
filename string

The desired name of the output file. This will be used as the name or suggested name in browsers that support it.

stringValue string

The data, in string format, to be written to the file.


 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback