Skip to content

Commit

Permalink
Add ColorProperty, see phetsims/axon#221
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 24, 2020
1 parent 1015401 commit a38dbea
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions js/util/ColorProperty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2020, University of Colorado Boulder

import Property from '../../../axon/js/Property.js';
import merge from '../../../phet-core/js/merge.js';
import Color from './Color.js';
import scenery from '../scenery.js';

/**
* Convenience type for creating Property<Color>
*
* @author Sam Reid (PhET Interactive Simulations)
*/
class ColorProperty extends Property {

constructor( color, options ) {

// client cannot specify superclass options that are controlled by this type
if ( options ) {
assert && assert( !options.hasOwnProperty( 'valueType' ), 'ColorProperty sets valueType' );
assert && assert( !options.hasOwnProperty( 'phetioType' ), 'ColorProperty sets phetioType' );
}

options = merge( {
valueType: Color,
phetioType: Property.PropertyIO( Color.ColorIO )
}, options );
super( color, options );
}
}

scenery.register( 'ColorProperty', ColorProperty );
export default ColorProperty;

0 comments on commit a38dbea

Please sign in to comment.