{"size": 1008, "ext": "js", "max_stars_repo_path": "src/createRenderData.js", "max_stars_repo_name": "rightwayround/text-in-shape", "max_stars_repo_stars_event_min_datetime": "2021-03-16T14:54:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T20:05:29.000Z", "max_issues_repo_path": "src/createRenderData.js", "max_issues_repo_name": "rightwayround/text-in-shape", "max_issues_repo_issues_event_min_datetime": "2021-08-04T14:39:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-04T08:10:57.000Z", "max_forks_repo_path": "src/createRenderData.js", "max_forks_repo_name": "rightwayround/text-in-shape", "max_forks_repo_forks_event_min_datetime": "2022-01-24T09:37:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T09:37:19.000Z"}
{"max_stars_count": 4, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 56.0, "max_line_length": 120, "alphanum_fraction": 0.7738095238}
import { svgElementToCanvas, destroyCanvas } from "./svgElementToCanvas";
import { calcLineAlignment } from "./calcLineAlignment";
import { calcTextJustification } from "./calcTextJustification";
import { calcLinePositions } from "./calcLinePositions";
import { addTextContentToLineData } from "./addTextContentToLineData";
import { getLineHeight } from './utils';

export const createRenderData = (text, svgElement, options) => {
    const context = svgElementToCanvas(svgElement);
    const lineHeight = getLineHeight(options);
    const lineData = calcLinePositions({ lineHeight, context, svgElement, options, text });
    const lineDataWithText = addTextContentToLineData({ lineHeight, text, lineData, options });
    const lineDataJustified = options.justifyText ? calcTextJustification(options, lineDataWithText) : lineDataWithText;
    const lineDataAligned = options.justifyText ? lineDataJustified : calcLineAlignment(options, lineDataJustified);
    destroyCanvas();

    return lineDataAligned;
} 