浏览代码

update image

/main
gewentao 6 年前
当前提交
418ed172
共有 6 个文件被更改,包括 2 次插入165 次删除
  1. 75
      Assets/UIWidgets/painting/alignment.cs
  2. 39
      Assets/UIWidgets/painting/box_fit.cs
  3. 1
      Assets/UIWidgets/painting/image_provider.cs
  4. 4
      Assets/UIWidgets/ui/painting/image.cs
  5. 44
      Assets/UIWidgets/ui/painting/painting.cs
  6. 4
      Assets/UIWidgets/ui/painting/picture.cs

75
Assets/UIWidgets/painting/alignment.cs


public static readonly Alignment bottomCenter = new Alignment(0.0, 1.0);
public static readonly Alignment bottomRight = new Alignment(1.0, 1.0);
// todo more operators
public Alignment resolve(TextDirection direction)
{
return this;

public static bool operator !=(Alignment a, Alignment b)
{
return !(a == b);
}
}
public class _MixedAlignment : IEquatable<_MixedAlignment>
{
public _MixedAlignment(double x, double start, double y)
{
this.x = x;
this.start = start;
this.y = y;
}
private readonly double x;
private readonly double start;
private readonly double y;
public static _MixedAlignment operator -(_MixedAlignment a)
{
return new _MixedAlignment(
-a.x,
-a.start,
-a.y
);
}
public static _MixedAlignment operator *(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a.x * other,
a.start * other,
a.y * other
);
}
public static _MixedAlignment operator /(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a.x / other,
a.start / other,
a.y / other
);
}
public static _MixedAlignment operator %(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a.x % other,
a.start % other,
a.y % other
);
}
public Alignment resolve(TextDirection direction)
{
switch (direction)
{
case TextDirection.rtl:
return new Alignment(x - start, y);
case TextDirection.ltr:
return new Alignment(x + start, y);
}
return null;
}
public bool Equals(_MixedAlignment other)
{
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return this.x.Equals(other.x) && this.y.Equals(other.y) && this.start.Equals(other.start);
}
}
}

39
Assets/UIWidgets/painting/box_fit.cs


{
public enum BoxFit
{
/// Fill the target box by distorting the source's aspect ratio.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_fill.png)
/// As large as possible while still containing the source entirely within the
/// target box.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_contain.png)
/// As small as possible while still covering the entire target box.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_cover.png)
/// Make sure the full width of the source is shown, regardless of
/// whether this means the source overflows the target box vertically.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_fitWidth.png)
/// Make sure the full height of the source is shown, regardless of
/// whether this means the source overflows the target box horizontally.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_fitHeight.png)
/// Align the source within the target box (by default, centering) and discard
/// any portions of the source that lie outside the box.
///
/// The source image is not resized.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_none.png)
/// Align the source within the target box (by default, centering) and, if
/// necessary, scale the source down to ensure that the source fits within the
/// box.
///
/// This is the same as `contain` if that would shrink the image, otherwise it
/// is the same as `none`.
///
/// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_scaleDown.png)
scaleDown,
}

{
//todo wrong
this.source = source;
this.destination = destination;
}

1
Assets/UIWidgets/painting/image_provider.cs


public override NetworkImage obtainKey(ImageConfiguration configuration)
{
// return new SynchronousFuture<NetworkImage> (this);
return this;
}

4
Assets/UIWidgets/ui/painting/image.cs


this.width = width;
}
public byte[] rawData; // todo temp hack
public int height; //有别的用吗
public byte[] rawData;
public int height;
public int width;
}
}

44
Assets/UIWidgets/ui/painting/painting.cs


};
}
}
// public class GUICanvas : Canvas {
// static GUICanvas() {
// GUICanvas.shadowMat = Resources.Load<Material>("UIWidgets_ShadowMat");
// if (GUICanvas.shadowMat == null) {
// throw new Exception("UIWidgets_ShadowShader not found");
// }
// }
//
// public static readonly Material shadowMat;
//
// public override void drawPloygon4(Paint paint, params Offset[] points) {
// Vector3[] vectors = new Vector3 [points.Length];
// for (int i = 0; i < points.Length; i++) {
// vectors[i] = points[i].toVector();
// }
//
// Handles.DrawSolidRectangleWithOutline(vectors, paint.color.toColor(),
// new UnityEngine.Color(0f, 0f, 0f, 0f));
// }
//
// public override void drawRect(Paint paint, Rect rect, BorderWidth borderWidth, BorderRadius borderRadius) {
// GUI.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill, true, 0,
// paint.color.toColor(), borderWidth.toVector(), borderRadius.toVector());
// }
//
// public override void drawRectShadow(Paint paint, Rect rect) {
// GUICanvas.shadowMat.SetFloatArray("_Rect", new float[] {
// (float) rect.left, (float) rect.top, (float) rect.width, (float) rect.height,
// });
// GUICanvas.shadowMat.SetFloat("_sigma", (float) paint.blurSigma);
//
// Graphics.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture,
// new UnityEngine.Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0, paint.color.toColor(), GUICanvas.shadowMat);
// }
// }
public class ColorFilter
{

Color _color;
BlendMode _blendMode;
// public static bool operator ==(ColorFilter a, dynamic other) {
// if (other is! ColorFilter)
// return false;
// ColorFilter typedOther = other;
// return a._color == typedOther._color &&
// a._blendMode == typedOther._blendMode;
// }
}
public enum BlendMode

4
Assets/UIWidgets/ui/painting/picture.cs


} else if (drawCmd is DrawPicture) {
var drawPicture = (DrawPicture) drawCmd;
this.addPaintBounds(drawPicture.picture.paintBounds);
} else if (drawCmd is DrawImageRect)
{
var drawImageRect = (DrawImageRect) drawCmd;
// todo
} else if (drawCmd is DrawConcat) {
this._transform = ((DrawConcat) drawCmd).transform * this._transform;
} else if (drawCmd is DrawSave) {

正在加载...
取消
保存