mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-08-06 16:40:27 +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';
|
export 'package:rive/src/generated/artboard_base.dart';
|
||||||
|
|
||||||
class Artboard extends ArtboardBase with ShapePaintContainer {
|
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.
|
/// Artboard are one of the few (only?) components that can be orphaned.
|
||||||
@override
|
@override
|
||||||
bool get canBeOrphaned => true;
|
bool get canBeOrphaned => true;
|
||||||
|
@ -152,6 +152,7 @@ class LinearGradient extends LinearGradientBase with ShapePaintMutator {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void syncColor() {
|
void syncColor() {
|
||||||
|
super.syncColor();
|
||||||
paint.color = const ui.Color(0xFFFFFFFF)
|
paint.color = const ui.Color(0xFFFFFFFF)
|
||||||
.withOpacity((opacity * renderOpacity).clamp(0, 1).toDouble());
|
.withOpacity((opacity * renderOpacity).clamp(0, 1).toDouble());
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rive/src/rive_core/artboard.dart';
|
||||||
import 'package:rive/src/rive_core/shapes/shape_paint_container.dart';
|
import 'package:rive/src/rive_core/shapes/shape_paint_container.dart';
|
||||||
|
|
||||||
abstract class ShapePaintMutator {
|
abstract class ShapePaintMutator {
|
||||||
ShapePaintContainer? _shapePaintContainer;
|
ShapePaintContainer? _shapePaintContainer;
|
||||||
Paint _paint = Paint();
|
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 container is usually either a Shape or an Artboard, basically any of
|
||||||
/// the various ContainerComponents that can contain Fills or Strokes.
|
/// the various ContainerComponents that can contain Fills or Strokes.
|
||||||
ShapePaintContainer? get shapePaintContainer => _shapePaintContainer;
|
ShapePaintContainer? get shapePaintContainer => _shapePaintContainer;
|
||||||
@ -22,7 +26,8 @@ abstract class ShapePaintMutator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void syncColor();
|
@mustCallSuper
|
||||||
|
void syncColor() => _paint.isAntiAlias = artboard?.antialiasing ?? true;
|
||||||
|
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
void initializePaintMutator(ShapePaintContainer container, Paint paint) {
|
void initializePaintMutator(ShapePaintContainer container, Paint paint) {
|
||||||
|
@ -35,6 +35,7 @@ class SolidColor extends SolidColorBase with ShapePaintMutator {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void syncColor() {
|
void syncColor() {
|
||||||
|
super.syncColor();
|
||||||
paint.color = color
|
paint.color = color
|
||||||
.withOpacity((color.opacity * renderOpacity).clamp(0, 1).toDouble());
|
.withOpacity((color.opacity * renderOpacity).clamp(0, 1).toDouble());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user