-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ColorProperty, see phetsims/axon#221
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |