public void InitializeMovement(List<Vector2> points) { _points = points; _tween = new LinearTween(points[0], points[1], getStandardSpeed(points[0], points[1]), Ease.None); _tween.Ended += tween_Ended; _targetPointIndex = 1; _colorTween = new ColorTween(Color.Transparent, Color.White, 1000, Ease.None); }
Color _getFillColor() { if (widget.highlightElevation == null || widget.highlightElevation == 0.0) { return(Colors.transparent); } Color color = widget.color ?? Theme.of(context).canvasColor; ColorTween colorTween = new ColorTween( begin: color.withAlpha(0x00), end: color.withAlpha(0xFF) ); return(colorTween.evaluate(_fillAnimation)); }
public BaseTween ColorTween(Image image, Color to, float t) { ColorTween tween = TweenPool.GetColorTween(image.color, to, t); tween.SetOnUpdateColor(delegate(Color c) { if (image == null) { CancelTween(tween); return; } image.color = c; }); return(ProcessTween(tween)); }
public BaseTween ColorTween(SpriteRenderer sprite, Color to, float t) { ColorTween tween = TweenPool.GetColorTween(sprite.color, to, t); tween.SetOnUpdateColor(delegate(Color c) { if (sprite == null) { TweenPool.FinishTween(tween); return; } sprite.color = c; }); return(ProcessTween(tween)); }
internal static ColorTween GetColorTween(Color from, Color to, float t) { ColorTween tween; if (TryGetTween(colorTweens, out tween)) { tween.Init(from, to, t); } else { tween = new ColorTween(from, to, t, GenerateId()); tween.Recycle = FinishTween; } _activeTweens.Add(tween); return(tween); }
bool _updateColors() { D.assert(mounted, () => "This should only be called after didUpdateDependencies"); bool changed = false; Color selectedColor = widget.selectedColor ?? CupertinoTheme.of(context).primaryColor; if (_selectedColor != selectedColor) { changed = true; _selectedColor = selectedColor; } Color unselectedColor = widget.unselectedColor ?? CupertinoTheme.of(context).primaryContrastingColor; if (_unselectedColor != unselectedColor) { changed = true; _unselectedColor = unselectedColor; } Color borderColor = widget.borderColor ?? CupertinoTheme.of(context).primaryColor; if (_borderColor != borderColor) { changed = true; _borderColor = borderColor; } Color pressedColor = widget.pressedColor ?? CupertinoTheme.of(context).primaryColor.withOpacity(0.2f); if (_pressedColor != pressedColor) { changed = true; _pressedColor = pressedColor; } _forwardBackgroundColorTween = new ColorTween( begin: _pressedColor, end: _selectedColor ); _reverseBackgroundColorTween = new ColorTween( begin: _unselectedColor, end: _selectedColor ); _textColorTween = new ColorTween( begin: _selectedColor, end: _unselectedColor ); return(changed); }
public override void paint( PaintingContext context, Offset center, Animation <float> activationAnimation = null, Animation <float> enableAnimation = null, bool isDiscrete = false, TextPainter labelPainter = null, RenderBox parentBox = null, SliderThemeData sliderTheme = null, TextDirection?textDirection = null, float?value = null) { Canvas canvas = context.canvas; ColorTween enableColor = new ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.valueIndicatorColor ); Tween <float> slideUpTween = new FloatTween( begin: 0.0f, end: _slideUpHeight ); float size = _indicatorSize * sizeTween.evaluate(enableAnimation); Offset slideUpOffset = new Offset(0.0f, -slideUpTween.evaluate(activationAnimation)); Path thumbPath = SliderDemoUtils._upTriangle(size, center + slideUpOffset); Color paintColor = enableColor.evaluate(enableAnimation) .withAlpha((255.0f * activationAnimation.value).round()); canvas.drawPath( thumbPath, new Paint { color = paintColor } ); canvas.drawLine( center, center + slideUpOffset, new Paint { color = paintColor, style = PaintingStyle.stroke, strokeWidth = 2.0f }); labelPainter.paint(canvas, center + slideUpOffset + new Offset(-labelPainter.width / 2.0f, -labelPainter.height - 4.0f)); }
public _TileIcon( Key key = null, ColorTween colorTween = null, Animation <float> animation = null, float?iconSize = null, bool?selected = null, BottomNavigationBarItem item = null ) : base(key: key) { D.assert(selected != null); D.assert(item != null); this.colorTween = colorTween; this.animation = animation; this.iconSize = iconSize; this.selected = selected; this.item = item; }
public static void TweenColor(GameObject go, float duration, Color color, Tweener.Method method) { if (go.activeSelf && go.renderer != null) { ColorTween tweenColor = ColorTween.Begin(go, duration, color); tweenColor.method = method; if (duration == 0) { tweenColor.color = color; } } for (int i = 0; i < go.transform.childCount; i++) { TweenColor(go.transform.GetChild(i).gameObject, duration, color, method); } }
public static PTween createTween <T>() where T : struct { PTween tween = null; Type t = typeof(T); if (t == typeof(int)) { tween = new IntTween(); } else if (t == typeof(float)) { tween = new FloatTween(); } else if (t == typeof(Vector2)) { tween = new Vector2Tween(); } else if (t == typeof(Vector3)) { tween = new Vector3Tween(); } else if (t == typeof(Vector4)) { tween = new Vector4Tween(); } else if (t == typeof(Color)) { tween = new ColorTween(); } else if (t == typeof(Quaternion)) { tween = new QuaternionTween(); } else { Debug.LogError("PTween createTween: invalid type: " + t); return(null); } add(tween); return(tween); }
public _BottomNavigationTile( BottomNavigationBarType?type, BottomNavigationBarItem item, Animation <float> animation, float?iconSize = null, VoidCallback onTap = null, ColorTween colorTween = null, float?flex = null, bool selected = false, IconThemeData selectedIconTheme = null, IconThemeData unselectedIconTheme = null, TextStyle selectedLabelStyle = null, TextStyle unselectedLabelStyle = null, bool?showSelectedLabels = null, bool?showUnselectedLabels = null, string indexLabel = null ) { D.assert(type != null); D.assert(item != null); D.assert(animation != null); D.assert(selectedLabelStyle != null); D.assert(unselectedLabelStyle != null); this.type = type; this.item = item; this.animation = animation; this.iconSize = iconSize; this.onTap = onTap; this.colorTween = colorTween; this.flex = flex; this.selected = selected; this.selectedLabelStyle = selectedLabelStyle; this.unselectedLabelStyle = unselectedLabelStyle; this.selectedIconTheme = selectedIconTheme; this.unselectedIconTheme = unselectedIconTheme; this.showSelectedLabels = showSelectedLabels ?? false; this.showUnselectedLabels = showUnselectedLabels ?? false; this.indexLabel = indexLabel; }
/// <summary> /// Starts a color tween. /// </summary> /// <param name="targetColor">Target color.</param> /// <param name="duration">Duration.</param> private void StartColorTweenText(Color targetColor, float duration) { if (this.m_TextTarget == null) { return; } if (!Application.isPlaying || duration == 0f) { this.m_TextTarget.color = targetColor; } else { var colorTween = new ColorTween { duration = duration, startColor = this.m_TextTarget.color, targetColor = targetColor }; colorTween.AddOnChangedCallback(SetTextColor); colorTween.ignoreTimeScale = true; this.m_ColorTweenRunner.StartTween(colorTween); } }
private void tween_Ended(object sender, System.EventArgs e) { if (_targetPointIndex + 1 < _points.Count) { Vector2 start = _points[_targetPointIndex]; Vector2 stop = _points[_targetPointIndex + 1]; _tween = new LinearTween(start, stop, getStandardSpeed(start, stop), Ease.None); _tween.Ended += tween_Ended; if (_targetPointIndex + 2 >= _points.Count) _colorTween = new ColorTween(Color.White, Color.Transparent, 1000, Ease.None); _targetPointIndex += 1; } else { Vector2 start = _points[0]; Vector2 stop = _points[1]; _tween = new LinearTween(start, stop, getStandardSpeed(start, stop), Ease.None); _tween.Ended += tween_Ended; _colorTween = new ColorTween(Color.Transparent, Color.White, 1000, Ease.None); _targetPointIndex = 1; } }
public _BottomNavigationTile( BottomNavigationBarType?type, BottomNavigationBarItem item, Animation <float> animation, float?iconSize = null, VoidCallback onTap = null, ColorTween colorTween = null, float?flex = null, bool selected = false, string indexLabel = null ) { this.type = type; this.item = item; this.animation = animation; this.iconSize = iconSize; this.onTap = onTap; this.colorTween = colorTween; this.flex = flex; this.selected = selected; this.indexLabel = indexLabel; }
public override void paint( PaintingContext context, Offset center, Animation <float> activationAnimation = null, Animation <float> enableAnimation = null, bool isDiscrete = false, TextPainter labelPainter = null, RenderBox parentBox = null, SliderThemeData sliderTheme = null, TextDirection?textDirection = null, float?value = null) { Canvas canvas = context.canvas; ColorTween colorTween = new ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.thumbColor ); float size = _thumbSize * sizeTween.evaluate(enableAnimation); Path thumbPath = SliderDemoUtils._downTriangle(size, center); canvas.drawPath(thumbPath, new Paint { color = colorTween.evaluate(enableAnimation) }); }
List <Widget> _createTiles() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); D.assert(localizations != null); ThemeData themeData = Theme.of(this.context); Color themeColor; switch (themeData.brightness) { case Brightness.light: themeColor = themeData.primaryColor; break; case Brightness.dark: themeColor = themeData.accentColor; break; default: throw new Exception("Unknown brightness: " + themeData.brightness); } ColorTween colorTween; switch (this.widget.type) { case BottomNavigationBarType.fix: colorTween = new ColorTween( begin: this.widget.unselectedItemColor ?? themeData.textTheme.caption.color, end: this.widget.selectedItemColor ?? this.widget.fixedColor ?? themeColor ); break; case BottomNavigationBarType.shifting: colorTween = new ColorTween( begin: this.widget.unselectedItemColor ?? Colors.white, end: this.widget.selectedItemColor ?? Colors.white ); break; default: throw new UIWidgetsError($"Unknown bottom navigation bar type: {this.widget.type}"); } List <Widget> tiles = new List <Widget>(); for (int i = 0; i < this.widget.items.Count; i++) { int index = i; tiles.Add(new _BottomNavigationTile( this.widget.type, this.widget.items[i], this._animations[i], this.widget.iconSize, selectedFontSize: this.widget.selectedFontSize, unselectedFontSize: this.widget.unselectedFontSize, onTap: () => { if (this.widget.onTap != null) { this.widget.onTap(index); } }, colorTween: colorTween, flex: this._evaluateFlex(this._animations[i]), selected: i == this.widget.currentIndex, showSelectedLabels: this.widget.showSelectedLabels, showUnselectedLabels: this.widget.showUnselectedLabels, indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: this.widget.items.Count) )); } return(tiles); }
public override void paint(PaintingContext context, Offset offset) { Canvas canvas = context.canvas; float trackLength = this.size.width - 2 * _overlayRadius; float value = this._state.positionController.value; ColorTween activeTrackEnableColor = new ColorTween(begin: this._sliderTheme.disabledActiveTrackColor, end: this._sliderTheme.activeTrackColor); ColorTween inactiveTrackEnableColor = new ColorTween(begin: this._sliderTheme.disabledInactiveTrackColor, end: this._sliderTheme.inactiveTrackColor); ColorTween activeTickMarkEnableColor = new ColorTween(begin: this._sliderTheme.disabledActiveTickMarkColor, end: this._sliderTheme.activeTickMarkColor); ColorTween inactiveTickMarkEnableColor = new ColorTween(begin: this._sliderTheme.disabledInactiveTickMarkColor, end: this._sliderTheme.inactiveTickMarkColor); Paint activeTrackPaint = new Paint { color = activeTrackEnableColor.evaluate(this._enableAnimation) }; Paint inactiveTrackPaint = new Paint { color = inactiveTrackEnableColor.evaluate(this._enableAnimation) }; Paint activeTickMarkPaint = new Paint { color = activeTickMarkEnableColor.evaluate(this._enableAnimation) }; Paint inactiveTickMarkPaint = new Paint { color = inactiveTickMarkEnableColor.evaluate(this._enableAnimation) }; float visualPosition = value; Paint leftTrackPaint = activeTrackPaint; Paint rightTrackPaint = inactiveTrackPaint; Paint leftTickMarkPaint = activeTickMarkPaint; Paint rightTickMarkPaint = inactiveTickMarkPaint; float trackRadius = _trackHeight / 2.0f; float thumbGap = 2.0f; float trackVerticalCenter = offset.dy + (this.size.height) / 2.0f; float trackLeft = offset.dx + _overlayRadius; float trackTop = trackVerticalCenter - trackRadius; float trackBottom = trackVerticalCenter + trackRadius; float trackRight = trackLeft + trackLength; float trackActive = trackLeft + trackLength * visualPosition; float thumbRadius = this._sliderTheme.thumbShape.getPreferredSize(this.isInteractive, this.isDiscrete).width / 2.0f; float trackActiveLeft = Mathf.Max(0.0f, trackActive - thumbRadius - thumbGap * (1.0f - this._enableAnimation.value)); float trackActiveRight = Mathf.Min(trackActive + thumbRadius + thumbGap * (1.0f - this._enableAnimation.value), trackRight); Rect trackLeftRect = Rect.fromLTRB(trackLeft, trackTop, trackActiveLeft, trackBottom); Rect trackRightRect = Rect.fromLTRB(trackActiveRight, trackTop, trackRight, trackBottom); Offset thumbCenter = new Offset(trackActive, trackVerticalCenter); if (visualPosition > 0.0) { canvas.drawRect(trackLeftRect, leftTrackPaint); } if (visualPosition < 1.0) { canvas.drawRect(trackRightRect, rightTrackPaint); } this._paintOverlay(canvas, thumbCenter); this._paintTickMarks( canvas, trackLeftRect, trackRightRect, leftTickMarkPaint, rightTickMarkPaint ); if (this.isInteractive && this.label != null && this._valueIndicatorAnimation.status != AnimationStatus.dismissed) { if (this.showValueIndicator) { this._sliderTheme.valueIndicatorShape.paint( context, thumbCenter, activationAnimation: this._valueIndicatorAnimation, enableAnimation: this._enableAnimation, isDiscrete: this.isDiscrete, labelPainter: this._labelPainter, parentBox: this, sliderTheme: this._sliderTheme, value: this._value ); } } this._sliderTheme.thumbShape.paint( context, thumbCenter, activationAnimation: this._valueIndicatorAnimation, enableAnimation: this._enableAnimation, isDiscrete: this.isDiscrete, labelPainter: this._labelPainter, parentBox: this, sliderTheme: this._sliderTheme, value: this._value ); }
private void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB) { if (((this.canvasRenderer != null) && (useRGB || useAlpha)) && !this.canvasRenderer.GetColor().Equals(targetColor)) { ColorTween.ColorTweenMode mode = (!useRGB || !useAlpha) ? (!useRGB ? ColorTween.ColorTweenMode.Alpha : ColorTween.ColorTweenMode.RGB) : ColorTween.ColorTweenMode.All; ColorTween info = new ColorTween { duration = duration, startColor = this.canvasRenderer.GetColor(), targetColor = targetColor }; info.AddOnChangedCallback(new UnityAction<Color>(this.canvasRenderer.SetColor)); info.ignoreTimeScale = ignoreTimeScale; info.tweenMode = mode; this.m_ColorTweenRunner.StartTween(info); } }
/// <summary> /// Starts a color tween. /// </summary> /// <param name="targetColor">Target color.</param> /// <param name="duration">Duration.</param> private void StartColorTweenText(Color targetColor, float duration) { if (this.m_TextTarget == null) return; if (!Application.isPlaying || duration == 0f) { this.m_TextTarget.color = targetColor; } else { var colorTween = new ColorTween { duration = duration, startColor = this.m_TextTarget.color, targetColor = targetColor }; colorTween.AddOnChangedCallback(SetTextColor); colorTween.ignoreTimeScale = true; this.m_ColorTweenRunner.StartTween(colorTween); } }
private void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB) { if (canvasRenderer == null || (!useRGB && !useAlpha)) return; Color currentColor = canvasRenderer.GetColor(); if (currentColor.Equals(targetColor)) return; ColorTween.ColorTweenMode mode = (useRGB && useAlpha ? ColorTween.ColorTweenMode.All : (useRGB ? ColorTween.ColorTweenMode.RGB : ColorTween.ColorTweenMode.Alpha)); var colorTween = new ColorTween {duration = duration, startColor = canvasRenderer.GetColor(), targetColor = targetColor}; colorTween.AddOnChangedCallback(canvasRenderer.SetColor); colorTween.ignoreTimeScale = ignoreTimeScale; colorTween.tweenMode = mode; m_ColorTweenRunner.StartTween(colorTween); }
List <Widget> _createTiles() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); D.assert(localizations != null); List <Widget> children = new List <Widget> { }; switch (this.widget.type) { case BottomNavigationBarType.fix: ThemeData themeData = Theme.of(this.context); TextTheme textTheme = themeData.textTheme; Color themeColor; switch (themeData.brightness) { case Brightness.light: themeColor = themeData.primaryColor; break; case Brightness.dark: themeColor = themeData.accentColor; break; default: throw new Exception("Unknown brightness: " + themeData.brightness); } ColorTween colorTween = new ColorTween( begin: textTheme.caption.color, end: this.widget.fixedColor ?? themeColor ); for (int i = 0; i < this.widget.items.Count; i += 1) { int index = i; children.Add( new _BottomNavigationTile(this.widget.type, this.widget.items[i], this._animations[i], this.widget.iconSize, onTap: () => { if (this.widget.onTap != null) { this.widget.onTap(index); } }, colorTween: colorTween, selected: i == this.widget.currentIndex, indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: this.widget.items.Count) ) ); } break; case BottomNavigationBarType.shifting: for (int i = 0; i < this.widget.items.Count; i += 1) { int index = i; children.Add( new _BottomNavigationTile(this.widget.type, this.widget.items[i], this._animations[i], this.widget.iconSize, onTap: () => { if (this.widget.onTap != null) { this.widget.onTap(index); } }, flex: this._evaluateFlex(this._animations[i]), selected: i == this.widget.currentIndex, indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: this.widget.items.Count) ) ); } break; } return(children); }
public BaseTween ColorTween(Color from, Color to, float t) { ColorTween tween = TweenPool.GetColorTween(from, to, t); return(ProcessTween(tween)); }
private void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB) { if ((UnityEngine.Object) this.canvasRenderer == (UnityEngine.Object) null || !useRGB && !useAlpha || this.canvasRenderer.GetColor().Equals((object) targetColor)) return; ColorTween.ColorTweenMode colorTweenMode = !useRGB || !useAlpha ? (!useRGB ? ColorTween.ColorTweenMode.Alpha : ColorTween.ColorTweenMode.RGB) : ColorTween.ColorTweenMode.All; ColorTween info = new ColorTween() { duration = duration, startColor = this.canvasRenderer.GetColor(), targetColor = targetColor }; info.AddOnChangedCallback(new UnityAction<Color>(this.canvasRenderer.SetColor)); info.ignoreTimeScale = ignoreTimeScale; info.tweenMode = colorTweenMode; this.m_ColorTweenRunner.StartTween(info); }