小编Tre*_*vor的帖子

How can I extend Backbone.Events in a Typescript ES6 Class?

I'm trying to attach Backbone's Events properties onto a TypeScript class, however when I do this...

class Foo {
    constructor () {
        _.assign(this, Backbone.Events); // or _.extend()
        this.stopListening(this.otherInstance);
    }
}

let bar = new Foo();
bar.on("myevent", handler);
Run Code Online (Sandbox Code Playgroud)

...I get these compile time errors:

  • Error TS2339: Property 'stopListening' does not exist on type 'Foo'.
  • Error TS2339: Property 'on' does not exist on type 'Foo'.

I'm not very familiar with how TypeScript would approach this, but seems like something it could handle. …

javascript inheritance backbone.js typescript

5
推荐指数
1
解决办法
1581
查看次数

WebGL:当 alpha 为 0 时,为什么透明画布显示clearColor颜色分量?

这是一个简单的尖峰,显示了我的问题:

<html>
<head>
    <title>Clear Color</title>
    <style type="text/css">
        #stage {
            background-color: rgba(127,127,127,1);
        }
    </style>
</head>
<body>
    <canvas id="stage" width="100", height="100"></canvas>
    <script type="text/javascript">
        var options = {
            alpha: true,
            premultipliedAlpha: true
        };
        var ctx = document.getElementById("stage").getContext("webgl", options);
        ctx.clearColor(1, 0, 0, 0);
        ctx.enable(ctx.BLEND);
        ctx.blendFuncSeparate(
            ctx.SRC_ALPHA, ctx.ONE_MINUS_SRC_ALPHA,
            ctx.ONE, ctx.ONE_MINUS_SRC_ALPHA
        );
        ctx.clear(ctx.COLOR_BUFFER_BIT);
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

BlendFunc 是这样的:
(sR*sA) + (dR*(1-sA)) = rR
(sG*sA) + (dG*(1-sA)) = rG
(sB*sA) + (dB*(1 -sA)) = rB
(sA*1) + (dA*(1-sA)) = rA

...这意味着(我认为):
(1*0) + (0.5*(1-0)) = 0.5
(0*0) …

webgl

4
推荐指数
1
解决办法
4465
查看次数

标签 统计

backbone.js ×1

inheritance ×1

javascript ×1

typescript ×1

webgl ×1