How to use the scratch-svg-renderer.SVGRenderer function in scratch-svg-renderer

To help you get started, we’ve selected a few scratch-svg-renderer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LLK / scratch-vm / src / playground / benchmark.js View on Github external
}

    new ProfilerRun({
        vm,
        warmUpTime,
        maxRecordedTime
    }).run();

    // Instantiate the renderer and connect it to the VM.
    const canvas = document.getElementById('scratch-stage');
    const renderer = new ScratchRender(canvas);
    Scratch.renderer = renderer;
    vm.attachRenderer(renderer);
    const audioEngine = new AudioEngine();
    vm.attachAudioEngine(audioEngine);
    vm.attachV2SVGAdapter(new ScratchSVGRenderer.SVGRenderer());
    vm.attachV2BitmapAdapter(new ScratchSVGRenderer.BitmapAdapter());

    // Feed mouse events as VM I/O events.
    document.addEventListener('mousemove', e => {
        const rect = canvas.getBoundingClientRect();
        const coordinates = {
            x: e.clientX - rect.left,
            y: e.clientY - rect.top,
            canvasWidth: rect.width,
            canvasHeight: rect.height
        };
        Scratch.vm.postIOData('mouse', coordinates);
    });
    canvas.addEventListener('mousedown', e => {
        const rect = canvas.getBoundingClientRect();
        const data = {
github LLK / scratch-gui / src / containers / stage.jsx View on Github external
dragOffset: null,
            dragId: null,
            colorInfo: null,
            question: null,
            sprites: null,
            stageURL: null
        };
        if (this.props.vm.renderer) {
            this.renderer = this.props.vm.renderer;
            this.canvas = this.renderer.canvas;
        } else {
            this.canvas = document.createElement('canvas');
            this.renderer = new Renderer(this.canvas);
            this.props.vm.attachRenderer(this.renderer);
        }
        this.props.vm.attachV2SVGAdapter(new V2SVGAdapter());
        this.props.vm.attachV2BitmapAdapter(new V2BitmapAdapter());
        this.props.vm.setVideoProvider(new VideoProvider());
        this.props.vm.on('LOADED_PROJECT', () => {
            console.log('LOADED PROJECT');
            requestAnimationFrame(this.step.bind(this));
        });
    }
    componentDidMount () {
github LLK / scratch-render / src / SVGSkin.js View on Github external
constructor (id, renderer) {
        super(id);

        /** @type {RenderWebGL} */
        this._renderer = renderer;

        /** @type {SvgRenderer} */
        this._svgRenderer = new SvgRenderer();

        /** @type {Array} */
        this._scaledMIPs = [];

        /** @type {number} */
        this._largestMIPScale = 0;

        /**
        * Ratio of the size of the SVG and the max size of the WebGL texture
        * @type {Number}
        */
        this._maxTextureScale = 1;
    }
github LLK / scratch-render / src / util / svg-text-bubble.js View on Github external
constructor () {
        this.svgRenderer = new SvgRenderer();
        this.svgTextWrapper = new SVGTextWrapper(this.makeSvgTextElement);
        this._textSizeCache = {};
    }

scratch-svg-renderer

SVG renderer for Scratch

BSD-3-Clause
Latest version published 2 days ago

Package Health Score

78 / 100
Full package analysis

Similar packages