浏览代码

fix nine patch image.

/main
kg 6 年前
当前提交
6ef46645
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 12
      Runtime/ui/painting/canvas_impl.cs

12
Runtime/ui/painting/canvas_impl.cs


var state = this._getState();
var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src, center, dst);
var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src, center, image.width, image.height, dst);
if (!this._applyClip(mesh.bounds)) {
return;

return new MeshMesh(matrix, vertices, _imageTriangles, uv);
}
public static MeshMesh imageNineMesh(Matrix3 matrix, Rect src, Rect center, Rect dst) {
public static MeshMesh imageNineMesh(Matrix3 matrix, Rect src, Rect center, int srcWidth, int srcHeight, Rect dst) {
float x1 = x0 + (float) ((center.left - src.left) * dst.width);
float x2 = x3 - (float) ((src.right - center.right) * dst.width);
float x1 = x0 + (float) ((center.left - src.left) * srcWidth);
float x2 = x3 - (float) ((src.right - center.right) * srcHeight);
float y1 = y0 + (float) ((center.top - src.top) * dst.height);
float y2 = y3 - (float) ((src.bottom - center.bottom) * dst.height);
float y1 = y0 + (float) ((center.top - src.top) * srcWidth);
float y2 = y3 - (float) ((src.bottom - center.bottom) * srcHeight);
float tx0 = (float) src.left;
float tx1 = (float) center.left;

正在加载...
取消
保存