當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript d3-interpolate.interpolateRgb函數代碼示例

本文整理匯總了TypeScript中d3-interpolate.interpolateRgb函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript interpolateRgb函數的具體用法?TypeScript interpolateRgb怎麽用?TypeScript interpolateRgb使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了interpolateRgb函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

updateTransition = updateTransition.tween('fillColor', function (d, i, group) {
    let circle = this;
    let interpolator = interpolateRgb(circle.getAttribute('fill'), d.color); // datum type CircleDatum
    console.log('Radius ', this.r.baseVal.value); // this type SVGCircleElement
    return function (t) {
        circle.setAttribute('fill', interpolator(t));
    };
});
開發者ID:rchaser53,項目名稱:DefinitelyTyped,代碼行數:8,代碼來源:d3-transition-tests.ts

示例2: function

updateTransition = updateTransition.tween('fillColor', function (d, i, g) {
    let that: SVGCircleElement = this;
    // let that2: HTMLElement  = this; // fails, type mismatch
    let datum: CircleDatum = d;
    let index: number = i;
    let group: SVGCircleElement[] | ArrayLike<SVGCircleElement> = g;
    let c: string | null = that.getAttribute('fill');
    let interpolator = interpolateRgb(c ? c : 'blue', d.color); // datum type CircleDatum
    console.log('Radius ', this.r.baseVal.value); // this type SVGCircleElement
    return function (t) {
        that.setAttribute('fill', interpolator(t));
    };
});
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:d3-transition-tests.ts

示例3: iZoom

iZoom = d3Interpolate.interpolateZoom([50, 50, 300], [100, 100, 500]);
zoom = iZoom(0.5);

console.log('Recommended transition duration = %d', iZoom.duration);

// test quantize(interpolator, n) signature ------------------------------------------------

arrNum = d3Interpolate.quantize(d3Interpolate.interpolateRound(-1, 2), 4); // infered template parameter type
arrStr = d3Interpolate.quantize<string>(d3Interpolate.interpolateString('-1', '2'), 4); // explicit template parameter typing

// arrStr = d3Interpolate.quantize<string>(d3Interpolate.interpolateRound(-1, 2), 4); // test fails, due to explicit typing v argument type mismatch

// test interpolateRgb(a, b) signatures ----------------------------------------------------------------

// without gamma correction
iString = d3Interpolate.interpolateRgb('seagreen', 'steelblue');
iString = d3Interpolate.interpolateRgb(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateRgb(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
str = iString(0.5);

// with gamma correction
iString = d3Interpolate.interpolateRgb.gamma(2.2)('purple', 'orange');

// test interpolateRgbBasis(color) and  interpolateRgbBasisClosed(color) signatures -------------------------

iString = d3Interpolate.interpolateRgbBasis(['seagreen', d3Color.rgb('steelblue'), 'rgb(100, 100, 100)']);
iString = d3Interpolate.interpolateRgbBasis(['seagreen', d3Hsv.hsv('steelblue'), 'rgb(100, 100, 100)']);
iString = d3Interpolate.interpolateRgbBasisClosed(['seagreen', d3Hsv.hsv('steelblue'), 'rgb(100, 100, 100)']);

// test interpolateHsl(a, b) and interpolateHslLong(a, b)----------------------------------------------------------------
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:d3-interpolate-tests.ts


注:本文中的d3-interpolate.interpolateRgb函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。