Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update cicd.yml file on flame_3d to match main, rollback color changes #3378

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ on:
pull_request:
types: [opened, reopened, synchronize]


env:
FLUTTER_MIN_VERSION: '3.24.0'

jobs:
# BEGIN LINTING STAGE
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: main
- uses: bluefireteam/melos-action@v3
- run: melos run format-check

Expand All @@ -25,7 +27,18 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: main
flutter-version: ${{env.FLUTTER_MIN_VERSION}}
- uses: bluefireteam/melos-action@v3
- name: "Analyze with lowest supported version"
uses: invertase/github-action-dart-analyzer@v3
with:
fatal-infos: true

analyze-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@v3
- name: "Analyze with latest stable"
uses: invertase/github-action-dart-analyzer@v3
Expand All @@ -47,8 +60,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: main
- uses: bluefireteam/melos-action@v3
- name: Install DCM
uses: CQLabs/setup-dcm@v1
Expand All @@ -66,7 +77,6 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: main
cache: true
- uses: bluefireteam/melos-action@v3
- name: Run tests
Expand Down
6 changes: 3 additions & 3 deletions doc/flame/examples/lib/drag_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Trail extends Component {
final path = _paths[i];
final opacity = _opacities[i];
if (opacity > 0) {
_linePaint.color = _color.withValues(alpha: opacity);
_linePaint.color = _color.withOpacity(opacity);
_linePaint.strokeWidth = lineWidth * opacity;
canvas.drawPath(path, _linePaint);
}
Expand Down Expand Up @@ -216,11 +216,11 @@ class Star extends PositionComponent with DragCallbacks {
@override
void render(Canvas canvas) {
if (isDragged) {
_paint.color = color.withValues(alpha: 0.5);
_paint.color = color.withOpacity(0.5);
canvas.drawPath(_path, _paint);
canvas.drawPath(_path, _borderPaint);
} else {
_paint.color = color.withValues(alpha: 1);
_paint.color = color.withOpacity(1);
canvas.drawPath(_path, _shadowPaint);
canvas.drawPath(_path, _paint);
}
Expand Down
6 changes: 3 additions & 3 deletions doc/flame/examples/lib/pointer_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HoverTarget extends PositionComponent with HoverCallbacks {
final _paint = Paint()
..color = HSLColor.fromAHSL(1, _random.nextDouble() * 360, 1, 0.8)
.toColor()
.withValues(alpha: 0.5);
.withOpacity(0.5);

@override
void render(Canvas canvas) {
Expand All @@ -41,11 +41,11 @@ class HoverTarget extends PositionComponent with HoverCallbacks {

@override
void onHoverEnter() {
_paint.color = _paint.color.withValues(alpha: 1);
_paint.color = _paint.color.withOpacity(1);
}

@override
void onHoverExit() {
_paint.color = _paint.color.withValues(alpha: 0.5);
_paint.color = _paint.color.withOpacity(0.5);
}
}
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/ray_cast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RayCastExample extends FlameGame with HasCollisionDetection {
final velocity = 60;
double get resetPosition => -canvasSize.y;

Paint paint = BasicPalette.red.withOpacity(0.6).paint();
Paint paint = Paint()..color = Colors.red.withOpacity(0.6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Paint paint = Paint()..color = Colors.red.withOpacity(0.6);
final Paint paint = Paint()..color = Colors.red.withOpacity(0.6);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copied as is from main - you can fix on a separate PR!


RaycastResult<ShapeHitbox>? result;

Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/ray_trace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter/material.dart';

class RayTraceExample extends FlameGame
with HasCollisionDetection, TapDetector {
Paint paint = BasicPalette.red.withOpacity(0.6).paint();
Paint paint = Paint()..color = Colors.red.withOpacity(0.6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Paint paint = Paint()..color = Colors.red.withOpacity(0.6);
final Paint paint = Paint()..color = Colors.red.withOpacity(0.6);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copied as is from main - you can fix on a separate PR!

bool isClicked = false;

Vector2 get origin => canvasSize / 2;
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/tap_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ExpandingCircle extends Component {
removeFromParent();
} else {
final opacity = 1 - radius / maxRadius;
_paint.color = _baseColor.withValues(alpha: opacity);
_paint.color = _baseColor.withOpacity(opacity);
_paint.strokeWidth = _outerRadius - _innerRadius;
}
}
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/rendering/particles.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ game.add(
ParticleSystemComponent(
particle: CircleParticle(
radius: game.size.x / 2,
paint: Paint()..color = Colors.red.withValues(alpha: .5),
paint: Paint()..color = Colors.red.withOpacity(.5),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion examples/games/padracing/lib/lap_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LapLine extends BodyComponent with ContactCallbacks {
@override
Body createBody() {
paint.color = (isFinish ? GameColors.green.color : GameColors.green.color)
..withValues(alpha: 0.5);
..withOpacity(0.5);
paint
..style = PaintingStyle.fill
..shader = Gradient.radial(
Expand Down
2 changes: 1 addition & 1 deletion examples/games/padracing/lib/trail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Trail extends Component with HasPaint {
@override
Future<void> onLoad() async {
paint
..color = (tire.paint.color.withValues(alpha: 0.9))
..color = (tire.paint.color.withOpacity(0.9))
..strokeWidth = 1.0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class ExpandingCircle extends CircleComponent {
removeFromParent();
} else {
final opacity = 1 - radius / maxRadius;
paint.color = const Color(0xffffffff).withValues(alpha: opacity);
paint.color = const Color(0xffffffff).withOpacity(opacity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class TextButton extends ButtonComponent {
),
buttonDown: RectangleComponent(
size: Vector2(200, 100),
paint: BasicPalette.orange.withOpacity(0.5).paint(),
paint: Paint()..color = BasicPalette.orange.color.withOpacity(0.5),
),
children: [
TextComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ abstract class MyCollidable extends PositionComponent
final Vector2 velocity;
final delta = Vector2.zero();
double angleDelta = 0;
final Color _defaultColor = Colors.blue.withValues(alpha: 0.8);
final Color _collisionColor = Colors.green.withValues(alpha: 0.8);
final Color _defaultColor = Colors.blue.withOpacity(0.8);
final Color _collisionColor = Colors.green.withOpacity(0.8);
late final Paint _dragIndicatorPaint;
final ScreenHitbox screenHitbox;
ShapeHitbox? hitbox;
Expand Down Expand Up @@ -219,7 +219,7 @@ class CollidableCircle extends MyCollidable {
class SnowmanPart extends CircleHitbox {
@override
final renderShape = true;
final startColor = Colors.white.withValues(alpha: 0.8);
final startColor = Colors.white.withOpacity(0.8);
final Color hitColor;

SnowmanPart(double radius, Vector2 position, this.hitColor)
Expand All @@ -234,7 +234,7 @@ class SnowmanPart extends CircleHitbox {
if (other.hitboxParent is ScreenHitbox) {
paint.color = startColor;
} else {
paint.color = hitColor.withValues(alpha: 0.8);
paint.color = hitColor.withOpacity(0.8);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ around trying not to hit them.
Ray2? ray;
Ray2? reflection;
Vector2 origin = Vector2(250, 100);
Paint paint = Paint()..color = Colors.amber.withValues(alpha: 0.6);
Paint paint = Paint()..color = Colors.amber.withOpacity(0.6);
final speed = 100;
final inertia = 3.0;
final safetyDistance = 50;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ with with mouse.
Paint tapPaint = Paint();

final _colorTween = ColorTween(
begin: Colors.blue.withValues(alpha: 0.2),
end: Colors.red.withValues(alpha: 0.2),
begin: Colors.blue.withOpacity(0.2),
end: Colors.red.withOpacity(0.2),
);

static const numberOfRays = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ bounce on will appear.
''';

final _colorTween = ColorTween(
begin: Colors.amber.withValues(alpha: 1.0),
end: Colors.lightBlueAccent.withValues(alpha: 1.0),
begin: Colors.amber.withOpacity(1.0),
end: Colors.lightBlueAccent.withOpacity(1.0),
);
final random = Random();
Ray2? ray;
Expand Down
4 changes: 2 additions & 2 deletions examples/lib/stories/components/keys_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ class SelectableClass extends SpriteComponent {
super.size,
super.key,
super.sprite,
}) : super(paint: Paint()..color = Colors.white.withValues(alpha: 0.5));
}) : super(paint: Paint()..color = Colors.white.withOpacity(0.5));

bool _selected = false;
bool get selected => _selected;
set selected(bool value) {
_selected = value;
paint = Paint()
..color = value ? Colors.white : Colors.white.withValues(alpha: 0.5);
..color = value ? Colors.white : Colors.white.withOpacity(0.5);
}
}
2 changes: 1 addition & 1 deletion examples/lib/stories/effects/opacity_effect_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OpacityEffectExample extends FlameGame with TapDetector {

@override
void onTap() {
final opacity = sprite.paint.color.a;
final opacity = sprite.paint.color.opacity;
if (opacity >= 0.5) {
sprite.add(OpacityEffect.fadeOut(EffectController(duration: 1)));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TapCallbacksSquare extends RectangleComponent with TapCallbacks {
position: position ?? Vector2.all(100),
size: Vector2.all(100),
paint: continuePropagation
? (Paint()..color = Colors.green.withValues(alpha: 0.9))
? (Paint()..color = Colors.green.withOpacity(0.9))
: PaintExtension.random(withAlpha: 0.9, base: 100),
);

Expand Down
4 changes: 1 addition & 3 deletions examples/lib/stories/rendering/particles_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,7 @@ class ParticlesExample extends FlameGame {
renderer: (canvas, particle) {
final paint = randomElement(paints);
// Override the color to dynamically update opacity
paint.color = paint.color.withValues(
alpha: 1 - particle.progress,
);
paint.color = paint.color.withOpacity(1 - particle.progress);

canvas.drawCircle(
Offset.zero,
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/stories/system/resize_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ResizingRectangle extends RectangleComponent {
void onGameResize(Vector2 size) {
super.onGameResize(size);

this.size = size * 0.4;
this.size = size * .4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.size = size * .4;
this.size = size * 0.4;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copied as is from main - you can fix on a separate PR!

}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/flame/lib/src/cache/images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class Images {
/// Whether the cache contains the specified [key] or not.
bool containsKey(String key) => _assets.containsKey(key);

/// Returns the list of keys in the cache.
List<String> get keys => _assets.keys.toList();

String? findKeyForImage(Image image) {
return _assets.keys.firstWhere(
(k) => _assets[k]?.image?.isCloneOf(image) ?? false,
Expand Down
24 changes: 13 additions & 11 deletions packages/flame/lib/src/components/mixins/has_paint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,12 @@ mixin HasPaint<T extends Object> on Component
throw ArgumentError('Opacity needs to be between 0 and 1');
}

setColor(
getPaint(paintId).color.withValues(alpha: opacity),
paintId: paintId,
);
setColor(getPaint(paintId).color.withOpacity(opacity), paintId: paintId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was easier to read with the trailing comma

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copied as is from main - you can fix on a separate PR!

}

/// Returns the current opacity.
double getOpacity({T? paintId}) {
return getPaint(paintId).color.a;
return getPaint(paintId).color.opacity;
}

/// Changes the opacity of the paint.
Expand All @@ -103,6 +100,11 @@ mixin HasPaint<T extends Object> on Component
setColor(getPaint(paintId).color.withAlpha(alpha), paintId: paintId);
}

/// Returns the current opacity.
int getAlpha({T? paintId}) {
return getPaint(paintId).color.alpha;
}

/// Shortcut for changing the color of the paint.
void setColor(Color color, {T? paintId}) {
getPaint(paintId).color = color;
Expand All @@ -116,13 +118,13 @@ mixin HasPaint<T extends Object> on Component
}

@override
double get opacity => paint.color.a;
double get opacity => paint.color.opacity;

@override
set opacity(double value) {
paint.color = paint.color.withValues(alpha: value);
paint.color = paint.color.withOpacity(value);
for (final paint in _paints.values) {
paint.color = paint.color.withValues(alpha: value);
paint.color = paint.color.withOpacity(value);
}
}

Expand Down Expand Up @@ -184,7 +186,7 @@ class _MultiPaintOpacityProvider<T extends Object> implements OpacityProvider {
];
_layerOpacityRatios = target.paintLayersInternal
?.map(
(paint) => paint.color.a / maxOpacity,
(paint) => paint.color.opacity / maxOpacity,
)
.toList(growable: false);
}
Expand All @@ -204,7 +206,7 @@ class _MultiPaintOpacityProvider<T extends Object> implements OpacityProvider {
}
if (includeLayers) {
target.paintLayersInternal?.forEach(
(paint) => maxOpacity = max(paint.color.a, maxOpacity),
(paint) => maxOpacity = max(paint.color.opacity, maxOpacity),
);
}

Expand All @@ -224,7 +226,7 @@ class _MultiPaintOpacityProvider<T extends Object> implements OpacityProvider {
for (var i = 0; i < (paintLayersInternal?.length ?? 0); ++i) {
paintLayersInternal![i].color = paintLayersInternal[i]
.color
.withValues(alpha: value * _layerOpacityRatios![i]);
.withOpacity(value * _layerOpacityRatios![i]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/flame/lib/src/effects/color_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class ColorEffect extends ComponentEffect<HasPaint> {

@override
void apply(double progress) {
final currentColor = color.withValues(
alpha: min(max(_tween.transform(progress), 0), 1),
final currentColor = color.withOpacity(
min(max(_tween.transform(progress), 0), 1),
);
target.tint(currentColor, paintId: paintId);
}
Expand Down
Loading
Loading