|
|
|
|
|
|
|
|
|
|
uint _pathKey = 0; |
|
|
|
|
|
|
|
bool _isRRect = false; |
|
|
|
public bool isRRect => this._isRRect; |
|
|
|
|
|
|
|
public uint pathKey { |
|
|
|
get { |
|
|
|
return this._pathKey; |
|
|
|
|
|
|
|
|
|
|
public List<float> commands => this._commands; |
|
|
|
|
|
|
|
void _updateRRectFlag(bool isRRect) { |
|
|
|
if (this._commands.Count > 0 && !this._isRRect) { |
|
|
|
return; |
|
|
|
} |
|
|
|
this._isRRect = isRRect && this._hasOnlyMoveTos(); |
|
|
|
} |
|
|
|
|
|
|
|
bool _hasOnlyMoveTos() { |
|
|
|
var i = 0; |
|
|
|
while (i < this._commands.Count) { |
|
|
|
var cmd = (PathCommand) this._commands[i]; |
|
|
|
switch (cmd) { |
|
|
|
case PathCommand.moveTo: |
|
|
|
i += 3; |
|
|
|
break; |
|
|
|
case PathCommand.lineTo: |
|
|
|
return false; |
|
|
|
case PathCommand.bezierTo: |
|
|
|
return false; |
|
|
|
case PathCommand.close: |
|
|
|
i++; |
|
|
|
break; |
|
|
|
case PathCommand.winding: |
|
|
|
i += 2; |
|
|
|
break; |
|
|
|
default: |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public override string ToString() { |
|
|
|
var sb = new StringBuilder("Path: count = " + this._commands.Count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._pathKey = pathGlobalKey++; |
|
|
|
this._cache = null; |
|
|
|
this._isRRect = false; |
|
|
|
} |
|
|
|
|
|
|
|
internal PathCache flatten(float scale) { |
|
|
|
|
|
|
public void relativeLineTo(float x, float y) { |
|
|
|
var x0 = this._commandx; |
|
|
|
var y0 = this._commandy; |
|
|
|
|
|
|
|
|
|
|
|
this._updateRRectFlag(false); |
|
|
|
this._updateRRectFlag(false); |
|
|
|
this._updateRRectFlag(false); |
|
|
|
this._appendBezierTo(c1x, c1y, c2x, c2y, x, y); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._updateRRectFlag(false); |
|
|
|
this.cubicTo(x0 + c1x, y0 + c1y, x0 + c2x, y0 + c2y, x0 + x, y0 + y); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const float twoThird = 2.0f / 3.0f; |
|
|
|
this._updateRRectFlag(false); |
|
|
|
this._appendBezierTo( |
|
|
|
x0 + twoThird * (cx - x0), y0 + twoThird * (cy - y0), |
|
|
|
x + twoThird * (cx - x), y + twoThird * (cy - y), |
|
|
|
|
|
|
var x0 = this._commandx; |
|
|
|
var y0 = this._commandy; |
|
|
|
|
|
|
|
this._updateRRectFlag(false); |
|
|
|
this._updateRRectFlag(false); |
|
|
|
if (!(w > 0)) { |
|
|
|
this.lineTo(x2, y2); |
|
|
|
return; |
|
|
|
|
|
|
public void relativeConicTo(float x1, float y1, float x2, float y2, float w) { |
|
|
|
var x0 = this._commandx; |
|
|
|
var y0 = this._commandy; |
|
|
|
|
|
|
|
this._updateRRectFlag(false); |
|
|
|
this.conicTo(x0 + x1, y0 + y1, x0 + x2, y0 + y2, w); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
bool largeArc = false, |
|
|
|
bool clockwise = false) { |
|
|
|
radius = radius ?? Radius.zero; |
|
|
|
|
|
|
|
this._updateRRectFlag(false); |
|
|
|
D.assert(PaintingUtils._offsetIsValid(arcEnd)); |
|
|
|
D.assert(PaintingUtils._radiusIsValid(radius)); |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void addRect(Rect rect) { |
|
|
|
this._updateRRectFlag(true); |
|
|
|
this._appendMoveTo(rect.left, rect.top); |
|
|
|
this._appendLineTo(rect.left, rect.bottom); |
|
|
|
this._appendLineTo(rect.right, rect.bottom); |
|
|
|
|
|
|
|
|
|
|
public void addRRect(RRect rrect) { |
|
|
|
this._updateRRectFlag(true); |
|
|
|
float w = rrect.width; |
|
|
|
float h = rrect.height; |
|
|
|
float halfw = Mathf.Abs(w) * 0.5f; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void addEllipse(float cx, float cy, float rx, float ry) { |
|
|
|
this._updateRRectFlag(true); |
|
|
|
this._appendMoveTo(cx - rx, cy); |
|
|
|
this._appendBezierTo(cx - rx, cy + ry * _KAPPA90, |
|
|
|
cx - rx * _KAPPA90, cy + ry, cx, cy + ry); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void addCircle(float cx, float cy, float r) { |
|
|
|
this._updateRRectFlag(true); |
|
|
|
this._updateRRectFlag(true); |
|
|
|
this._updateRRectFlag(false); |
|
|
|
var x0 = this._commandx; |
|
|
|
var y0 = this._commandy; |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void arcTo(Rect rect, float startAngle, float sweepAngle, bool forceMoveTo = true) { |
|
|
|
this._updateRRectFlag(false); |
|
|
|
var mat = Matrix3.makeScale(rect.width / 2, rect.height / 2); |
|
|
|
var center = rect.center; |
|
|
|
mat.postTranslate(center.dx, center.dy); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void addArc(Rect rect, float startAngle, float sweepAngle) { |
|
|
|
this._updateRRectFlag(false); |
|
|
|
this.arcTo(rect, startAngle, sweepAngle, true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void addArc(float cx, float cy, float r, float a0, float a1, PathWinding dir, bool forceMoveTo = true) { |
|
|
|
this._updateRRectFlag(false); |
|
|
|
this._updateRRectFlag(false); |
|
|
|
D.assert(points != null); |
|
|
|
if (points.Count == 0) { |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
public void addPath(Path path, Matrix3 transform = null) { |
|
|
|
D.assert(path != null); |
|
|
|
|
|
|
|
|
|
|
|
this._updateRRectFlag(path.isRRect); |
|
|
|
var i = 0; |
|
|
|
while (i < path._commands.Count) { |
|
|
|
var cmd = (PathCommand) path._commands[i]; |
|
|
|