<commit_before>#include "Graphics.h"
#include "sfwindow.h"
#include <SFML/Graphics.hpp>
#include "utility/misc.h"

#define GRAPHICS WalrusRPG::Graphics

sf::RenderWindow window;
sf::View view;
sf::RenderTexture buffer;

void GRAPHICS::init()
{
    window.create(sf::VideoMode::getDesktopMode(), "WalrusRPG", sf::Style::Fullscreen);
    window.setFramerateLimit(60);
    view = sf::View(window.getDefaultView());
    buffer.create(320, 240);
}

void GRAPHICS::deinit()
{
    window.close();
}

void GRAPHICS::frame_begin()
{
    window.clear(sf::Color::Black);
}

void GRAPHICS::frame_end()
{
    sf::Sprite sprite(buffer.getTexture());
    sf::Vector2u winsize = window.getSize();
    sf::Event event;
    float scale = min(winsize.x / 320.f, winsize.y / 240.f);

    while (window.pollEvent(event))
    {
    }

    window.setView(view = sf::View(sf::FloatRect(0, 0, winsize.x, winsize.y)));

    buffer.display();
    window.clear();
    sprite.setScale(scale, scale);
    sprite.setPosition((winsize.x - 320.f * scale) / 2, (winsize.y - 240.f * scale) / 2);
    window.draw(sprite);
    window.display();
}

void GRAPHICS::put_sprite(const Texture &sheet, int x, int y,
                          const WalrusRPG::Utils::Rect &window)
{
    sf::Sprite sprite;
    sprite.setTexture(sheet.data);
    sprite.setTextureRect(sf::IntRect(window.x, window.y, window.width, window.height));
    sprite.setPosition(x, y);
    buffer.draw(sprite);
}

void GRAPHICS::fill(const WalrusRPG::Graphics::Pixel &color)
{
    UNUSED(color);
}<commit_msg>SFML: (untested) put_pixel<commit_after>#include "Graphics.h"
#include "sfwindow.h"
#include <SFML/Graphics.hpp>
#include "utility/misc.h"

#define GRAPHICS WalrusRPG::Graphics

sf::RenderWindow window;
sf::View view;
sf::RenderTexture buffer;

void GRAPHICS::init()
{
    window.create(sf::VideoMode::getDesktopMode(), "WalrusRPG", sf::Style::Fullscreen);
    window.setFramerateLimit(60);
    view = sf::View(window.getDefaultView());
    buffer.create(320, 240);
}

void GRAPHICS::deinit()
{
    window.close();
}

void GRAPHICS::frame_begin()
{
    window.clear(sf::Color::Black);
}

void GRAPHICS::frame_end()
{
    sf::Sprite sprite(buffer.getTexture());
    sf::Vector2u winsize = window.getSize();
    sf::Event event;
    float scale = min(winsize.x / 320.f, winsize.y / 240.f);

    while (window.pollEvent(event))
    {
    }

    window.setView(view = sf::View(sf::FloatRect(0, 0, winsize.x, winsize.y)));

    buffer.display();
    window.clear();
    sprite.setScale(scale, scale);
    sprite.setPosition((winsize.x - 320.f * scale) / 2, (winsize.y - 240.f * scale) / 2);
    window.draw(sprite);
    window.display();
}

void GRAPHICS::put_sprite(const Texture &sheet, int x, int y,
                          const WalrusRPG::Utils::Rect &window)
{
    sf::Sprite sprite;
    sprite.setTexture(sheet.data);
    sprite.setTextureRect(sf::IntRect(window.x, window.y, window.width, window.height));
    sprite.setPosition(x, y);
    buffer.draw(sprite);
}

void GRAPHICS::fill(const WalrusRPG::Graphics::Pixel &color)
{
    UNUSED(color);
}

void GRAPHICS::put_pixel(uint16_t x, uint16_t y, const WalrusRPG::Graphics::Pixel &color)
{
    sf::RectangleShape pixel;
    pixel.setSize(sf::Vector2f(1, 1));
    pixel.setFillColor(sf::Color(color.r << 3, color.g << 2, color.b << 3));
    pixel.setPosition(x, y);
    buffer.draw(pixel);
}
{'fraction_non_alphanumeric': 0.17016248153618907, 'fraction_numerical': 0.01772525849335303, 'mean_word_length': 4.031203566121842, 'pattern_counts': {'":': 0, '<': 11, '<?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': '486972', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1228, 'n_words': 213}