浏览代码

add drawParagraph

/main
fzhangtj 6 年前
当前提交
d6d7d1bc
共有 2 个文件被更改,包括 20 次插入0 次删除
  1. 8
      Runtime/ui/painting/canvas.cs
  2. 12
      Tests/Editor/CanvasAndLayers.cs

8
Runtime/ui/painting/canvas.cs


using System;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.ui {
public interface Canvas {

void drawTextBlob(TextBlob textBlob, Offset offset, Paint paint);
void drawParagraph(Paragraph paragraph, Offset offset);
void flush();
void reset();

offset = offset,
paint = new Paint(paint),
});
}
public void drawParagraph(Paragraph paragraph, Offset offset) {
D.assert(paragraph != null);
D.assert(PaintingUtils._offsetIsValid(offset));
paragraph.paint(this, offset);
}
public virtual void flush() {

12
Tests/Editor/CanvasAndLayers.cs


this.clipRRect,
this.saveLayer,
this.drawLine,
this.drawParagraph,
};
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray();
this._selected = 0;

editorCanvas.flush();
}
void drawParagraph() {
var pb = new ParagraphBuilder(new ParagraphStyle{});
pb.addText("Hello drawParagraph");
var paragraph = pb.build();
paragraph.layout(new ParagraphConstraints(width:300));
var canvas = new CommandBufferCanvas(this._renderTexture, Window.instance.devicePixelRatio,
this._meshPool);
canvas.drawParagraph(paragraph, new Offset(10f, 100f));
canvas.flush();
}
void drawImageRect() {
if (this._stream == null || this._stream.completer == null || this._stream.completer.currentImage == null) {
return;

正在加载...
取消
保存