@@ -55,35 +55,57 @@ import {
5555
5656import { version } from '../package.json' ;
5757
58- const createScatterplot = ( {
59- regl : initialRegl ,
60- background : initialBackground = DEFAULT_COLOR_BG ,
61- backgroundImage : initialBackgroundImage = DEFAULT_BACKGROUND_IMAGE ,
62- canvas : initialCanvas = document . createElement ( 'canvas' ) ,
63- colorBy : initialColorBy = DEFAULT_COLOR_BY ,
64- colors : initialColors = DEFAULT_COLORS ,
65- lassoColor : initialLassoColor = DEFAULT_LASSO_COLOR ,
66- lassoMinDelay : initialLassoMinDelay = LASSO_MIN_DELAY ,
67- lassoMinDist : initialLassoMinDist = LASSO_MIN_DIST ,
68- showRecticle : initialShowRecticle = DEFAULT_SHOW_RECTICLE ,
69- recticleColor : initialRecticleColor = DEFAULT_RECTICLE_COLOR ,
70- pointSize : initialPointSize = DEFAULT_POINT_SIZE ,
71- pointSizeSelected : initialPointSizeSelected = DEFAULT_POINT_SIZE_SELECTED ,
72- pointOutlineWidth : initialPointOutlineWidth = DEFAULT_POINT_OUTLINE_WIDTH ,
73- width : initialWidth = DEFAULT_WIDTH ,
74- height : initialHeight = DEFAULT_HEIGHT ,
75- target : initialTarget = DEFAULT_TARGET ,
76- distance : initialDistance = DEFAULT_DISTANCE ,
77- rotation : initialRotation = DEFAULT_ROTATION ,
78- view : initialView = DEFAULT_VIEW
79- } = { } ) => {
58+ const deprecations = {
59+ background : 'backgroundColor'
60+ } ;
61+
62+ const checkDeprecations = properties => {
63+ Object . keys ( properties )
64+ . filter ( prop => deprecations [ prop ] )
65+ . forEach ( name => {
66+ console . warn (
67+ `regl-scatterplot: the "${ name } " property is deprecated. Please use "${ deprecations [ name ] } " instead.`
68+ ) ;
69+ } ) ;
70+ } ;
71+
72+ const createScatterplot = ( initialProperties = { } ) => {
8073 const pubSub = createPubSub ( ) ;
8174 const scratch = new Float32Array ( 16 ) ;
8275 const mousePosition = [ 0 , 0 ] ;
8376
77+ checkDeprecations ( initialProperties ) ;
78+
79+ const {
80+ regl : initialRegl ,
81+ background : initialBackground ,
82+ backgroundColor : initialBackgroundColor ,
83+ backgroundImage : initialBackgroundImage = DEFAULT_BACKGROUND_IMAGE ,
84+ canvas : initialCanvas = document . createElement ( 'canvas' ) ,
85+ colorBy : initialColorBy = DEFAULT_COLOR_BY ,
86+ colors : initialColors = DEFAULT_COLORS ,
87+ lassoColor : initialLassoColor = DEFAULT_LASSO_COLOR ,
88+ lassoMinDelay : initialLassoMinDelay = LASSO_MIN_DELAY ,
89+ lassoMinDist : initialLassoMinDist = LASSO_MIN_DIST ,
90+ showRecticle : initialShowRecticle = DEFAULT_SHOW_RECTICLE ,
91+ recticleColor : initialRecticleColor = DEFAULT_RECTICLE_COLOR ,
92+ pointSize : initialPointSize = DEFAULT_POINT_SIZE ,
93+ pointSizeSelected : initialPointSizeSelected = DEFAULT_POINT_SIZE_SELECTED ,
94+ pointOutlineWidth : initialPointOutlineWidth = DEFAULT_POINT_OUTLINE_WIDTH ,
95+ width : initialWidth = DEFAULT_WIDTH ,
96+ height : initialHeight = DEFAULT_HEIGHT ,
97+ target : initialTarget = DEFAULT_TARGET ,
98+ distance : initialDistance = DEFAULT_DISTANCE ,
99+ rotation : initialRotation = DEFAULT_ROTATION ,
100+ view : initialView = DEFAULT_VIEW
101+ } = initialProperties ;
102+
84103 checkReglExtensions ( initialRegl ) ;
85104
86- let background = toRgba ( initialBackground , true ) ;
105+ let backgroundColor = toRgba (
106+ initialBackgroundColor || initialBackground || DEFAULT_COLOR_BG ,
107+ true
108+ ) ;
87109 let backgroundImage = initialBackgroundImage ;
88110 let canvas = initialCanvas ;
89111 let colors = initialColors ;
@@ -406,7 +428,7 @@ const createScatterplot = ({
406428 const rgbaOpaque = [ ...rgba . slice ( 0 , 3 ) , 1 ] ;
407429 tmp . push ( rgba , rgbaOpaque , rgbaOpaque ) ; // normal, active, and hover
408430 }
409- tmp . push ( background ) ;
431+ tmp . push ( backgroundColor ) ;
410432 } ) ;
411433 } catch ( e ) {
412434 console . error (
@@ -740,10 +762,10 @@ const createScatterplot = ({
740762 return out ;
741763 } ;
742764
743- const setBackground = newBackground => {
744- if ( ! newBackground ) return ;
765+ const setBackgroundColor = newBackgroundColor => {
766+ if ( ! newBackgroundColor ) return ;
745767
746- background = toRgba ( newBackground , true ) ;
768+ backgroundColor = toRgba ( newBackgroundColor , true ) ;
747769 } ;
748770
749771 const setBackgroundImage = newBackgroundImage => {
@@ -802,7 +824,10 @@ const createScatterplot = ({
802824 } ;
803825
804826 const get = property => {
805- if ( property === 'background' ) return background ;
827+ checkDeprecations ( { property : true } ) ;
828+
829+ if ( property === 'background' ) return backgroundColor ;
830+ if ( property === 'backgroundColor' ) return backgroundColor ;
806831 if ( property === 'backgroundImage' ) return backgroundImage ;
807832 if ( property === 'colorBy' ) return colorBy ;
808833 if ( property === 'colors' ) return colors ;
@@ -823,25 +848,30 @@ const createScatterplot = ({
823848 return undefined ;
824849 } ;
825850
826- const set = ( {
827- background : newBackground = null ,
828- backgroundImage : newBackgroundImage = backgroundImage ,
829- colorBy : newColorBy = colorBy ,
830- colors : newColors = null ,
831- opacity : newOpacity = null ,
832- lassoColor : newLassoColor = null ,
833- lassoMinDelay : newLassoMinDelay = null ,
834- lassoMinDist : newLassoMinDist = null ,
835- showRecticle : newShowRecticle = null ,
836- recticleColor : newRecticleColor = null ,
837- pointOutlineWidth : newPointOutlineWidth = null ,
838- pointSize : newPointSize = null ,
839- pointSizeSelected : newPointSizeSelected = null ,
840- height : newHeight = null ,
841- width : newWidth = null ,
842- aspectRatio : newDataAspectRatio = null
843- } = { } ) => {
844- setBackground ( newBackground ) ;
851+ const set = ( properties = { } ) => {
852+ checkDeprecations ( properties ) ;
853+
854+ const {
855+ background : newBackground = null ,
856+ backgroundColor : newBackgroundColor = null ,
857+ backgroundImage : newBackgroundImage = backgroundImage ,
858+ colorBy : newColorBy = colorBy ,
859+ colors : newColors = null ,
860+ opacity : newOpacity = null ,
861+ lassoColor : newLassoColor = null ,
862+ lassoMinDelay : newLassoMinDelay = null ,
863+ lassoMinDist : newLassoMinDist = null ,
864+ showRecticle : newShowRecticle = null ,
865+ recticleColor : newRecticleColor = null ,
866+ pointOutlineWidth : newPointOutlineWidth = null ,
867+ pointSize : newPointSize = null ,
868+ pointSizeSelected : newPointSizeSelected = null ,
869+ height : newHeight = null ,
870+ width : newWidth = null ,
871+ aspectRatio : newDataAspectRatio = null
872+ } = properties ;
873+
874+ setBackgroundColor ( newBackgroundColor || newBackground ) ;
845875 setBackgroundImage ( newBackgroundImage ) ;
846876 setColorBy ( newColorBy ) ;
847877 setColors ( newColors ) ;
0 commit comments