MCPcopy Create free account
hub / github.com/microsoft/SandDance / newTextLayer

Function newTextLayer

docs/app/js/sanddance-app.js:7513–7558  ·  view source on GitHub ↗
(presenter, id, data, config, fontFamily, characterSet)

Source from the content-addressed store, hash-verified

7511 return newlayer;
7512}
7513function newTextLayer(presenter, id, data, config, fontFamily, characterSet) {
7514 let alphaCutoff = config.getTextHighlightAlphaCutoff && config.getTextHighlightAlphaCutoff();
7515 if (alphaCutoff === undefined) alphaCutoff = 0.1;
7516 const props = {
7517 id,
7518 data,
7519 characterSet,
7520 coordinateSystem: (0, _base.base).deck.COORDINATE_SYSTEM.CARTESIAN,
7521 sizeUnits: "pixels",
7522 autoHighlight: true,
7523 pickable: true,
7524 highlightColor: (p)=>{
7525 if (config.getTextHighlightColor) return config.getTextHighlightColor(p.object);
7526 else return [
7527 0,
7528 0,
7529 0,
7530 0
7531 ];
7532 },
7533 onClick: (o, e)=>{
7534 let pe = e && e.srcEvent;
7535 config.onTextClick && config.onTextClick(pe, o.object);
7536 },
7537 onHover: (o, e)=>{
7538 if (o.index === -1) presenter.deckgl.interactiveState.onText = false;
7539 else presenter.deckgl.interactiveState.onText = config.onTextHover ? config.onTextHover(e && e.srcEvent, o.object) : true;
7540 },
7541 getColor: config.getTextColor || ((o)=>o.color),
7542 getTextAnchor: (o)=>o.textAnchor,
7543 getSize: (o)=>o.size,
7544 getAngle: (o)=>o.angle,
7545 fontSettings: {
7546 sdf: false,
7547 fontSize: 128,
7548 buffer: 3
7549 },
7550 _subLayerProps: {
7551 characters: {
7552 alphaCutoff
7553 }
7554 }
7555 };
7556 if (fontFamily) props.fontFamily = fontFamily;
7557 return new (0, _base.base).layers.TextLayer(props);
7558}
7559function getTiming(duration, easing) {
7560 let timing;
7561 if (duration) {

Callers 1

getLayersFunction · 0.70

Calls 1

onTextHoverMethod · 0.45

Tested by

no test coverage detected