217056c048
drawText is having issues in a release build. Skottie sometimes asserts in debug mode. This possibly has something to do with memory alignment - like https://skia-review.googlesource.com/c/skia/+/155980 helped fix. Patchset 9 shows off integrating Skia drawing to an HTML canvas using Ganesh. To see it locally, set up https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html and then set $EMSDK to be that directory. Then run make clean make local-example and navigate to http://localhost:8000/skia-wasm/example.html Patchset 20 shows off Skottie animating directly to a Canvas. Docs-Preview: https://skia.org/?cl=153882 Bug: skia: Change-Id: I2ad2f4ffac00925ee901982ccbaeb7aa63b1ea23 Reviewed-on: https://skia-review.googlesource.com/153882 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
16 lines
629 B
JavaScript
16 lines
629 B
JavaScript
|
|
// Adds any extra JS functions/helpers we want to CanvasKit.
|
|
// Wrapped in a function to avoid leaking global variables.
|
|
(function(CanvasKit){
|
|
|
|
function clamp(c) {
|
|
return Math.round(Math.max(0, Math.min(c || 0, 255)));
|
|
}
|
|
|
|
// Colors are just a 32 bit number with 8 bits each of a, r, g, b
|
|
// The API is the same as CSS's representation of color rgba(), that is
|
|
// r,g,b are 0-255, and a is 0.0 to 1.0.
|
|
CanvasKit.Color = function(r, g, b, a) {
|
|
return (clamp(a*255) << 24) | (clamp(r) << 16) | (clamp(g) << 8) | (clamp(b) << 0);
|
|
}
|
|
}(Module)); // When this file is loaded in, the high level object is "Module";
|