浏览代码

fix bug

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
cac18bcd
共有 3 个文件被更改,包括 120 次插入6 次删除
  1. 71
      com.unity.uiwidgets/Runtime/painting/alignment.cs
  2. 54
      com.unity.uiwidgets/Runtime/painting/gradient.cs
  3. 1
      com.unity.uiwidgets/Runtime/painting/image_provider.cs

71
com.unity.uiwidgets/Runtime/painting/alignment.cs


using System;
using Unity.UIWidgets.foundation;
public abstract class AlignmentGeometry {
public AlignmentGeometry() {
}
float _x { get; }
float _start { get; }
float _y { get; }
// public static AlignmentGeometry add(AlignmentGeometry other) {
// return new _MixedAlignment(
// _x + other._x,
// _start + other._start,
// _y + other._y,
// );
// }
// public abstract AlignmentGeometry operator -();
//
// public abstract AlignmentGeometry operator *(double other);
//
// public abstract AlignmentGeometry operator /(double other);
//
// public abstract AlignmentGeometry operator ~/(double other);
//
// public abstract AlignmentGeometry operator %(double other);
// static AlignmentGeometry lerp(AlignmentGeometry a, AlignmentGeometry b, float t) {
// D.assert(t != null);
// if (a == null && b == null)
// return null;
// if (a == null)
// return b * t;
// if (b == null)
// return a * (1.0 - t);
// if (a is Alignment && b is Alignment)
// return Alignment.lerp(a, b, t);
// if (a is AlignmentDirectional && b is AlignmentDirectional)
// return AlignmentDirectional.lerp(a, b, t);
// return _MixedAlignment(
// ui.lerpDouble(a._x, b._x, t),
// ui.lerpDouble(a._start, b._start, t),
// ui.lerpDouble(a._y, b._y, t),
// );
// }
//
public abstract Alignment resolve(TextDirection? direction);
//
// @override
// String toString() {
// if (_start == 0.0)
// return Alignment._stringify(_x, _y);
// if (_x == 0.0)
// return AlignmentDirectional._stringify(_start, _y);
// return Alignment._stringify(_x, _y) + ' + ' + AlignmentDirectional._stringify(_start, 0.0);
// }
//
// @override
// bool operator ==(Object other) {
// return other is AlignmentGeometry
// && other._x == _x
// && other._start == _start
// && other._y == _y;
// }
//
// @override
// int get hashCode => hashValues(_x, _start, _y);
}
public class Alignment : IEquatable<Alignment> {
public Alignment(float x, float y) {
this.x = x;

54
com.unity.uiwidgets/Runtime/painting/gradient.cs


}
}
public abstract class GradientTransform {
public GradientTransform() {
}
public abstract Matrix4 transform(Rect bounds, TextDirection? textDirection = null);
}
public class GradientRotation : GradientTransform {
public GradientRotation(float radians) {
this.radians = radians;
}
public readonly float radians;
public override
Matrix4 transform(Rect bounds,
TextDirection? textDirection = null
) {
D.assert(bounds != null);
float sinRadians = Mathf.Sin(radians);
float oneMinusCosRadians = 1 - Mathf.Cos(radians);
Offset center = bounds.center;
float originX = sinRadians * center.dy + oneMinusCosRadians * center.dx;
float originY = -sinRadians * center.dx + oneMinusCosRadians * center.dy;
var result = new Matrix4().identity();
result.translate(originX, originY);
result.rotateZ(radians);
return result;
}
}
public abstract class Gradient {
public Gradient(

public readonly List<Color> colors;
public readonly List<float> stops;
public readonly GradientTransform transform;
protected List<float> _impliedStops() {
if (stops != null) {

D.assert(a != null && b != null);
return t < 0.5 ? a.scale(1.0f - (t * 2.0f)) : b.scale((t - 0.5f) * 2.0f);
}
protected float[] _resolveTransform(Rect bounds, TextDirection? textDirection) {
return transform?.transform(bounds, textDirection: textDirection)?._m4storage;
}
}

begin.withinRect(rect),
end.withinRect(rect),
colors, _impliedStops(),
tileMode
tileMode, _resolveTransform(rect, textDirection)
public override Gradient scale(float factor) {
return new LinearGradient(
begin: begin,

public readonly TileMode tileMode;
public readonly AlignmentGeometry focal;
public override Shader createShader(Rect rect, TextDirection? textDirection = null) {
public readonly float focalRadius;
public override Shader createShader(Rect rect, TextDirection? textDirection = null) {
tileMode
tileMode,
_resolveTransform(rect, textDirection),
focal == null ? null : focal.resolve(textDirection).withinRect(rect),
focalRadius * rect.shortestSide
);
}

public readonly TileMode tileMode;
public override Shader createShader(Rect rect, TextDirection? textDirection = null) {
public override Shader createShader(Rect rect, TextDirection? textDirection = null) {
startAngle, endAngle
startAngle, endAngle, _resolveTransform(rect, textDirection)
);
}

1
com.unity.uiwidgets/Runtime/painting/image_provider.cs


obtainedKey = key;
// TODO : how to load
// stream.setCompleter(PaintingBinding.instance.imageCache.putIfAbsent(key, () => load(key)));
D.assert(false, () => "load image from ImageStream is not implemented yet");
}).catchError(ex => {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: ex,

正在加载...
取消
保存