<commit_before>import numpy as np
import os
from galry import log_debug, log_info, log_warn, get_color
from fontmaps import load_font
from visual import Visual

__all__ = ['TextVisual']

VS = """
gl_Position.x += (offset - text_width / 2) * spacing.x / window_size.x;
gl_Position.y -= index * spacing.y / window_size.y;

gl_Position.xy = gl_Position.xy + posoffset;

gl_PointSize = point_size;
flat_text_map = text_map;
"""

def FS(background_transparent=True):
    if background_transparent:
        background_transparent_shader = "letter_alpha"
    else:
        background_transparent_shader = "1."
    fs = """
// relative coordinates of the pixel within the sprite (in [0,1])
float x = gl_PointCoord.x;
float y = gl_PointCoord.y;

// size of the corresponding character
float w = flat_text_map.z;
float h = flat_text_map.w;

// display the character at the left of the sprite
float delta = h / w;
x = delta * x;
if ((x >= 0) && (x <= 1))
{
    // coordinates of the character in the font atlas
    vec2 coord = flat_text_map.xy + vec2(w * x, h * y);
    float letter_alpha = texture2D(tex_sampler, coord).a;
    out_color = color * letter_alpha;<commit_msg>In TextVisual, posoffset is now independent from the window size.<commit_after>import numpy as np
import os
from galry import log_debug, log_info, log_warn, get_color
from fontmaps import load_font
from visual import Visual

__all__ = ['TextVisual']

VS = """
gl_Position.x += (offset - text_width / 2) * spacing.x / window_size.x;
gl_Position.y -= index * spacing.y / window_size.y;

gl_Position.xy = gl_Position.xy + posoffset / window_size;

gl_PointSize = point_size;
flat_text_map = text_map;
"""

def FS(background_transparent=True):
    if background_transparent:
        background_transparent_shader = "letter_alpha"
    else:
        background_transparent_shader = "1."
    fs = """
// relative coordinates of the pixel within the sprite (in [0,1])
float x = gl_PointCoord.x;
float y = gl_PointCoord.y;

// size of the corresponding character
float w = flat_text_map.z;
float h = flat_text_map.w;

// display the character at the left of the sprite
float delta = h / w;
x = delta * x;
if ((x >= 0) && (x <= 1))
{
    // coordinates of the character in the font atlas
    vec2 coord = flat_text_map.xy + vec2(w * x, h * y);
    float letter_alpha = texture2D(tex_sampler, coord).a;
    out_color = color * letter_alpha;
{'fraction_non_alphanumeric': 0.10660535117056856, 'fraction_numerical': 0.007525083612040134, 'mean_word_length': 3.786, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5974293', 'n_tokens_mistral': 807, 'n_tokens_neox': 793, 'n_words': 251}