From d123a18112ec3b78b8948ceffe6415291741a3a3 Mon Sep 17 00:00:00 2001 From: Luisav1 Date: Mon, 14 Aug 2023 09:44:32 -0600 Subject: [PATCH] Use electron colorProperty. See https://github.com/phetsims/build-a-nucleus/issues/112. --- js/common/view/ParticleAtomNode.ts | 9 +++++---- js/decay/view/DecayScreenView.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/js/common/view/ParticleAtomNode.ts b/js/common/view/ParticleAtomNode.ts index 4dd58ce..3a4f10b 100644 --- a/js/common/view/ParticleAtomNode.ts +++ b/js/common/view/ParticleAtomNode.ts @@ -18,6 +18,7 @@ import AtomIdentifier from '../../../../shred/js/AtomIdentifier.js'; import Particle from '../../../../shred/js/model/Particle.js'; import ParticleView from '../../../../shred/js/view/ParticleView.js'; import Range from '../../../../dot/js/Range.js'; +import BANColors from '../BANColors.js'; // empirically determined, from the ElectronCloudView radius const MIN_ELECTRON_CLOUD_RADIUS = 42.5; @@ -44,8 +45,8 @@ class ParticleAtomNode extends Node { const electronCloud = new Circle( { radius: MIN_ELECTRON_CLOUD_RADIUS, fill: new RadialGradient( 0, 0, 0, 0, 0, MIN_ELECTRON_CLOUD_RADIUS ) - .addColorStop( 0, 'rgba( 0, 0, 255, 200 )' ) - .addColorStop( 0.9, 'rgba( 0, 0, 255, 0 )' ) + .addColorStop( 0, BANColors.electronColorProperty.value.withAlpha( 200 ) ) + .addColorStop( 0.9, BANColors.electronColorProperty.value.withAlpha( 0 ) ) } ); electronCloud.center = atomCenter; @@ -163,8 +164,8 @@ class ParticleAtomNode extends Node { this.electronCloud.radius = radius * factor; this.electronCloud.fill = new RadialGradient( 0, 0, 0, 0, 0, radius * factor ) // TODO: use color.interpolateRGBA() to use the same color property in both https://github.com/phetsims/build-a-nucleus/issues/85 - .addColorStop( 0, 'rgba( 0, 0, 255, 200 )' ) - .addColorStop( 0.9, 'rgba( 0, 0, 255, 0 )' ); // Color.withAlpha() + .addColorStop( 0, BANColors.electronColorProperty.value.withAlpha( 200 ) ) + .addColorStop( 0.9, BANColors.electronColorProperty.value.withAlpha( 0 ) ); } } diff --git a/js/decay/view/DecayScreenView.ts b/js/decay/view/DecayScreenView.ts index c7e9c8f..2121d0b 100644 --- a/js/decay/view/DecayScreenView.ts +++ b/js/decay/view/DecayScreenView.ts @@ -194,8 +194,8 @@ class DecayScreenView extends BANScreenView { new Circle( { radius: 18, fill: new RadialGradient( 0, 0, 0, 0, 0, 18 ) - .addColorStop( 0, 'rgba( 0, 0, 255, 200 )' ) - .addColorStop( 0.9, 'rgba( 0, 0, 255, 0 )' ) + .addColorStop( 0, BANColors.electronColorProperty.value.withAlpha( 200 ) ) + .addColorStop( 0.9, BANColors.electronColorProperty.value.withAlpha( 0 ) ) } ) ], spacing: 5