toColorWithOpacity method

Color toColorWithOpacity(
  1. double opacity
)

Converts this Ray to a Flutter Color with specific opacity.

final ray = RayRgb8.fromHex('#FF0000');
final transparent = ray.toColorWithOpacity(0.5);

Implementation

Color toColorWithOpacity(double opacity) {
  final rgb = toRgb8();
  return Color.fromARGB(
    (opacity.clamp(0.0, 1.0) * 255).round(),
    rgb.red.round(),
    rgb.green.round(),
    rgb.blue.round(),
  );
}