Compare commits

..

No commits in common. "1994e7ccb11525c4964fd08b5cf49bba08b6c426" and "65faf0230bbe8341cace69383d4bb8d25f5b9cc2" have entirely different histories.

16 changed files with 177 additions and 152 deletions

View File

@ -1,3 +1,10 @@
# how to build
```
g++ build.cpp -o build
./build
or
./build run
```
# Code style # Code style
@ -28,6 +35,6 @@
## Generate shader .h files ## Generate shader .h files
``` ```
xxd -i shaders/sun_100.fs > shared/inc/canvas/sunShader.hpp xxd -i shaders/sun_100.fs > inc/sunShader.hpp
xxd -i shaders/sun_330.fs >> shared/inc/canvas/sunShader.hpp xxd -i shaders/sun_330.fs >> inc/sunShader.hpp
``` ```

View File

@ -1,4 +1,4 @@
#include <cstdio> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "sys.hpp" #include "sys.hpp"
#include <raylib.h> #include <raylib.h>
@ -25,7 +25,7 @@ namespace sys
const char *saveFilePath = transformFilePath(filename); const char *saveFilePath = transformFilePath(filename);
FILE *file = fopen(saveFilePath, "wb"); FILE *file = fopen(saveFilePath, "wb");
if (file == nullptr) if (file == NULL)
return false; return false;
size_t ret = fwrite(data, 1, size, file); size_t ret = fwrite(data, 1, size, file);
@ -39,7 +39,7 @@ namespace sys
const char *saveFilePath = transformFilePath(filename); const char *saveFilePath = transformFilePath(filename);
FILE *file = fopen(saveFilePath, "rb"); FILE *file = fopen(saveFilePath, "rb");
if (file == nullptr) if (file == NULL)
return false; return false;
size_t ret = fread(data, 1, size, file); size_t ret = fread(data, 1, size, file);

View File

@ -1,17 +1,17 @@
#version 300 es #version 100
precision mediump float; precision mediump float;
in vec2 fragTexCoord; varying vec2 fragTexCoord;
in vec4 fragColor; varying vec4 fragColor;
out vec4 finalColor;
uniform vec3 color; uniform vec3 color;
vec2 offset = vec2(1.0, 1.0); uniform float sun_radius;
uniform float start_transperency;
float start_transparency = 0.40f; vec2 offset = vec2(1.0, 1.0);
float sun_radius = 0.6f; float sun_end = 1.0;
float sun_end = 1.0f;
void main() void main()
{ {
@ -20,13 +20,17 @@ void main()
float radius = length(offset); float radius = length(offset);
if(radius < sun_radius){ if(radius < sun_radius){
finalColor = vec4(color, 1.0);
gl_FragColor = vec4(color, 1.0);
}else if(radius < sun_end){ }else if(radius < sun_end){
float gradient = radius; float gradient = radius;
gradient -= sun_radius; gradient -= sun_radius;
gradient = gradient / 0.4f * start_transparency; gradient = gradient / (sun_end - sun_radius) * start_transperency;
finalColor = vec4(color, start_transparency - gradient); gl_FragColor = vec4(color, start_transperency - gradient);
}else{ }else{
finalColor = vec4(color, 0.0); gl_FragColor = vec4(color, 0.0);
} }
} }

View File

@ -5,10 +5,9 @@ in vec4 fragColor;
out vec4 finalColor; out vec4 finalColor;
uniform vec3 color; uniform vec3 color;
vec2 offset = vec2(1.0, 1.0); uniform float sun_radius;
uniform float start_transperency;
float start_transparency = 0.40f; vec2 offset = vec2(1.0f, 1.0f);
float sun_radius = 0.6f;
float sun_end = 1.0f; float sun_end = 1.0f;
void main() void main()
@ -21,8 +20,8 @@ void main()
}else if(radius < sun_end){ }else if(radius < sun_end){
float gradient = radius; float gradient = radius;
gradient -= sun_radius; gradient -= sun_radius;
gradient = gradient / 0.4f * start_transparency; gradient = gradient / (sun_end - sun_radius) * start_transperency;
finalColor = vec4(color, start_transparency - gradient); finalColor = vec4(color, start_transperency - gradient);
}else{ }else{
finalColor = vec4(color, 0.0f); finalColor = vec4(color, 0.0f);
} }

View File

