[demos] Add directory from which to serve demos.skia.org
To run the demos locally, cd in to the directory and run make local Then navigate to, for example, http://localhost:8123/demos/hello_world/ Change-Id: I5954989053d4602cd558c646e19106998dc00604 Bug: skia:10170 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298397 Reviewed-by: Weston Tracey <westont@google.com>
This commit is contained in:
parent
ebea6d0133
commit
2639a144ff
4
demos.skia.org/Makefile
Normal file
4
demos.skia.org/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
.PHONY: local
|
||||
local:
|
||||
echo "Go check out http://localhost:8123/hello_world/index.html"
|
||||
python2 -m SimpleHTTPServer 8123
|
42
demos.skia.org/hello_world/index.html
Normal file
42
demos.skia.org/hello_world/index.html
Normal file
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<title>Hello World Demo</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script type="text/javascript" src="https://particles.skia.org/static/canvaskit.js"></script>
|
||||
|
||||
<style>
|
||||
canvas {
|
||||
border: 1px dashed grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<h1>Hello world</h1>
|
||||
|
||||
<canvas id=draw width=500 height=500></canvas>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
const ckLoaded = CanvasKitInit({locateFile: (file) => 'https://particles.skia.org/static/'+file});
|
||||
|
||||
ckLoaded.then((CanvasKit) => {
|
||||
const surface = CanvasKit.MakeCanvasSurface('draw');
|
||||
if (!surface) {
|
||||
throw 'Could not make surface';
|
||||
}
|
||||
|
||||
const paint = new CanvasKit.SkPaint();
|
||||
paint.setColor(CanvasKit.RED);
|
||||
|
||||
const textPaint = new CanvasKit.SkPaint();
|
||||
const textFont = new CanvasKit.SkFont(null, 20);
|
||||
|
||||
function drawFrame(canvas) {
|
||||
canvas.drawRect(CanvasKit.LTRBRect(10, 10, 50, 50), paint);
|
||||
canvas.drawText('If you see this, CanvasKit loaded!!', 5, 100, textPaint, textFont);
|
||||
}
|
||||
surface.requestAnimationFrame(drawFrame);
|
||||
});
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user