@genome-spy/core 0.49.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/index.es.js +2861 -2829
- package/dist/bundle/index.js +90 -89
- package/dist/schema.json +2175 -1430
- package/dist/src/genomeSpy.d.ts.map +1 -1
- package/dist/src/genomeSpy.js +12 -8
- package/dist/src/gl/includes/common.glsl.js +1 -1
- package/dist/src/marks/link.d.ts +8 -1
- package/dist/src/marks/link.d.ts.map +1 -1
- package/dist/src/marks/link.fragment.glsl.js +1 -1
- package/dist/src/marks/link.js +38 -32
- package/dist/src/marks/link.vertex.glsl.js +1 -1
- package/dist/src/marks/mark.d.ts +19 -16
- package/dist/src/marks/mark.d.ts.map +1 -1
- package/dist/src/marks/mark.js +41 -27
- package/dist/src/marks/markUtils.d.ts +25 -0
- package/dist/src/marks/markUtils.d.ts.map +1 -1
- package/dist/src/marks/markUtils.js +41 -1
- package/dist/src/marks/point.common.glsl.js +1 -1
- package/dist/src/marks/point.d.ts +8 -1
- package/dist/src/marks/point.d.ts.map +1 -1
- package/dist/src/marks/point.js +29 -24
- package/dist/src/marks/point.vertex.glsl.js +1 -1
- package/dist/src/marks/rect.d.ts +8 -1
- package/dist/src/marks/rect.d.ts.map +1 -1
- package/dist/src/marks/rect.js +19 -19
- package/dist/src/marks/rule.d.ts +8 -1
- package/dist/src/marks/rule.d.ts.map +1 -1
- package/dist/src/marks/rule.js +19 -16
- package/dist/src/marks/text.d.ts +10 -1
- package/dist/src/marks/text.d.ts.map +1 -1
- package/dist/src/marks/text.fragment.glsl.js +1 -1
- package/dist/src/marks/text.js +48 -46
- package/dist/src/marks/text.vertex.glsl.js +1 -1
- package/dist/src/spec/channel.d.ts +14 -1
- package/dist/src/spec/mark.d.ts +167 -87
- package/dist/src/spec/view.d.ts +115 -39
- package/dist/src/styles/genome-spy.css.d.ts +1 -1
- package/dist/src/styles/genome-spy.css.d.ts.map +1 -1
- package/dist/src/styles/genome-spy.css.js +1 -0
- package/dist/src/styles/genome-spy.scss +1 -0
- package/dist/src/tooltip/dataTooltipHandler.d.ts +1 -1
- package/dist/src/tooltip/dataTooltipHandler.d.ts.map +1 -1
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +1 -1
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts.map +1 -1
- package/dist/src/view/axisResolution.d.ts +1 -1
- package/dist/src/view/axisResolution.d.ts.map +1 -1
- package/dist/src/view/axisResolution.js +1 -1
- package/dist/src/view/axisView.js +2 -2
- package/dist/src/view/flowBuilder.test.js +1 -1
- package/dist/src/view/gridView.js +1 -1
- package/dist/src/view/layout/flexLayout.d.ts +6 -0
- package/dist/src/view/layout/flexLayout.d.ts.map +1 -1
- package/dist/src/view/layout/flexLayout.js +9 -0
- package/dist/src/view/paramMediator.d.ts +7 -0
- package/dist/src/view/paramMediator.d.ts.map +1 -1
- package/dist/src/view/paramMediator.js +23 -0
- package/dist/src/view/paramMediator.test.js +20 -0
- package/dist/src/view/scaleResolution.d.ts +1 -7
- package/dist/src/view/scaleResolution.d.ts.map +1 -1
- package/dist/src/view/scaleResolution.js +24 -39
- package/dist/src/view/unitView.d.ts +3 -5
- package/dist/src/view/unitView.d.ts.map +1 -1
- package/dist/src/view/unitView.js +22 -4
- package/dist/src/view/view.js +1 -1
- package/dist/src/view/viewUtils.d.ts +1 -5
- package/dist/src/view/viewUtils.d.ts.map +1 -1
- package/dist/src/view/viewUtils.js +0 -7
- package/package.json +2 -2
package/dist/src/marks/point.js
CHANGED
|
@@ -17,6 +17,9 @@ import { fixFill, fixStroke } from "./markUtils.js";
|
|
|
17
17
|
/** @type {Record<string, import("../spec/channel.js").ChannelDef>} */
|
|
18
18
|
const defaultEncoding = {};
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @extends {Mark<import("../spec/mark.js").PointProps>}
|
|
22
|
+
*/
|
|
20
23
|
export default class PointMark extends Mark {
|
|
21
24
|
#semanticZoomFraction = () => 0;
|
|
22
25
|
|
|
@@ -26,28 +29,28 @@ export default class PointMark extends Mark {
|
|
|
26
29
|
constructor(unitView) {
|
|
27
30
|
super(unitView);
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
32
|
+
this.augmentDefaultProperties({
|
|
33
|
+
x: 0.5,
|
|
34
|
+
y: 0.5,
|
|
35
|
+
color: "#4c78a8",
|
|
36
|
+
filled: true,
|
|
37
|
+
opacity: 1.0,
|
|
38
|
+
size: 100.0,
|
|
39
|
+
// @ts-expect-error - TODO: Should be datum instead of value. But needs fixing.
|
|
40
|
+
semanticScore: 0.0,
|
|
41
|
+
shape: "circle",
|
|
42
|
+
strokeWidth: 2.0,
|
|
43
|
+
fillGradientStrength: 0.0,
|
|
44
|
+
dx: 0,
|
|
45
|
+
dy: 0,
|
|
46
|
+
angle: 0,
|
|
47
|
+
|
|
48
|
+
sampleFacetPadding: 0.1,
|
|
49
|
+
|
|
50
|
+
semanticZoomFraction: 0.02,
|
|
51
|
+
|
|
52
|
+
minPickingSize: 2.0,
|
|
53
|
+
});
|
|
51
54
|
|
|
52
55
|
// TODO: This mess should be simplified
|
|
53
56
|
// TODO: createExpression should accept constant values or ExprRefs and allow
|
|
@@ -68,9 +71,11 @@ export default class PointMark extends Mark {
|
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @returns {import("../spec/channel.js").Channel[]}
|
|
76
|
+
*/
|
|
71
77
|
getAttributes() {
|
|
72
78
|
return [
|
|
73
|
-
"inwardStroke",
|
|
74
79
|
"uniqueId",
|
|
75
80
|
"facetIndex",
|
|
76
81
|
"x",
|
|
@@ -79,7 +84,6 @@ export default class PointMark extends Mark {
|
|
|
79
84
|
"semanticScore",
|
|
80
85
|
"shape",
|
|
81
86
|
"strokeWidth",
|
|
82
|
-
"gradientStrength",
|
|
83
87
|
"dx",
|
|
84
88
|
"dy",
|
|
85
89
|
"fill",
|
|
@@ -173,6 +177,7 @@ export default class PointMark extends Mark {
|
|
|
173
177
|
"uGradientStrength",
|
|
174
178
|
props.fillGradientStrength
|
|
175
179
|
);
|
|
180
|
+
this.registerMarkUniformValue("uMinPickingSize", props.minPickingSize);
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
updateGraphicsData() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const shader = "out float vRadius;out float vRadiusWithPadding;out lowp vec4 vFillColor;out lowp vec4 vStrokeColor;out lowp float vShape;out lowp float vHalfStrokeWidth;out mat2 vRotationMatrix;const float CIRCLE=0.0;const float SQUARE=1.0;const float CROSS=2.0;const float DIAMOND=3.0;const float TRIANGLE_UP=4.0;const float TRIANGLE_RIGHT=5.0;const float TRIANGLE_DOWN=6.0;const float TRIANGLE_LEFT=7.0;const float TICK_UP=8.0;const float TICK_RIGHT=9.0;const float TICK_DOWN=10.0;const float TICK_LEFT=11.0;float computeSemanticThresholdFactor(){return getScaled_semanticScore()>=uSemanticThreshold ? 1.0 : 0.0;}vec2 getDxDy(){\n#if defined(dx_DEFINED) || defined(dy_DEFINED)\nreturn vec2(getScaled_dx(),getScaled_dy())/uViewportSize;\n#else\nreturn vec2(0.0,0.0);\n#endif\n}void main(void){float shapeAngle=0.0;float semanticThresholdFactor=computeSemanticThresholdFactor();if(semanticThresholdFactor<=0.0){gl_PointSize=0.0;gl_Position=vec4(100.0,0.0,0.0,0.0);return;}float size=getScaled_size();vec2 pos=vec2(getScaled_x(),getScaled_y())+getDxDy();gl_Position=unitToNdc(applySampleFacet(pos));float strokeWidth=getScaled_strokeWidth();float diameter=sqrt(size)*uScaleFactor*semanticThresholdFactor;float opacity=uViewOpacity;if(strokeWidth<=0.0||uInwardStroke){float minDiameter=1.0/uDevicePixelRatio;if(diameter<minDiameter){opacity*=pow(diameter/minDiameter,2.5);diameter=minDiameter;}}float fillOpa=getScaled_fillOpacity()*opacity;float strokeOpa=getScaled_strokeOpacity()*opacity;vShape=getScaled_shape();bool circle=vShape==0.0;if(vShape>TICK_UP&&vShape<=TICK_LEFT){shapeAngle=(vShape-TICK_UP)*90.0;vShape=TICK_UP;}else if(vShape>TRIANGLE_UP&&vShape<=TRIANGLE_LEFT){shapeAngle=(vShape-TRIANGLE_UP)*90.0;vShape=TRIANGLE_UP;}float angleInDegrees=getScaled_angle();float angle=-(shapeAngle+angleInDegrees)*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);vRotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);float roomForRotation=circle ? 1.0 : sin(mod(angle,PI/2.0)+PI/4.0)/sin(PI/4.0);float aaPadding=1.0/uDevicePixelRatio;float rotationPadding=(diameter*roomForRotation)-diameter;float strokePadding=uInwardStroke ? 0.0 : strokeWidth*(circle ? 1.0 : sqrt(3.0));float padding=rotationPadding+strokePadding+aaPadding;gl_PointSize=(diameter+padding)*uDevicePixelRatio;vRadius=diameter/2.0;vRadiusWithPadding=vRadius+padding/2.0;vHalfStrokeWidth=strokeWidth/2.0;vFillColor=vec4(getScaled_fill()*fillOpa,fillOpa);vStrokeColor=vec4(getScaled_stroke()*strokeOpa,strokeOpa);setupPicking();}";
|
|
1
|
+
const shader = "out float vRadius;out float vRadiusWithPadding;out lowp vec4 vFillColor;out lowp vec4 vStrokeColor;out lowp float vShape;out lowp float vHalfStrokeWidth;out mat2 vRotationMatrix;const float CIRCLE=0.0;const float SQUARE=1.0;const float CROSS=2.0;const float DIAMOND=3.0;const float TRIANGLE_UP=4.0;const float TRIANGLE_RIGHT=5.0;const float TRIANGLE_DOWN=6.0;const float TRIANGLE_LEFT=7.0;const float TICK_UP=8.0;const float TICK_RIGHT=9.0;const float TICK_DOWN=10.0;const float TICK_LEFT=11.0;float computeSemanticThresholdFactor(){return getScaled_semanticScore()>=uSemanticThreshold ? 1.0 : 0.0;}vec2 getDxDy(){\n#if defined(dx_DEFINED) || defined(dy_DEFINED)\nreturn vec2(getScaled_dx(),getScaled_dy())/uViewportSize;\n#else\nreturn vec2(0.0,0.0);\n#endif\n}void main(void){float shapeAngle=0.0;float semanticThresholdFactor=computeSemanticThresholdFactor();if(semanticThresholdFactor<=0.0){gl_PointSize=0.0;gl_Position=vec4(100.0,0.0,0.0,0.0);return;}float size=getScaled_size();vec2 pos=vec2(getScaled_x(),getScaled_y())+getDxDy();gl_Position=unitToNdc(applySampleFacet(pos));float strokeWidth=getScaled_strokeWidth();float diameter=sqrt(size)*uScaleFactor*semanticThresholdFactor;float opacity=uViewOpacity;if(strokeWidth<=0.0||uInwardStroke){float minDiameter=1.0/uDevicePixelRatio;if(diameter<minDiameter){opacity*=pow(diameter/minDiameter,2.5);diameter=minDiameter;}}float fillOpa=getScaled_fillOpacity()*opacity;float strokeOpa=getScaled_strokeOpacity()*opacity;vShape=getScaled_shape();bool circle=vShape==0.0;if(vShape>TICK_UP&&vShape<=TICK_LEFT){shapeAngle=(vShape-TICK_UP)*90.0;vShape=TICK_UP;}else if(vShape>TRIANGLE_UP&&vShape<=TRIANGLE_LEFT){shapeAngle=(vShape-TRIANGLE_UP)*90.0;vShape=TRIANGLE_UP;}float angleInDegrees=getScaled_angle();float angle=-(shapeAngle+angleInDegrees)*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);vRotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);float roomForRotation=circle ? 1.0 : sin(mod(angle,PI/2.0)+PI/4.0)/sin(PI/4.0);float aaPadding=1.0/uDevicePixelRatio;float rotationPadding=(diameter*roomForRotation)-diameter;float strokePadding=uInwardStroke ? 0.0 : strokeWidth*(circle ? 1.0 : sqrt(3.0));float padding=rotationPadding+strokePadding+aaPadding;gl_PointSize=max((diameter+padding),uPickingEnabled ? uMinPickingSize : 0.0)*uDevicePixelRatio;vRadius=diameter/2.0;vRadiusWithPadding=vRadius+padding/2.0;vHalfStrokeWidth=strokeWidth/2.0;vFillColor=vec4(getScaled_fill()*fillOpa,fillOpa);vStrokeColor=vec4(getScaled_stroke()*strokeOpa,strokeOpa);setupPicking();}";
|
|
2
2
|
export default shader;
|
package/dist/src/marks/rect.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @extends {Mark<import("../spec/mark.js").RectProps>}
|
|
3
|
+
*/
|
|
4
|
+
export default class RectMark extends Mark<import("../spec/mark.js").RectProps> {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("../view/unitView.js").default} unitView
|
|
7
|
+
*/
|
|
8
|
+
constructor(unitView: import("../view/unitView.js").default);
|
|
2
9
|
/**
|
|
3
10
|
* Finds a datum that overlaps the given value on the x domain.
|
|
4
11
|
* The result is unspecified if multiple data are found.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/marks/rect.js"],"names":[],"mappings":"AAaA;
|
|
1
|
+
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/marks/rect.js"],"names":[],"mappings":"AAaA;;GAEG;AACH;IACI;;OAEG;IACH,sBAFW,OAAO,qBAAqB,EAAE,OAAO,EAkB/C;IAuMD;;;;;;;;;;OAUG;IACH,8BALW,GAAG,KACH,OAAO,oBAAoB,EAAE,MAAM,GACjC,GAAG,CAyBf;;CACJ;iBAvQgB,WAAW"}
|
package/dist/src/marks/rect.js
CHANGED
|
@@ -11,6 +11,9 @@ import { isValueDef } from "../encoder/encoder.js";
|
|
|
11
11
|
import { getCachedOrCall } from "../utils/propertyCacher.js";
|
|
12
12
|
import { isDiscrete } from "vega-scale";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @extends {Mark<import("../spec/mark.js").RectProps>}
|
|
16
|
+
*/
|
|
14
17
|
export default class RectMark extends Mark {
|
|
15
18
|
/**
|
|
16
19
|
* @param {import("../view/unitView.js").default} unitView
|
|
@@ -18,27 +21,24 @@ export default class RectMark extends Mark {
|
|
|
18
21
|
constructor(unitView) {
|
|
19
22
|
super(unitView);
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
minOpacity: 1.0,
|
|
35
|
-
|
|
36
|
-
tessellationZoomThreshold: 10, // This works with genomes, but likely breaks with other data. TODO: Fix, TODO: log2
|
|
37
|
-
tessellationTiles: 35, // TODO: Tiles per unit (bp)
|
|
38
|
-
})
|
|
39
|
-
);
|
|
24
|
+
this.augmentDefaultProperties({
|
|
25
|
+
x2: undefined,
|
|
26
|
+
y2: undefined,
|
|
27
|
+
filled: true,
|
|
28
|
+
color: "#4c78a8",
|
|
29
|
+
opacity: 1.0,
|
|
30
|
+
strokeWidth: 3,
|
|
31
|
+
cornerRadius: 0.0,
|
|
32
|
+
|
|
33
|
+
minWidth: 0.5, // Minimum width/height prevents annoying flickering when zooming
|
|
34
|
+
minHeight: 0.5,
|
|
35
|
+
minOpacity: 1.0,
|
|
36
|
+
});
|
|
40
37
|
}
|
|
41
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @returns {import("../spec/channel.js").Channel[]}
|
|
41
|
+
*/
|
|
42
42
|
getAttributes() {
|
|
43
43
|
return [
|
|
44
44
|
"uniqueId",
|
package/dist/src/marks/rule.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @extends {Mark<import("../spec/mark.js").RuleProps>}
|
|
3
|
+
*/
|
|
4
|
+
export default class RuleMark extends Mark<import("../spec/mark.js").RuleProps> {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("../view/unitView.js").default} unitView
|
|
7
|
+
*/
|
|
8
|
+
constructor(unitView: import("../view/unitView.js").default);
|
|
2
9
|
dashTextureSize: number;
|
|
3
10
|
dashTexture: WebGLTexture;
|
|
4
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../../src/marks/rule.js"],"names":[],"mappings":"AAcA;
|
|
1
|
+
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../../src/marks/rule.js"],"names":[],"mappings":"AAcA;;GAEG;AACH;IACI;;OAEG;IACH,sBAFW,OAAO,qBAAqB,EAAE,OAAO,EAoB/C;IAfG,wBAAwB;IA4GpB,0BAOE;CAgGb;iBA3OgB,WAAW"}
|
package/dist/src/marks/rule.js
CHANGED
|
@@ -12,6 +12,9 @@ import COMMON_SHADER from "./rule.common.glsl.js";
|
|
|
12
12
|
import { RuleVertexBuilder } from "../gl/dataToVertices.js";
|
|
13
13
|
import { isChannelDefWithScale } from "../encoder/encoder.js";
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @extends {Mark<import("../spec/mark.js").RuleProps>}
|
|
17
|
+
*/
|
|
15
18
|
export default class RuleMark extends Mark {
|
|
16
19
|
/**
|
|
17
20
|
* @param {import("../view/unitView.js").default} unitView
|
|
@@ -21,24 +24,24 @@ export default class RuleMark extends Mark {
|
|
|
21
24
|
|
|
22
25
|
this.dashTextureSize = 0;
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
strokeCap: "butt",
|
|
38
|
-
})
|
|
39
|
-
);
|
|
27
|
+
this.augmentDefaultProperties({
|
|
28
|
+
x2: undefined,
|
|
29
|
+
y2: undefined,
|
|
30
|
+
size: 1,
|
|
31
|
+
color: "black",
|
|
32
|
+
opacity: 1.0,
|
|
33
|
+
|
|
34
|
+
minLength: 0.0,
|
|
35
|
+
/** @type {number[]} */
|
|
36
|
+
strokeDash: null,
|
|
37
|
+
strokeDashOffset: 0,
|
|
38
|
+
strokeCap: "butt",
|
|
39
|
+
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @returns {import("../spec/channel.js").Channel[]}
|
|
44
|
+
*/
|
|
42
45
|
getAttributes() {
|
|
43
46
|
return [
|
|
44
47
|
"uniqueId",
|
package/dist/src/marks/text.d.ts
CHANGED
|
@@ -5,8 +5,17 @@
|
|
|
5
5
|
* - Valve's SDF paper: https://doi.org/10.1145/1281500.1281665
|
|
6
6
|
* - Multi-channel SDF fonts: https://github.com/Chlumsky/msdfgen
|
|
7
7
|
* - Google's web fonts as SDFs: https://github.com/etiennepinchon/aframe-fonts
|
|
8
|
+
*
|
|
9
|
+
* @extends {Mark<import("../spec/mark.js").TextProps>}
|
|
8
10
|
*/
|
|
9
|
-
export default class TextMark extends Mark {
|
|
11
|
+
export default class TextMark extends Mark<import("../spec/mark.js").TextProps> {
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import("../spec/mark.js").MarkProps} MarkProps
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @param {import("../view/unitView.js").default} unitView
|
|
17
|
+
*/
|
|
18
|
+
constructor(unitView: import("../view/unitView.js").default);
|
|
10
19
|
font: import("../fonts/bmFontManager.js").FontEntry;
|
|
11
20
|
}
|
|
12
21
|
import Mark from "./mark.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/marks/text.js"],"names":[],"mappings":"AAgCA
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/marks/text.js"],"names":[],"mappings":"AAgCA;;;;;;;;;GASG;AACH;IACI;;OAEG;IACH;;OAEG;IACH,sBAFW,OAAO,qBAAqB,EAAE,OAAO,EA8D/C;IAbG,oDAMmD;CA+M1D;iBAxSgB,WAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const shader = "uniform sampler2D uTexture;in vec2 vTexCoord;in float vEdgeFadeOpacity;in vec4 vColor;in float vSlope;out lowp vec4 fragColor;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){vec3 c=texture(uTexture,vTexCoord).rgb;float sigDist=1.0-median(c.r,c.g,c.b);float slope=uLogoLetter? 0.7/length(vec2(dFdy(sigDist),dFdx(sigDist))): vSlope;float opa=clamp((sigDist-0.5)*slope+0.5,0.0,1.0);opa*=
|
|
1
|
+
const shader = "uniform sampler2D uTexture;in vec2 vTexCoord;in float vEdgeFadeOpacity;in vec4 vColor;in float vSlope;in float vGamma;out lowp vec4 fragColor;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){vec3 c=texture(uTexture,vTexCoord).rgb;float sigDist=1.0-median(c.r,c.g,c.b);float slope=uLogoLetter? 0.7/length(vec2(dFdy(sigDist),dFdx(sigDist))): vSlope;float opa=clamp((sigDist-0.5)*slope+0.5,0.0,1.0);opa*=clamp(vEdgeFadeOpacity,0.0,1.0);opa=pow(opa,vGamma);fragColor=vColor*opa;if(uPickingEnabled){fragColor=vPickingColor;}}";
|
|
2
2
|
export default shader;
|
package/dist/src/marks/text.js
CHANGED
|
@@ -37,6 +37,8 @@ const baselines = {
|
|
|
37
37
|
* - Valve's SDF paper: https://doi.org/10.1145/1281500.1281665
|
|
38
38
|
* - Multi-channel SDF fonts: https://github.com/Chlumsky/msdfgen
|
|
39
39
|
* - Google's web fonts as SDFs: https://github.com/etiennepinchon/aframe-fonts
|
|
40
|
+
*
|
|
41
|
+
* @extends {Mark<import("../spec/mark.js").TextProps>}
|
|
40
42
|
*/
|
|
41
43
|
export default class TextMark extends Mark {
|
|
42
44
|
/**
|
|
@@ -48,52 +50,49 @@ export default class TextMark extends Mark {
|
|
|
48
50
|
constructor(unitView) {
|
|
49
51
|
super(unitView);
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
viewportEdgeFadeDistanceLeft: -Infinity,
|
|
95
|
-
})
|
|
96
|
-
);
|
|
53
|
+
this.augmentDefaultProperties({
|
|
54
|
+
x: 0.5,
|
|
55
|
+
y: 0.5,
|
|
56
|
+
x2: undefined,
|
|
57
|
+
y2: undefined,
|
|
58
|
+
text: "",
|
|
59
|
+
size: 11.0,
|
|
60
|
+
color: "black",
|
|
61
|
+
opacity: 1.0,
|
|
62
|
+
|
|
63
|
+
// Use the built-in default
|
|
64
|
+
font: undefined,
|
|
65
|
+
fontStyle: undefined,
|
|
66
|
+
fontWeight: undefined,
|
|
67
|
+
|
|
68
|
+
align: "center",
|
|
69
|
+
baseline: "middle",
|
|
70
|
+
dx: 0,
|
|
71
|
+
dy: 0,
|
|
72
|
+
angle: 0,
|
|
73
|
+
|
|
74
|
+
/** When only primary channel is defined with band/locus scale */
|
|
75
|
+
fitToBand: false,
|
|
76
|
+
|
|
77
|
+
squeeze: true,
|
|
78
|
+
paddingX: 0,
|
|
79
|
+
paddingY: 0,
|
|
80
|
+
flushX: true,
|
|
81
|
+
flushY: true,
|
|
82
|
+
|
|
83
|
+
/** Stretch letters so that they can be used with sequence logos etc... */
|
|
84
|
+
logoLetters: false,
|
|
85
|
+
|
|
86
|
+
viewportEdgeFadeWidthTop: 0,
|
|
87
|
+
viewportEdgeFadeWidthRight: 0,
|
|
88
|
+
viewportEdgeFadeWidthBottom: 0,
|
|
89
|
+
viewportEdgeFadeWidthLeft: 0,
|
|
90
|
+
|
|
91
|
+
viewportEdgeFadeDistanceTop: -Infinity,
|
|
92
|
+
viewportEdgeFadeDistanceRight: -Infinity,
|
|
93
|
+
viewportEdgeFadeDistanceBottom: -Infinity,
|
|
94
|
+
viewportEdgeFadeDistanceLeft: -Infinity,
|
|
95
|
+
});
|
|
97
96
|
|
|
98
97
|
this.font = this.properties.font
|
|
99
98
|
? unitView.context.fontManager.getFont(
|
|
@@ -110,6 +109,9 @@ export default class TextMark extends Mark {
|
|
|
110
109
|
]);
|
|
111
110
|
}
|
|
112
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @returns {import("../spec/channel.js").Channel[]}
|
|
114
|
+
*/
|
|
113
115
|
getAttributes() {
|
|
114
116
|
return [
|
|
115
117
|
"uniqueId",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const shader = "in mediump vec2 vertexCoord;in lowp vec2 textureCoord;in float width;out vec2 vTexCoord;out vec4 vColor;out float vSlope;out float vEdgeFadeOpacity;struct RangeResult{float pos;float scale;};float minValue(vec4 v){return min(min(v.x,v.y),min(v.z,v.w));}float maxValue(vec4 v){return max(max(v.x,v.y),max(v.z,v.w));}/***All measures are in[0,1]*/RangeResult positionInsideRange(float a,float b,float width,float padding,int align,bool flush){float span=b-a;float paddedWidth=width+2.0*padding;if(a>1.0||b<0.0){return RangeResult(0.0,0.0);}float extra=max(0.0,span-paddedWidth);float pos;if(align==0){float centre=a+b;if(flush){float leftOver=max(0.0,paddedWidth-centre);centre+=min(leftOver,extra);float rightOver=max(0.0,paddedWidth+centre-2.0);centre-=min(rightOver,extra);}pos=centre/2.0;}else if(align<0){float edge=a;if(flush){float over=max(0.0,-edge);edge+=min(over,extra);}pos=edge+padding;}else{float edge=b;if(flush){float over=max(0.0,edge-1.0);edge-=min(over,extra);}pos=edge-padding;}float scale=clamp((span-padding)/paddedWidth,0.0,1.0);return RangeResult(pos,scale);}vec2 calculateRotatedDimensions(float width,mat2 rotationMatrix){vec2 a=abs(rotationMatrix*vec2(width/2.0,0.5));vec2 b=abs(rotationMatrix*vec2(width/2.0,-0.5));return vec2(max(a.x,b.x),max(a.y,b.y))*2.0;}ivec2 fixAlignForAngle(ivec2 align,float angleInDegrees){float a=mod(angleInDegrees+45.0,360.0);int x=align.x;int y=-align.y;if(a<90.0){return ivec2(x,y);}else if(a<180.0){return ivec2(y,-x);}else if(a<270.0){return ivec2(-x,y);}else{return ivec2(-y,x);}}void main(void){float opacity=getScaled_opacity()*uViewOpacity;vec2 size=vec2(getScaled_size());float x=getScaled_x();float y=getScaled_y();float scale=1.0;float angleInDegrees=getScaled_angle();float angle=-angleInDegrees*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);mat2 rotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);vec2 flushSize=calculateRotatedDimensions(width,rotationMatrix);\n#if defined(x2_DEFINED) || defined(y2_DEFINED)\nivec2 align=fixAlignForAngle(uAlign,angleInDegrees);\n#else\nivec2 align=uAlign;\n#endif\n#ifdef x2_DEFINED\nfloat x2=getScaled_x2();if(uLogoLetter){size.x=(x2-x)*uViewportSize.x;x+=(x2-x)/2.0;}else{float x2=getScaled_x2();RangeResult result=positionInsideRange(min(x,x2),max(x,x2),size.x*scale*flushSize.x/uViewportSize.x,uPaddingX/uViewportSize.x,align.x,uFlushX);x=result.pos;scale*=result.scale;}\n#endif\nvec2 pos=applySampleFacet(vec2(x,y));\n#ifdef y2_DEFINED\nfloat y2=getScaled_y2();vec2 pos2=applySampleFacet(vec2(x,y2));if(uLogoLetter){size.y=(pos2.y-pos.y)*uViewportSize.y;pos.y+=(pos2.y-pos.y)/2.0;}else{RangeResult result=positionInsideRange(min(pos.y,pos2.y),max(pos.y,pos2.y),size.y*scale*flushSize.y/uViewportSize.y,uPaddingY/uViewportSize.y,align.y,uFlushY);pos.y=result.pos;scale*=result.scale;}\n#endif\nif(scale<1.0){if(uSqueeze){vec2 scaleFadeExtent=vec2(3.0,6.0)/size;if(scale<scaleFadeExtent[0]){gl_Position=vec4(0.0);return;}size*=scale;opacity*=linearstep(scaleFadeExtent[0],scaleFadeExtent[1],scale);}else if(scale<1.0){gl_Position=vec4(0.0);return;}}vec2 charPos=rotationMatrix*(vertexCoord*size+uD);vec2 unitPos=pos+charPos/uViewportSize;gl_Position=unitToNdc(unitPos);vSlope=max(1.0,min(size.x,size.y)/uSdfNumerator);vColor=vec4(
|
|
1
|
+
const shader = "in mediump vec2 vertexCoord;in lowp vec2 textureCoord;in float width;out vec2 vTexCoord;out vec4 vColor;out float vSlope;out float vEdgeFadeOpacity;out float vGamma;struct RangeResult{float pos;float scale;};float minValue(vec4 v){return min(min(v.x,v.y),min(v.z,v.w));}float maxValue(vec4 v){return max(max(v.x,v.y),max(v.z,v.w));}/***All measures are in[0,1]*/RangeResult positionInsideRange(float a,float b,float width,float padding,int align,bool flush){float span=b-a;float paddedWidth=width+2.0*padding;if(a>1.0||b<0.0){return RangeResult(0.0,0.0);}float extra=max(0.0,span-paddedWidth);float pos;if(align==0){float centre=a+b;if(flush){float leftOver=max(0.0,paddedWidth-centre);centre+=min(leftOver,extra);float rightOver=max(0.0,paddedWidth+centre-2.0);centre-=min(rightOver,extra);}pos=centre/2.0;}else if(align<0){float edge=a;if(flush){float over=max(0.0,-edge);edge+=min(over,extra);}pos=edge+padding;}else{float edge=b;if(flush){float over=max(0.0,edge-1.0);edge-=min(over,extra);}pos=edge-padding;}float scale=clamp((span-padding)/paddedWidth,0.0,1.0);return RangeResult(pos,scale);}vec2 calculateRotatedDimensions(float width,mat2 rotationMatrix){vec2 a=abs(rotationMatrix*vec2(width/2.0,0.5));vec2 b=abs(rotationMatrix*vec2(width/2.0,-0.5));return vec2(max(a.x,b.x),max(a.y,b.y))*2.0;}ivec2 fixAlignForAngle(ivec2 align,float angleInDegrees){float a=mod(angleInDegrees+45.0,360.0);int x=align.x;int y=-align.y;if(a<90.0){return ivec2(x,y);}else if(a<180.0){return ivec2(y,-x);}else if(a<270.0){return ivec2(-x,y);}else{return ivec2(-y,x);}}void main(void){float opacity=getScaled_opacity()*uViewOpacity;vec2 size=vec2(getScaled_size());float x=getScaled_x();float y=getScaled_y();float scale=1.0;float angleInDegrees=getScaled_angle();float angle=-angleInDegrees*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);mat2 rotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);vec2 flushSize=calculateRotatedDimensions(width,rotationMatrix);\n#if defined(x2_DEFINED) || defined(y2_DEFINED)\nivec2 align=fixAlignForAngle(uAlign,angleInDegrees);\n#else\nivec2 align=uAlign;\n#endif\n#ifdef x2_DEFINED\nfloat x2=getScaled_x2();if(uLogoLetter){size.x=(x2-x)*uViewportSize.x;x+=(x2-x)/2.0;}else{float x2=getScaled_x2();RangeResult result=positionInsideRange(min(x,x2),max(x,x2),size.x*scale*flushSize.x/uViewportSize.x,uPaddingX/uViewportSize.x,align.x,uFlushX);x=result.pos;scale*=result.scale;}\n#endif\nvec2 pos=applySampleFacet(vec2(x,y));\n#ifdef y2_DEFINED\nfloat y2=getScaled_y2();vec2 pos2=applySampleFacet(vec2(x,y2));if(uLogoLetter){size.y=(pos2.y-pos.y)*uViewportSize.y;pos.y+=(pos2.y-pos.y)/2.0;}else{RangeResult result=positionInsideRange(min(pos.y,pos2.y),max(pos.y,pos2.y),size.y*scale*flushSize.y/uViewportSize.y,uPaddingY/uViewportSize.y,align.y,uFlushY);pos.y=result.pos;scale*=result.scale;}\n#endif\nif(scale<1.0){if(uSqueeze){vec2 scaleFadeExtent=vec2(3.0,6.0)/size;if(scale<scaleFadeExtent[0]){gl_Position=vec4(0.0);return;}size*=scale;opacity*=linearstep(scaleFadeExtent[0],scaleFadeExtent[1],scale);}else if(scale<1.0){gl_Position=vec4(0.0);return;}}vec2 charPos=rotationMatrix*(vertexCoord*size+uD);vec2 unitPos=pos+charPos/uViewportSize;gl_Position=unitToNdc(unitPos);vSlope=max(1.0,min(size.x,size.y)/uSdfNumerator);vec3 color=getScaled_color();vColor=vec4(color*opacity,opacity);vGamma=getGammaForColor(color);vTexCoord=textureCoord;if(maxValue(uViewportEdgeFadeDistance)>-pow(10.0,10.0)){vEdgeFadeOpacity=minValue(((vec4(1.0,1.0,0.0,0.0)+vec4(-1.0,-1.0,1.0,1.0)*unitPos.yxyx)*uViewportSize.yxyx-uViewportEdgeFadeDistance)/uViewportEdgeFadeWidth);}else{vEdgeFadeOpacity=1.0;}setupPicking();}";
|
|
2
2
|
export default shader;
|
|
@@ -141,8 +141,19 @@ export interface ScaleMixins {
|
|
|
141
141
|
* An alternative channel for scale resolution.
|
|
142
142
|
*
|
|
143
143
|
* This is mainly for internal use and allows using `color` channel to resolve `fill` and `stroke` channels under certain circumstances.
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
144
146
|
*/
|
|
145
147
|
resolutionChannel?: ChannelWithScale;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Whether the field or evaluated expr should be included in the scale's domain.
|
|
151
|
+
*
|
|
152
|
+
* **Default value:** `true`
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
contributesToScaleDomain?: boolean;
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
export interface ValueDefBase<V extends Value = Scalar> {
|
|
@@ -157,6 +168,7 @@ export type ValueDef<V extends Value = Scalar> = ValueDefBase<V> & TitleMixins;
|
|
|
157
168
|
export interface DatumDef<V extends Scalar | ExprRef = Scalar | ExprRef>
|
|
158
169
|
extends Partial<TypeMixins<Type>>,
|
|
159
170
|
BandMixins,
|
|
171
|
+
ScaleMixins,
|
|
160
172
|
TitleMixins {
|
|
161
173
|
/**
|
|
162
174
|
* A constant value in data domain.
|
|
@@ -261,7 +273,8 @@ export type ValueDefWithCondition<V extends Value = Value> = Partial<
|
|
|
261
273
|
condition?:
|
|
262
274
|
| Conditional<FieldDef>
|
|
263
275
|
| Conditional<DatumDef>
|
|
264
|
-
| Conditional<ValueDef<V | ExprRef
|
|
276
|
+
| Conditional<ValueDef<V | ExprRef>>
|
|
277
|
+
| Conditional<ValueDef<V | ExprRef>>[];
|
|
265
278
|
};
|
|
266
279
|
|
|
267
280
|
export type MarkPropFieldOrDatumOrExprDef<T extends Type = Type> =
|