mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-08-06 00:21:17 +08:00
Merge pull request #120 from rive-app/antialias_toggle
Add underlying support for antialiasing options
This commit is contained in:
@ -21,6 +21,9 @@ import 'package:rive/src/generated/artboard_base.dart';
|
||||
export 'package:rive/src/generated/artboard_base.dart';
|
||||
|
||||
class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
/// Should antialiasing be used when drawing?
|
||||
bool antialiasing = true;
|
||||
|
||||
/// Artboard are one of the few (only?) components that can be orphaned.
|
||||
@override
|
||||
bool get canBeOrphaned => true;
|
||||
|
@ -152,6 +152,7 @@ class LinearGradient extends LinearGradientBase with ShapePaintMutator {
|
||||
|
||||
@override
|
||||
void syncColor() {
|
||||
super.syncColor();
|
||||
paint.color = const ui.Color(0xFFFFFFFF)
|
||||
.withOpacity((opacity * renderOpacity).clamp(0, 1).toDouble());
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rive/src/rive_core/artboard.dart';
|
||||
import 'package:rive/src/rive_core/shapes/shape_paint_container.dart';
|
||||
|
||||
abstract class ShapePaintMutator {
|
||||
ShapePaintContainer? _shapePaintContainer;
|
||||
Paint _paint = Paint();
|
||||
|
||||
/// Getter for the component's artboard
|
||||
Artboard? get artboard;
|
||||
|
||||
/// The container is usually either a Shape or an Artboard, basically any of
|
||||
/// the various ContainerComponents that can contain Fills or Strokes.
|
||||
ShapePaintContainer? get shapePaintContainer => _shapePaintContainer;
|
||||
@ -22,7 +26,8 @@ abstract class ShapePaintMutator {
|
||||
}
|
||||
|
||||
@protected
|
||||
void syncColor();
|
||||
@mustCallSuper
|
||||
void syncColor() => _paint.isAntiAlias = artboard?.antialiasing ?? true;
|
||||
|
||||
@mustCallSuper
|
||||
void initializePaintMutator(ShapePaintContainer container, Paint paint) {
|
||||
|
@ -35,6 +35,7 @@ class SolidColor extends SolidColorBase with ShapePaintMutator {
|
||||
|
||||
@override
|
||||
void syncColor() {
|
||||
super.syncColor();
|
||||
paint.color = color
|
||||
.withOpacity((color.opacity * renderOpacity).clamp(0, 1).toDouble());
|
||||
}
|
||||
|
Reference in New Issue
Block a user