本文整理汇总了TypeScript中d3-color.rgb函数的典型用法代码示例。如果您正苦于以下问题:TypeScript rgb函数的具体用法?TypeScript rgb怎么用?TypeScript rgb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rgb函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: improviseGradientFromShorter
improviseGradientFromShorter(shortColors: Color[], numColors: number): Color[] {
const newColors = clone(shortColors)
while (newColors.length < numColors) {
for (let i = newColors.length - 1; i > 0; i -= 1) {
const startColor = rgb(newColors[i - 1])
const endColor = rgb(newColors[i])
const newColor = interpolate(startColor, endColor)(0.5)
newColors.splice(i, 0, newColor)
if (newColors.length >= numColors) break
}
}
return newColors
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:16,代码来源:ColorSchemes.ts
示例2: interpolateArray
function interpolateArray(scaleArr: string[]) {
const N = scaleArr.length - 2 // -1 for spacings, -1 for number of interpolate fns
const intervalWidth = 1 / N
const intervals: Array<(t: number) => string> = []
for (let i = 0; i <= N; i++) {
intervals[i] = interpolate(rgb(scaleArr[i]), rgb(scaleArr[i + 1]))
}
return (t: number) => {
if (t < 0 || t > 1) throw new Error('Outside the allowed range of [0, 1]')
const i = Math.floor(t * N)
const intervalOffset = i * intervalWidth
return intervals[i](t / intervalWidth - intervalOffset / intervalWidth)
}
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:18,代码来源:ColorSchemes.ts
示例3: invertColor
export function invertColor(value: string): string {
const color = d3_color.rgb(value);
const { r, g, b, opacity } = color;
if (opacity === 0) {
return color.toString();
}
const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
const depth = (yiq >= 128) ? -.8 : .8;
return shadeRGBColor(color, depth);
}
开发者ID:emilkpetkov,项目名称:ngx-charts,代码行数:11,代码来源:color-utils.ts
示例4: rgb2hex
export function rgb2hex(color) {
color = rgb(color).toString();
color = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
color =
color && color.length === 4
? '#' +
('0' + parseInt(color[1], 10).toString(16)).slice(-2) +
('0' + parseInt(color[2], 10).toString(16)).slice(-2) +
('0' + parseInt(color[3], 10).toString(16)).slice(-2)
: '';
return color.toUpperCase();
}
开发者ID:socialmedialabs,项目名称:ngx-ui,代码行数:12,代码来源:app.utils.ts
示例5: Date
let num: number,
str: string,
arrNum: number[],
arrStr: string[],
objKeyVal: { [key: string]: any },
objRGBColor: d3Color.RGBColor,
objHSVColor: d3Hsv.HSVColor,
zoom: [number, number, number];
// test interpolate(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolate('1', 5);
// color interpolator returning a color string
iString = d3Interpolate.interpolate('seagreen', d3Color.rgb(100, 100, 100));
iString = d3Interpolate.interpolate('seagreen', d3Hsv.hsv(60, 1, 0.2, 0.4));
iString = d3Interpolate.interpolate('seagreen', 'steelblue'); // as used with valid color name string
// date interpolator
iDate = d3Interpolate.interpolate(new Date(2016, 6, 1), new Date(2016, 6, 31));
// regular string interpolator interpolating number strings (as the strings are not valid color strings)
iString = d3Interpolate.interpolate(1, '5');
iString = d3Interpolate.interpolate('a: 1', 'a: 5');
iString = d3Interpolate.interpolate(new StringCoercible('a: 1'), 'a: 5');
iArrayNum = d3Interpolate.interpolate(['1', '2'], [4, 8]);
iArrayStr = d3Interpolate.interpolate(['1', '2'], ['4', '8']);
// two element array with first element date and second element string
iArrayMixed = d3Interpolate.interpolate<[Date, string]>([new Date(2016, 6, 1), 'b: 2'], [new Date(2016, 6, 31), 'b: 8']);
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:31,代码来源:d3-interpolate-tests.ts
示例6:
import * as d3Color from 'd3-color';
// Signature tests for 'color', rgb and hsl
let c: d3Color.RGBColor | d3Color.HSLColor | null;
let cRGB: d3Color.RGBColor;
let cHSL: d3Color.HSLColor;
let displayable: boolean;
let cString: string;
let nil: null;
c = d3Color.color('oops');
c = d3Color.color('steelblue');
c = d3Color.color('rgba(20, 100, 200, 0.5)');
c = d3Color.color(d3Color.rgb(0, 0, 0));
cRGB = d3Color.color('hsl(60, 100%, 20%, 0.5)')!.rgb();
cRGB = d3Color.rgb(20, 100, 200);
cRGB = d3Color.rgb(20, 100, 200, 0.5);
cRGB = d3Color.rgb('steelblue');
cRGB = d3Color.rgb('rgba(20, 100, 200, 0.5)');
cRGB = d3Color.rgb(c);
cRGB = cRGB.brighter();
cRGB = cRGB.brighter(0.2);
cRGB = cRGB.darker();
cRGB = cRGB.darker(0.2);
cRGB = cRGB.rgb();
displayable = cRGB.displayable();
cString = cRGB.toString();
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-color-tests.ts
示例7: calculateColor
private calculateColor(d: TrialNodeData, trial_id: number): any {
var proportion = Math.round(255 * (1.0 - (d.duration[trial_id] / this.maxTotalDuration)));
//Math.round(510 * (node.duration - self.min_duration[node.trial_id]) / self.total_duration[node.trial_id]);
return d3_rgb(255, proportion, proportion, 255).toString();
}
开发者ID:gems-uff,项目名称:noworkflow,代码行数:5,代码来源:graph.ts
示例8: hsv
// Specifier signature
cHSV = hsv('rgb(255, 255, 255)');
cHSV = hsv('rgb(10%, 20%, 30%)');
cHSV = hsv('rgba(255, 255, 255, 0.4)');
cHSV = hsv('rgba(10%, 20%, 30%, 0.4)');
cHSV = hsv('hsl(120, 50%, 20%)');
cHSV = hsv('hsla(120, 50%, 20%, 0.4)');
cHSV = hsv('#ffeeaa');
cHSV = hsv('#fea');
cHSV = hsv('steelblue');
cHSV = hsv('');
// Color signature
cRGB = rgb('steelblue');
cHSV = hsv(cRGB);
cHSV = hsv(cHSV);
// Method signatures
cHSV = cHSV.brighter();
cHSV = cHSV.brighter(0.2);
cHSV = cHSV.darker();
cHSV = cHSV.darker(0.2);
displayable = cHSV.displayable();
cString = cHSV.toString();
console.log('Channels = (h : %d, s: %d, v: %d)', cHSV.h, cHSV.s, cHSV.v);
console.log('Opacity = %d', cHSV.opacity);
// Interpolater
开发者ID:MichaelBuen,项目名称:DefinitelyTyped,代码行数:31,代码来源:d3-hsv-tests.ts
示例9: hsv
// hsv signature
cHSV = hsv(120, 0.4, 0.5);
cHSV = hsv(120, 0.4, 0.5, 0.5);
// specifier signature
cHSV = hsv('rgb(255, 255, 255)');
cHSV = hsv('rgb(10%, 20%, 30%)');
cHSV = hsv('rgba(255, 255, 255, 0.4)');
cHSV = hsv('rgba(10%, 20%, 30%, 0.4)');
cHSV = hsv('hsl(120, 50%, 20%)');
cHSV = hsv('hsla(120, 50%, 20%, 0.4)');
cHSV = hsv('#ffeeaa');
cHSV = hsv('#fea');
cHSV = hsv('steelblue');
// color signature
c = rgb('steelblue');
cHSV = hsv(c);
cHSV = hsv(cHSV);
// method signatures
cHSV = cHSV.brighter();
cHSV = cHSV.brighter(0.2);
cHSV = cHSV.darker();
cHSV = cHSV.darker(0.2);
displayable = cHSV.displayable();
cString = cHSV.toString();
console.log('Channels = (h : %d, s: %d, v: %d)', cHSV.h, cHSV.s, cHSV.v);
console.log('Opacity = %d', cHSV.opacity);
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:29,代码来源:d3-hsv-tests.ts
示例10: hexToRgb
export function hexToRgb(value: string): any {
// deprecated, use d3.color()
return d3_color.rgb(value);
}
开发者ID:emilkpetkov,项目名称:ngx-charts,代码行数:4,代码来源:color-utils.ts
注:本文中的d3-color.rgb函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论