@ -2,6 +2,8 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <cinttypes> #include <cinttypes>
#define AS_DEFAULT_BUFFER_SIZE 0x1000 /*4096 bytes*/
constexpr int64_t StartHeader = 1737720524UL; constexpr int64_t StartHeader = 1737720524UL;
constexpr uint16_t serverPort = 9000; constexpr uint16_t serverPort = 9000;
constexpr uint16_t keyPort = 9010; constexpr uint16_t keyPort = 9010;

View File

@ -6,6 +6,7 @@ public:
static void init(); static void init();
static void deinit(); static void deinit();
static void setColor(Color color); static void setColor(Color color);
static void setSoftEdge(bool soft);
static void draw(float x, float y, float size); static void draw(float x, float y, float size);
Circle() = delete; Circle() = delete;
@ -15,6 +16,11 @@ private:
static RenderTexture2D target; static RenderTexture2D target;
static Shader shader; static Shader shader;
static float radius;
static float start_transperency;
static float c[3]; static float c[3];
static int radius_loc;
static int start_transperency_loc;
static int colorLoc; static int colorLoc;
}; };

View File

@ -28,6 +28,7 @@ private:
Dna *m_dna; Dna *m_dna;
uint128 branchSeed; uint128 branchSeed;
int canvasSize = 0;
Vector2 start = {0}; Vector2 start = {0};
std::list<DrawArgs> drawCalls; std::list<DrawArgs> drawCalls;

View File

@ -1,123 +1,88 @@
unsigned char shaders_sun_100_fs[] = { const char *sun_shader_100 = "#version 100\n\
0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x30, 0x30, precision mediump float;\
0x20, 0x65, 0x73, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69, varying vec2 fragTexCoord;\
0x6f, 0x6e, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x66, varying vec4 fragColor;\
0x6c, 0x6f, 0x61, 0x74, 0x3b, 0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, uniform vec3 color;\
0x63, 0x32, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, uniform float sun_radius;\
0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, uniform float start_transperency;\
0x20, 0x66, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, vec2 offset = vec2(1.0, 1.0);\
0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, float sun_end = 1.0;\
0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, void main()\
0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, {\
0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, offset.x -= fragTexCoord.x * 2.0;\
0x66, 0x66, 0x73, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, offset.y -= fragTexCoord.y * 2.0;\
0x28, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, float radius = length(offset);\
0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, if (radius < sun_radius) {\
0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, gl_FragColor = vec4(color, 1.0);\
0x79, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x34, 0x30, 0x66, 0x3b, 0x0a, 0x66, }\
0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, else if (radius < sun_end) {\
0x69, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x36, 0x66, 0x3b, 0x0a, float gradient = radius;\
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, gradient -= sun_radius;\
0x64, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, gradient = gradient / (sun_end - sun_radius) * start_transperency;\
0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, gl_FragColor = vec4(color, start_transperency - gradient);\
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, }\
0x78, 0x20, 0x2d, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, else {\
0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x2e, gl_FragColor = vec4(color, 0.0);\
0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, }\
0x74, 0x2e, 0x79, 0x20, 0x2d, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, }";
0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x79, 0x20, 0x2a, 0x20,
0x32, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3d, 0x20,
0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x6f, 0x66, 0x66, 0x73, 0x65,
0x74, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x28,
0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73, 0x75, 0x6e,
0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43,
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69,
0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73,
0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x67,
0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x72, 0x61,
0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2d,
0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72,
0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x67, 0x72, 0x61,
0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x20, 0x30, 0x2e, 0x34, 0x66,
0x20, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61,
0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34,
0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, 0x74, 0x61, 0x72,
0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e,
0x63, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e,
0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73,
0x65, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66,
0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20,
0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20,
0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
0x7d, 0x0a
};
unsigned int shaders_sun_100_fs_len = 710;
unsigned char shaders_sun_330_fs[] = { unsigned char shaders_sun_330_fs[] = {
0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30,
0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x66, 0x72, 0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x66, 0x72,
0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a,
0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x72, 0x61, 0x67, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x72, 0x61, 0x67,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76,
0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c,
0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d,
0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b,
0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x66, 0x6c, 0x6f,
0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x30, 0x2c, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75,
0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x73, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x66,
0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74,
0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x3d, 0x20, 0x30, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b,
0x2e, 0x34, 0x30, 0x66, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74,
0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x30, 0x66,
0x20, 0x30, 0x2e, 0x36, 0x66, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x66, 0x6c, 0x6f,
0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x31, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x3d,
0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64,
0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20,
0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x20, 0x2d, 0x3d, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x20, 0x2d,
0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f,
0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x64, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20,
0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x79, 0x20, 0x2d, 0x3d, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x79, 0x20, 0x2d,
0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f,
0x2e, 0x79, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x64, 0x2e, 0x79, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20,
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69,
0x20, 0x3d, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x6f, 0x66, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28,
0x66, 0x73, 0x65, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73, 0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c,
0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x7b, 0x0a, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69,
0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76,
0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31,
0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65,
0x65, 0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75,
0x3c, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x7b, 0x0a, 0x73, 0x20, 0x3c, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c,
0x74, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x6f, 0x61, 0x74, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74,
0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69,
0x74, 0x20, 0x2d, 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x65, 0x6e, 0x74, 0x20, 0x2d, 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72,
0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20,
0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x20, 0x30, 0x3d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f,
0x2e, 0x34, 0x66, 0x20, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x20, 0x28, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x2d, 0x20,
0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x20,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e,
0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x73, 0x70, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b, 0x0a, 0x20, 0x20,
0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43,
0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28,
0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74,
0x69, 0x65, 0x6e, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x65, 0x72, 0x65, 0x6e, 0x63,
0x65, 0x6c, 0x73, 0x65, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74,
0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, 0x65,
0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69,
0x72, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76,
0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x30,
}; 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
unsigned int shaders_sun_330_fs_len = 678; 0x7d, 0x0a};

