(presenter: Presenter, id: string, data: VegaTextLayerDatum[], config: PresenterConfig, fontFamily: string, characterSet: string[])
| 148 | } |
| 149 | |
| 150 | function newTextLayer(presenter: Presenter, id: string, data: VegaTextLayerDatum[], config: PresenterConfig, fontFamily: string, characterSet: string[]) { |
| 151 | let alphaCutoff = config.getTextHighlightAlphaCutoff && config.getTextHighlightAlphaCutoff(); |
| 152 | if (alphaCutoff === undefined) { |
| 153 | alphaCutoff = 0.1; |
| 154 | } |
| 155 | const props: TextLayerProps<VegaTextLayerDatum> = { |
| 156 | id, |
| 157 | data, |
| 158 | characterSet, |
| 159 | coordinateSystem: base.deck.COORDINATE_SYSTEM.CARTESIAN, |
| 160 | sizeUnits: 'pixels', |
| 161 | autoHighlight: true, |
| 162 | pickable: true, |
| 163 | highlightColor: p => { |
| 164 | if (config.getTextHighlightColor) { |
| 165 | return config.getTextHighlightColor(p.object); |
| 166 | } else { |
| 167 | return [0, 0, 0, 0]; |
| 168 | } |
| 169 | }, |
| 170 | onClick: (o, e) => { |
| 171 | const pe: Partial<PointerEvent> = e && e.srcEvent; |
| 172 | config.onTextClick && config.onTextClick(pe as PointerEvent, o.object as VegaTextLayerDatum); |
| 173 | }, |
| 174 | onHover: (o, e) => { |
| 175 | if (o.index === -1) { |
| 176 | presenter.deckgl.interactiveState.onText = false; |
| 177 | } else { |
| 178 | presenter.deckgl.interactiveState.onText = config.onTextHover ? config.onTextHover(e && e.srcEvent, o.object as VegaTextLayerDatum) : true; |
| 179 | } |
| 180 | }, |
| 181 | getColor: config.getTextColor || (o => o.color), |
| 182 | getTextAnchor: o => o.textAnchor, |
| 183 | getSize: o => o.size, |
| 184 | getAngle: o => o.angle, |
| 185 | fontSettings: { |
| 186 | sdf: false, |
| 187 | fontSize: 128, |
| 188 | buffer: 3, |
| 189 | }, |
| 190 | _subLayerProps: { characters: { alphaCutoff } }, |
| 191 | }; |
| 192 | if (fontFamily) { |
| 193 | props.fontFamily = fontFamily; |
| 194 | } |
| 195 | |
| 196 | return new base.layers.TextLayer(props); |
| 197 | } |
| 198 | |
| 199 | function getTiming(duration: number, easing?: (t: number) => number) { |
| 200 | let timing: InterpolationTransitionTiming; |
no test coverage detected