<commit_before>//
// ██████  ██ ███████ ████████  ██████  ██████  ███████ ██  ██████  ███    ██ 
// ██   ██ ██ ██         ██    ██    ██ ██   ██ ██      ██ ██    ██ ████   ██ 
// ██   ██ ██ ███████    ██    ██    ██ ██████  ███████ ██ ██    ██ ██ ██  ██ 
// ██   ██ ██      ██    ██    ██    ██ ██   ██      ██ ██ ██    ██ ██  ██ ██ 
// ██████  ██ ███████    ██     ██████  ██   ██ ███████ ██  ██████  ██   ████ 
// 
//
// build & run
// cmake --build . --config Release && Release\distorsion.exe

#include "config.h"
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"

class Distorsion : public olc::PixelGameEngine
{
    olc::vi2d centre = {100, 200};
    float N = 0.5f;     // distorsion factor (-1 <= N <= 1)
    float alp = 10.f;   // depth of the image
    float zoom = 100.f; // zoom factor

    float (*fn_f)(float, float);
    float (*fn_dfdx)(float, float);
    float (*fn_dfdy)(float, float);

    std::unique_ptr<olc::Sprite> source;
    // std::unique_ptr<olc::Sprite> target;

    bool usethreads = true;
    bool displayHelp = true;
    bool displayPars = true;
    bool displayAxes = true;

public:
    Distorsion() { sAppName = "Distorsion"; }

private:
    void fct_sin()
    {
        static auto sfn_f = [](float x, float y) { return sin(x + y); };
        static auto sfn_dfdx = [](float x, float y) { return cos(x + y); };
        static auto sfn_dfdy = [](float x, float y) { return cos(x + y); };
        fn_f = sfn_f;
        fn_dfdx = sfn_dfdx;
        fn_dfdy = sfn_dfdy;
    }

    void fct_sin2()
    {
        static auto sfn_f = [](float x, float y) { return sin(x * x + y * y); };
        static auto sfn_dfdx = [](float x, float y) {
            return 2 * x * cos(x * x + y * y);
        };
        static auto sfn_dfdy = [](float x, float y) {
            return 2 * y * cos(x * x + y * y);
        };
        fn_f = sfn_f;
        fn_dfdx = sfn_dfdx;
        fn_dfdy = sfn_dfdy;
    }

    void fct_gauss()
    {
        static auto sfn_f = [](float x, float y) {
            return exp(-x * x - y * y);
        };
        static auto sfn_dfdx = [](float x, float y) {
            return -2 * x * exp(-x * x - y * y);
        };
        static auto sfn_dfdy = [](float x, float y) {
            return -2 * y * exp(-x * x - y * y);
        };
        fn_f = sfn_f;<commit_msg>fix type of lambdas<commit_after>//
// ██████  ██ ███████ ████████  ██████  ██████  ███████ ██  ██████  ███    ██ 
// ██   ██ ██ ██         ██    ██    ██ ██   ██ ██      ██ ██    ██ ████   ██ 
// ██   ██ ██ ███████    ██    ██    ██ ██████  ███████ ██ ██    ██ ██ ██  ██ 
// ██   ██ ██      ██    ██    ██    ██ ██   ██      ██ ██ ██    ██ ██  ██ ██ 
// ██████  ██ ███████    ██     ██████  ██   ██ ███████ ██  ██████  ██   ████ 
// 
//
// build & run
// cmake --build . --config Release && Release\distorsion.exe

#include "config.h"
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"

class Distorsion : public olc::PixelGameEngine
{
    olc::vi2d centre = {100, 200};
    float N = 0.5f;     // distorsion factor (-1 <= N <= 1)
    float alp = 10.f;   // depth of the image
    float zoom = 100.f; // zoom factor

    float (*fn_f)(float, float);
    float (*fn_dfdx)(float, float);
    float (*fn_dfdy)(float, float);

    std::unique_ptr<olc::Sprite> source;
    // std::unique_ptr<olc::Sprite> target;

    bool usethreads = true;
    bool displayHelp = true;
    bool displayPars = true;
    bool displayAxes = true;

public:
    Distorsion() { sAppName = "Distorsion"; }

private:
    void fct_sin()
    {
        static auto sfn_f = [](float x, float y) -> float { return sin(x + y); };
        static auto sfn_dfdx = [](float x, float y) -> float { return cos(x + y); };
        static auto sfn_dfdy = [](float x, float y)  -> float{ return cos(x + y); };
        fn_f = sfn_f;
        fn_dfdx = sfn_dfdx;
        fn_dfdy = sfn_dfdy;
    }

    void fct_sin2()
    {
        static auto sfn_f = [](float x, float y) -> float { return sin(x * x + y * y); };
        static auto sfn_dfdx = [](float x, float y) -> float {
            return 2 * x * cos(x * x + y * y);
        };
        static auto sfn_dfdy = [](float x, float y) -> float {
            return 2 * y * cos(x * x + y * y);
        };
        fn_f = sfn_f;
        fn_dfdx = sfn_dfdx;
        fn_dfdy = sfn_dfdy;
    }

    void fct_gauss()
    {
        static auto sfn_f = [](float x, float y) -> float{
            return exp(-x * x - y * y);
        };
        static auto sfn_dfdx = [](float x, float y) -> float {
            return -2 * x * exp(-x * x - y * y);
        };
        static auto sfn_dfdy = [](float x, float y) -> float {
            return -2 * y * exp(-x * x - y * y);
        };
        fn_f = sfn_f;
{'fraction_non_alphanumeric': 0.2186046511627907, 'fraction_numerical': 0.008879492600422832, 'mean_word_length': 1.7346820809248555, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, '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': '2753968', 'n_tokens_mistral': 2677, 'n_tokens_neox': 1940, 'n_words': 553}