@@ -247,6 +247,7 @@ const createScatterplot = (initialProperties = {}) => {
247247 const fbo = regl . framebuffer ( {
248248 width : fboRes [ 0 ] ,
249249 height : fboRes [ 1 ] ,
250+ colorFormat : 'rgba' ,
250251 colorType : 'float' ,
251252 } ) ;
252253 let backgroundColorBrightness = rgbBrightness ( backgroundColor ) ;
@@ -1187,7 +1188,7 @@ const createScatterplot = (initialProperties = {}) => {
11871188
11881189 void main () {
11891190 vec4 color = texture2D(src, gl_FragCoord.xy / srcRes);
1190- gl_FragColor = vec4(approxLinearToSRGB(color.rgb, gamma), 1 );
1191+ gl_FragColor = vec4(approxLinearToSRGB(color.rgb, gamma), color.a );
11911192 }` ,
11921193 attributes : {
11931194 xy : [ - 4 , - 4 , 4 , - 4 , 0 , 4 ] ,
@@ -1199,6 +1200,15 @@ const createScatterplot = (initialProperties = {}) => {
11991200 } ,
12001201 count : 3 ,
12011202 depth : { enable : false } ,
1203+ blend : {
1204+ enable : true ,
1205+ func : {
1206+ srcRGB : 'one' ,
1207+ srcAlpha : 'one' ,
1208+ dstRGB : 'one minus src alpha' ,
1209+ dstAlpha : 'one minus src alpha' ,
1210+ } ,
1211+ } ,
12021212 } ) ;
12031213
12041214 const drawPoints = (
@@ -1696,27 +1706,34 @@ const createScatterplot = (initialProperties = {}) => {
16961706 // Update camera
16971707 isViewChanged = camera . tick ( ) ;
16981708
1709+ regl . clear ( {
1710+ // background color (transparent)
1711+ color : [ 0 , 0 , 0 , 0 ] ,
1712+ depth : 1 ,
1713+ } ) ;
1714+
1715+ // eslint-disable-next-line no-underscore-dangle
1716+ if ( backgroundImage && backgroundImage . _reglType ) {
1717+ drawBackgroundImage ( ) ;
1718+ }
1719+
1720+ if ( lassoPointsCurr . length > 2 ) drawPolygon2d ( ) ;
1721+
1722+ // The draw order of the following calls is important!
1723+ if ( ! isTransitioning )
1724+ pointConnections . draw ( {
1725+ projection : getProjection ( ) ,
1726+ model : getModel ( ) ,
1727+ view : getView ( ) ,
1728+ } ) ;
1729+
16991730 fbo . use ( ( ) => {
17001731 regl . clear ( {
17011732 // background color (transparent)
17021733 color : [ 0 , 0 , 0 , 0 ] ,
17031734 depth : 1 ,
17041735 } ) ;
17051736
1706- // eslint-disable-next-line no-underscore-dangle
1707- if ( backgroundImage && backgroundImage . _reglType ) {
1708- drawBackgroundImage ( ) ;
1709- }
1710-
1711- if ( lassoPointsCurr . length > 2 ) drawPolygon2d ( ) ;
1712-
1713- // The draw order of the following calls is important!
1714- if ( ! isTransitioning )
1715- pointConnections . draw ( {
1716- projection : getProjection ( ) ,
1717- model : getModel ( ) ,
1718- view : getView ( ) ,
1719- } ) ;
17201737 drawPointBodies ( ) ;
17211738 if ( ! mouseDown && ( showRecticle || showRecticleOnce ) ) drawRecticle ( ) ;
17221739 if ( hoveredPoint >= 0 ) drawHoveredPoint ( ) ;
@@ -2573,6 +2590,12 @@ const createScatterplot = (initialProperties = {}) => {
25732590 }
25742591 } ;
25752592
2593+ const exportFn = ( options = { } ) => ( {
2594+ pixels : Uint8ClampedArray . from ( regl . read ( options ) ) ,
2595+ width : currentWidth * window . devicePixelRatio ,
2596+ height : currentHeight * window . devicePixelRatio ,
2597+ } ) ;
2598+
25762599 const init = ( ) => {
25772600 updateViewAspectRatio ( ) ;
25782601 initCamera ( ) ;
@@ -2676,6 +2699,7 @@ const createScatterplot = (initialProperties = {}) => {
26762699 reset : withDraw ( reset ) ,
26772700 select,
26782701 set,
2702+ export : exportFn ,
26792703 subscribe : pubSub . subscribe ,
26802704 unsubscribe : pubSub . unsubscribe ,
26812705 } ;
0 commit comments