-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PaintTarget from Client? #26
Comments
I'd be interested in doing that if there's a good use case for it, with the caveat that the |
You'll notice from my previous comment here that I'm also loading CanvasKit. In fact, the two back-ends I would like to be able to paint to for my purposes are:
I'd be overjoyed if you'd make these available directly in DropFlow, but failing that, export your API. Failing that, if you could provide me with an example of how I can walk your laid-out tree and extract the boxes, positions, and other style info in drawing order, using your existing API, that would be super helpful and save me some serious reverse-engineering time. |
Oh, and BTW the reason I've turned to DropFlow is that CanvasKit |
So I realized (duh) that I could just provide a duck-typed class RenderingContext {
moveTo(x: number, y: number): void {
console.log(`moveTo(${x}, ${y})`);
}
// ...
}
// ...
test('Render to custom context' , () => {
const text = 'Any sufficiently advanced technology is indistinguishable from magic.';
const elem: HTMLElement = h('div', text);
const root = flow.dom(elem);
const container: BlockContainer = flow.generate(root);
flow.layout(container, 200, 200);
const width = flow.staticLayoutContribution(container);
flow.layout(container, width, 200);
const context = new RenderingContext();
flow.paintToCanvas(container, context);
}); |
Your docs say:
I see this in the source code, but is there a way I can "plug in" my own
PaintBackEnd
or write apaintMySurface()
function without having to change the dropflow codebase?The text was updated successfully, but these errors were encountered: