blob: 9282d094b8058b2cac372334e742ca67fb992e14 [file] [log] [blame]
Chris Dalton2b598902020-03-25 10:50:35 -06001/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include <emscripten.h>
9#include <emscripten/bind.h>
10#include "tools/viewer/SampleSlide.h"
11#include <string>
12
13using namespace emscripten;
14
15EMSCRIPTEN_BINDINGS(Viewer) {
16 function("MakeSlide", optional_override([](std::string name)->sk_sp<Slide> {
17 if (name == "WavyPathText") {
18 extern Sample* MakeWavyPathTextSample();
19 return sk_make_sp<SampleSlide>(MakeWavyPathTextSample);
20 }
21 return nullptr;
22 }));
23 class_<Slide>("Slide")
24 .smart_ptr<sk_sp<Slide>>("sk_sp<Slide>")
25 .function("load", &Slide::load)
26 .function("animate", &Slide::animate)
27 .function("draw", optional_override([](Slide& self, SkCanvas& canvas) {
28 self.draw(&canvas);
29 }));
30}