/
githubmirror
/
d3
Обзор
Документация
Войти
/
githubmirror
/
d3
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/components/ColorRamp.vue
30 строк
621 B
Mike Bostock
vitepress docs (#3654)
08 июн 2023, 04:30
Не верифицирован
08 июн 2023, 04:30
6d6c679
Код
Авторство
О чём код?
<script> function render(canvas, color, n) { canvas.width = n; canvas.height = 1; const context = canvas.getContext("2d"); for (let i = 0; i < n; ++i) { context.fillStyle = color(i / (n - 1)); context.fillRect(i, 0, 1, 1); } } export default { props: { color: {type: Function}, n: {type: Number, default: 256} }, mounted() { render(this.$el, this.color, this.n); }, updated() { render(this.$el, this.color, this.n); } } </script> <template> <canvas style="width: 100%; height: 40px; image-rendering: -moz-crisp-edges; image-rendering: pixelated;"></canvas> </template>