View File

@ -1,4 +1,4 @@
#include <cinttypes> #include <inttypes.h>
struct uint128 struct uint128
{ {

View File

@ -40,7 +40,7 @@ namespace TcpSocket
char ip[INET_ADDRSTRLEN]; char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(address.sin_addr), ip, INET_ADDRSTRLEN); inet_ntop(AF_INET, &(address.sin_addr), ip, INET_ADDRSTRLEN);
return {ip}; return std::string(ip);
} }
int remotePort(sockaddr_in &address) { return ntohs(address.sin_port); } int remotePort(sockaddr_in &address) { return ntohs(address.sin_port); }

View File

@ -14,6 +14,12 @@ constexpr static float moonXOffset = 0.1f;
constexpr static float minSizeOfMoon = 0.1f; constexpr static float minSizeOfMoon = 0.1f;
constexpr static float maxSizeOfMoon = 0.15f; constexpr static float maxSizeOfMoon = 0.15f;
constexpr static float maxYPosOfMoon = 0.80f; constexpr static float maxYPosOfMoon = 0.80f;
constexpr static float bigRingRatio = 0.5f;
constexpr static float smallRingRatio = 0.25f;
constexpr static float bigRingBlend = 0.02f;
constexpr static float smallRingBlend = 0.05f;
constexpr static float colorRatio1 = 0.3f;
constexpr static float colorRatio2 = 0.7f;
constexpr static float mounten1min = 0.65f; constexpr static float mounten1min = 0.65f;
constexpr static float mounten1max = 0.85f; constexpr static float mounten1max = 0.85f;
constexpr static float mounten2min = 0.80f; constexpr static float mounten2min = 0.80f;
@ -52,6 +58,7 @@ void BackGround::deinit()
void BackGround::draw(Dna *dna) void BackGround::draw(Dna *dna)
{ {
Circle::setSoftEdge(true);
m_dna = dna; m_dna = dna;
mountenSeed = dna->mountenSeed; mountenSeed = dna->mountenSeed;
starSeed = dna->starSeed; starSeed = dna->starSeed;

View File

@ -6,18 +6,30 @@
RenderTexture2D Circle::target; RenderTexture2D Circle::target;
Shader Circle::shader; Shader Circle::shader;
float Circle::radius;
float Circle::start_transperency;
float Circle::c[3]; float Circle::c[3];
int Circle::radius_loc;
int Circle::start_transperency_loc;
int Circle::colorLoc; int Circle::colorLoc;
void Circle::init() void Circle::init()
{ {
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
shader = LoadShaderFromMemory(nullptr, sun_shader_100); shader = LoadShaderFromMemory(0, sun_shader_100);
#else #else
shader = LoadShaderFromMemory(nullptr, (const char *)shaders_sun_330_fs); shader = LoadShaderFromMemory(0, (const char *)shaders_sun_330_fs);
#endif #endif
target = LoadRenderTexture(sizeTexute, sizeTexute); target = LoadRenderTexture(sizeTexute, sizeTexute);
radius = 0.6f;
radius_loc = GetShaderLocation(shader, "sun_radius");
SetShaderValue(shader, radius_loc, &radius, SHADER_UNIFORM_FLOAT);
start_transperency = 0.40f;
start_transperency_loc = GetShaderLocation(shader, "start_transperency");
SetShaderValue(shader, start_transperency_loc, &start_transperency, SHADER_UNIFORM_FLOAT);
c[0] = 1.0f; c[0] = 1.0f;
c[1] = 1.0f; c[1] = 1.0f;
c[2] = 1.0f; c[2] = 1.0f;
@ -43,6 +55,19 @@ void Circle::setColor(Color color)
SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3); SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3);
} }
void Circle::setSoftEdge(bool soft)
{
if (soft)
{
radius = 0.6f;
}
else
{
radius = 1.0f;
}
SetShaderValue(shader, radius_loc, &radius, SHADER_UNIFORM_FLOAT);
}
void Circle::draw(float x, float y, float size) void Circle::draw(float x, float y, float size)
{ {
Rectangle dest = {x - size, y - size, size * 2, size * 2}; Rectangle dest = {x - size, y - size, size * 2, size * 2};

View File

@ -1,6 +1,7 @@
#include <cmath> #include <cmath>
#include "canvas/Tree.hpp" #include "canvas/Tree.hpp"
#include "canvas/Circle.hpp"
#include <raylib.h> #include <raylib.h>
#include <raymath.h> #include <raymath.h>
@ -37,6 +38,7 @@ void calculateLevels(int canvasSize)
// Public // Public
void Tree::init(int size) void Tree::init(int size)
{ {
this->canvasSize = size;
start.x = size / 2; start.x = size / 2;
start.y = size; start.y = size;
calculateLevels(size); calculateLevels(size);
@ -44,6 +46,8 @@ void Tree::init(int size)
void Tree::draw(Dna *dna) void Tree::draw(Dna *dna)
{ {
Circle::setSoftEdge(false);
m_dna = dna; m_dna = dna;
branchSeed = dna->branchSeed; branchSeed = dna->branchSeed;
drawCalls.push_back({start, 180.0f, 0}); drawCalls.push_back({start, 180.0f, 0});

View File

@ -13,6 +13,7 @@ namespace DNA
{ {
array[i] = mrand::getValue(256, state); array[i] = mrand::getValue(256, state);
} }
return;
} }
void makeChild(Dna *p1, Dna *p2, Dna *c, uint128 *state) void makeChild(Dna *p1, Dna *p2, Dna *c, uint128 *state)
@ -37,8 +38,8 @@ namespace DNA
void clone(Dna *p1, Dna *c, uint128 *state) void clone(Dna *p1, Dna *c, uint128 *state)
{ {
uint8_t *p1a = (uint8_t *)p1; uint8_t *p1a = (uint8_t *)p1;
uint8_t *ca = (uint8_t *)c; uint8_t *ca = (uint8_t *)c;
for (size_t i = 0; i < sizeof(Dna); i++) for (size_t i = 0; i < sizeof(Dna); i++)
{ {
int val = mrand::getValue(2, state); int val = mrand::getValue(2, state);

View File

@ -56,7 +56,7 @@ void DnaManager::newGen(DnaManagerData *data)
data->queued = 0; data->queued = 0;
data->showed = 0; data->showed = 0;
data->generation += 1; data->generation += 1;
if (data->liked.empty()) if (data->liked.size() == 0)
{ {
for (std::size_t i = 0; i < NUM_PER_GEN; i++) for (std::size_t i = 0; i < NUM_PER_GEN; i++)
{ {

View File

@ -1,6 +1,10 @@
#include "values/Similarity.hpp" #include "values/Similarity.hpp"
#include <cmath> #include <cmath>
#define MATCH 1
#define MISMATCH -1
#define GAP -2
namespace Similarity namespace Similarity
{ {
// todo: use int8_t insted of uint8_t and map data // todo: use int8_t insted of uint8_t and map data