File size: 1,024 Bytes
30c32c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
compiled blocks:
    sensing_set_of: jsgen.js@1195, irgen.js@1420
*/
const Cast = require('../util/cast');

class pmLiveTests {
    constructor (runtime) {
        /**
         * The runtime instantiating this block package.
         * @type {Runtime}
         */
        this.runtime = runtime;
    }

    /**
     * Retrieve the block primitives implemented by this package.
     * @return {object.<string, Function>} Mapping of opcode to Function.
     */
    getPrimitives () {
        return {
            looks_setVertTransform: this.setVerticalTransform,
            looks_setHorizTransform: this.setHorizontalTransform
        };
    }

    setVerticalTransform (args, {target}) {
        const percent = Cast.toNumber(args.PERCENT) / 100;
        target.setTransform([percent, target.transform[1]]);
    }

    setHorizontalTransform (args, {target}) {
        const percent = Cast.toNumber(args.PERCENT) / 100;
        target.setTransform([target.transform[0], percent]);
    }
}

module.exports = pmLiveTests;