Add operators to Radius (flutter/engine#4117)
This will make it easier to implement BorderRadius RTL in a manner consistent with EdgeInsets.
This commit is contained in:
@@ -777,6 +777,58 @@ class Radius {
|
||||
/// You can use [Radius.zero] with [RRect] to have right-angle corners.
|
||||
static const Radius zero = const Radius.circular(0.0);
|
||||
|
||||
/// Unary negation operator.
|
||||
///
|
||||
/// Returns a Radius with the distances negated.
|
||||
///
|
||||
/// Radiuses with negative values aren't geometrically meaningful, but could
|
||||
/// occur as part of expressions. For example, negating a radius of one pixel
|
||||
/// and then adding the result to another radius is equivalent to subtracting
|
||||
/// a radius of one pixel from the other.
|
||||
Radius operator -() => new Radius.elliptical(-x, -y);
|
||||
|
||||
/// Binary subtraction operator.
|
||||
///
|
||||
/// Returns a radius whose [x] value is the left-hand-side operand's [x]
|
||||
/// minus the right-hand-side operand's [x] and whose [y] value is the
|
||||
/// left-hand-side operand's [y] minus the right-hand-side operand's [y].
|
||||
Radius operator -(Radius other) => new Radius.elliptical(x - other.x, y - other.y);
|
||||
|
||||
/// Binary addition operator.
|
||||
///
|
||||
/// Returns a radius whose [x] value is the sum of the [x] values of the
|
||||
/// two operands, and whose [y] value is the sum of the [y] values of the
|
||||
/// two operands.
|
||||
Radius operator +(Radius other) => new Radius.elliptical(x + other.x, y + other.y);
|
||||
|
||||
/// Multiplication operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (a radius) multiplied by the scalar
|
||||
/// right-hand-side operand (a double).
|
||||
Radius operator *(double operand) => new Radius.elliptical(x * operand, y * operand);
|
||||
|
||||
/// Division operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (a radius) divided by the scalar right-hand-side
|
||||
/// operand (a double).
|
||||
Radius operator /(double operand) => new Radius.elliptical(x / operand, y / operand);
|
||||
|
||||
/// Integer (truncating) division operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (a radius) divided by the scalar right-hand-side
|
||||
/// operand (a double), rounded towards zero.
|
||||
Radius operator ~/(double operand) => new Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble());
|
||||
|
||||
/// Modulo (remainder) operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the remainder of dividing the
|
||||
/// coordinates of the left-hand-side operand (a radius) by the scalar
|
||||
/// right-hand-side operand (a double).
|
||||
Radius operator %(double operand) => new Radius.elliptical(x % operand, y % operand);
|
||||
|
||||
/// Linearly interpolate between two radii.
|
||||
///
|
||||
/// If either is null, this function substitutes [Radius.zero] instead.
|
||||
|
||||
Reference in New Issue
Block a user