Spaces:
Configuration error
Configuration error
File size: 745 Bytes
b700c24 | 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 | import * as d3 from 'd3';
/**
* Calculate mapping functions for font coordinates
* Simplified version - just returns the scale functions
*/
export function calculateMappingDimensions(fonts, width = 2000, height = 2000) {
const padding = 50;
const xExtent = d3.extent(fonts, d => d.x);
const yExtent = d3.extent(fonts, d => d.y);
const mapX = d3.scaleLinear()
.domain(xExtent)
.range([padding, width - padding]);
const mapY = d3.scaleLinear()
.domain(yExtent)
.range([padding, height - padding]);
return { mapX, mapY };
}
/**
* Create transform string for a glyph
*/
export function createGlyphTransform(x, y, scale = 1.0) {
return `translate(${x}, ${y}) scale(${scale})`;
}
|