export var NotesRenderer;
(function (NotesRenderer) {
    NotesRenderer.render = (context, range, collection, { top, bottom }, contentColor, { rawStart, regionStart, resultStart, resultEnd }) => {
        const dpr = devicePixelRatio;
        const actualTop = top * dpr;
        const actualBottom = bottom * dpr;
        const height = actualBottom - actualTop;
        context.fillStyle = contentColor;
        const padding = 8;
        const noteHeight = 5;
        const searchStart = Math.floor(resultStart - rawStart);
        const searchEnd = Math.floor(resultEnd - rawStart);
        for (const note of collection.events.iterateRange(searchStart - collection.maxDuration, searchEnd)) {
            const position = rawStart + note.position;
            if (position < regionStart) {
                continue;
            }
            const complete = Math.min(rawStart + note.complete, resultEnd);
            const x0 = Math.floor(range.unitToX(position) * dpr);
            const x1 = Math.floor(range.unitToX(complete) * dpr);
            const y = actualTop + padding + Math.floor(note.normalizedPitch() * (height - (padding * 2 + noteHeight)));
            context.fillRect(x0, y, Math.max(1, x1 - x0), noteHeight);
        }
    };
})(NotesRenderer || (NotesRenderer = {}));
