Giter Site home page Giter Site logo

batmam hhh



𝐌𝐄𝐃𝐔𝐒𝐀 : 𝕄𝔼            𝐏𝐎𝐒𝐄𝐈𝐃𝐎𝐍 :

meow hhh meow hhh

𝟜𝟚 𝕡𝕣𝕠𝕗𝕚𝕝𝕖:


#include <mlx.h>
#include <math.h>
//math function: "y=x^{\frac{2}{3}}+0.9*\sqrt{3.3\ -\ x^{2}}*\sin(a*\pi*x)\"

typedef struct    s_data {
    void    *img;
    char    *addr;
    int        bits_per_pixel;
    int        line_length;
    int        endian;
}                t_data;

void    my_mlx_pixel_put(t_data *data, int x, int y, int color)
{
    char    *dst;

    dst = data->addr + (y * data->line_length + x * (data->bits_per_pixel / 8));
    *(unsigned int*)dst = color;
}

double map(double x, double in_min, double in_max, double out_min, double out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

int    main(void)
{
    void    *mlx;
    void    *mlx_win;
    t_data    img;
    double x = 500;
    double tmp_x;
   //change a value (0 < a < 280)
    double a = 10000;
    double y;
    mlx = mlx_init();
    mlx_win = mlx_new_window(mlx, 1920, 1080, "Hello world!");
    img.img = mlx_new_image(mlx, 1920, 1080);
    img.addr = mlx_get_data_addr(img.img, &img.bits_per_pixel, &img.line_length,
                                &img.endian);

double yy;
double yyy;
double yyyy;
    while (x < 1000)
    {
        tmp_x = map(x, 500, 1000, 1.8164, -1.8164);
        y = 0;
        yy = cbrt(pow(tmp_x, 2));
        yyy = 0.9 * sqrt(3.3 - pow(tmp_x, 2));
        yyyy = sin(a * M_PI * tmp_x);
        y = yy + yyy * yyyy;
        my_mlx_pixel_put(&img, x, map(y, 1.8164, -1.8164, 500, 1000), 0x002b1d69);
        x= x + 0.0001 ;
    }
    mlx_put_image_to_window(mlx, mlx_win, img.img, 0, 0);
    mlx_loop(mlx);
}

HYPNOS's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.