Merge pull request #3 from EugeneBrace/main

1040p tif for 1080p vids
This commit is contained in:
nilsberglund-orleans
2021-12-02 20:09:02 +01:00
committed by GitHub
4 changed files with 46 additions and 33 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
*.tif
**/*.tif
production/
tif_drop/
*.mp4
**/*.mp4

View File

@@ -16,7 +16,7 @@
/* It may be possible to increase parameter PAUSE */ /* It may be possible to increase parameter PAUSE */
/* */ /* */
/* create movie using */ /* create movie using */
/* ffmpeg -i part.%05d.tif -vcodec libx264 drop.mp4 */ /* ffmpeg -i tif_drop/part.%05d.tif -vcodec libx264 drop.mp4 */
/* */ /* */
/*********************************************************************************/ /*********************************************************************************/
@@ -28,10 +28,16 @@
#include <sys/types.h> #include <sys/types.h>
#include <tiffio.h> /* Sam Leffler's libtiff library. */ #include <tiffio.h> /* Sam Leffler's libtiff library. */
#define MOVIE 0 /* set to 1 to generate movie */ #define MOVIE 1 /* set to 1 to generate movie */
#define WINWIDTH 1280 /* window width */ // #define WINWIDTH 1280 /* window width */
#define WINHEIGHT 720 /* window height */ // #define WINHEIGHT 720 /* window height */
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1080 /* window height */
// #define WINWIDTH 2560 /* window width */
// #define WINHEIGHT 1440 /* window height */
#define XMIN -2.0 #define XMIN -2.0
#define XMAX 2.0 /* x interval */ #define XMAX 2.0 /* x interval */
@@ -59,7 +65,7 @@
#define NGOLDENSPIRAL 2000 /* max number of points for C_GOLDEN_SPIRAL arrandement */ #define NGOLDENSPIRAL 2000 /* max number of points for C_GOLDEN_SPIRAL arrandement */
#define SDEPTH 1 /* Sierpinski gastket depth */ #define SDEPTH 1 /* Sierpinski gastket depth */
#define LAMBDA 0.3 /* parameter controlling the dimensions of domain */ #define LAMBDA 0.3 /* parameter controlling the dimensions of domain - with 0.5 @1440p it cut out top-bottom borders. 0.4 is @limit */
// #define LAMBDA 1.124950941 /* sin(36°)/sin(31.5°) for 5-star shape with 45° angles */ // #define LAMBDA 1.124950941 /* sin(36°)/sin(31.5°) for 5-star shape with 45° angles */
// #define LAMBDA 1.445124904 /* sin(36°)/sin(24°) for 5-star shape with 60° angles */ // #define LAMBDA 1.445124904 /* sin(36°)/sin(24°) for 5-star shape with 60° angles */
// #define LAMBDA 3.75738973 /* sin(36°)/sin(9°) for 5-star shape with 90° angles */ // #define LAMBDA 3.75738973 /* sin(36°)/sin(9°) for 5-star shape with 90° angles */
@@ -104,17 +110,16 @@
#define NCOLORS 14 /* number of colors */ #define NCOLORS 14 /* number of colors */
#define COLORSHIFT 3 /* hue of initial color */ #define COLORSHIFT 3 /* hue of initial color */
#define RAINBOW_COLOR 0 /* set to 1 to use different colors for all particles */ #define RAINBOW_COLOR 0 /* set to 1 to use different colors for all particles */
#define NSEG 100 /* number of segments of boundary */ #define NSEG 150 /* number of segments of boundary */
#define BILLIARD_WIDTH 4 /* width of billiard */ #define BILLIARD_WIDTH 4 /* width of billiard */
#define FRONT_WIDTH 4 /* width of wave front */ #define FRONT_WIDTH 4 /* width of wave front */
#define BLACK 0 /* set to 1 for black background */ #define BLACK 1 /* set to 1 for black background */
#define COLOR_OUTSIDE 0 /* set to 1 for colored outside */ #define COLOR_OUTSIDE 1 /* set to 1 for colored outside */
#define OUTER_COLOR 300.0 /* color outside billiard */ #define OUTER_COLOR 300.0 /* color outside billiard */
#define PAINT_INT 0 /* set to 1 to paint interior in other color (for polygon) */ #define PAINT_INT 0 /* set to 1 to paint interior in other color (for polygon) */
#define PAINT_EXT 1 /* set to 1 to paint exterior of billiard */ #define PAINT_EXT 1 /* set to 1 to paint exterior of billiard */
#define PAUSE 1000 /* number of frames after which to pause */ #define PAUSE 1000 /* number of frames after which to pause */
#define PSLEEP 1 /* sleep time during pause */ #define PSLEEP 1 /* sleep time during pause */
#define SLEEP1 1 /* initial sleeping time */ #define SLEEP1 1 /* initial sleeping time */
@@ -125,7 +130,6 @@
#define DPI 6.283185307 #define DPI 6.283185307
#define PID 1.570796327 #define PID 1.570796327
#include "global_particles.c" #include "global_particles.c"
#include "sub_part_billiard.c" #include "sub_part_billiard.c"
@@ -196,8 +200,6 @@ void init_partial_drop_config(int i1, int i2, double x0, double y0, double angle
} }
} }
int resample(int color[NPARTMAX], double *configs[NPARTMAX]) int resample(int color[NPARTMAX], double *configs[NPARTMAX])
/* add particles where the front is stretched too thin */ /* add particles where the front is stretched too thin */
{ {

View File

@@ -30,10 +30,13 @@
#include <sys/types.h> #include <sys/types.h>
#include <tiffio.h> /* Sam Leffler's libtiff library. */ #include <tiffio.h> /* Sam Leffler's libtiff library. */
#define MOVIE 0 /* set to 1 to generate movie */ #define MOVIE 1 /* set to 1 to generate movie */
#define WINWIDTH 1280 /* window width */ // #define WINWIDTH 1280 /* window width */
#define WINHEIGHT 720 /* window height */ // #define WINHEIGHT 720 /* window height */
#define WINWIDTH 1920 /* window width */
#define WINHEIGHT 1080 /* window height */
#define XMIN -2.0 #define XMIN -2.0
#define XMAX 2.0 /* x interval */ #define XMAX 2.0 /* x interval */
@@ -87,10 +90,10 @@
#define PRINT_PARTICLE_NUMBER 0 /* set to 1 to print number of particles */ #define PRINT_PARTICLE_NUMBER 0 /* set to 1 to print number of particles */
#define TEST_ACTIVE 1 /* set to 1 to test whether particle is in billiard */ #define TEST_ACTIVE 1 /* set to 1 to test whether particle is in billiard */
#define NSTEPS 1000 /* number of frames of movie */ #define NSTEPS 5000 /* number of frames of movie */
#define TIME 1500 /* time between movie frames, for fluidity of real-time simulation */ #define TIME 400 /* time between movie frames, for fluidity of real-time simulation */
// #define DPHI 0.00001 /* integration step */ // #define DPHI 0.00001 /* integration step */
#define DPHI 0.000005 /* integration step */ #define DPHI 0.00005 /* integration step */
#define NVID 150 /* number of iterations between images displayed on screen */ #define NVID 150 /* number of iterations between images displayed on screen */
/* Decreasing TIME accelerates the animation and the movie */ /* Decreasing TIME accelerates the animation and the movie */

View File

@@ -109,6 +109,7 @@ int writetiff(char *filename, char *description, int x, int y, int width, int he
TIFFSetField(file, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(file, TIFFTAG_ROWSPERSTRIP, 1);
TIFFSetField(file, TIFFTAG_IMAGEDESCRIPTION, description); TIFFSetField(file, TIFFTAG_IMAGEDESCRIPTION, description);
p = image; p = image;
for (i = height - 1; i >= 0; i--) for (i = height - 1; i >= 0; i--)
{ {
// if (TIFFWriteScanline(file, p, height - i - 1, 0) < 0) // if (TIFFWriteScanline(file, p, height - i - 1, 0) < 0)
@@ -120,11 +121,11 @@ int writetiff(char *filename, char *description, int x, int y, int width, int he
} }
p += width * sizeof(GLubyte) * 3; p += width * sizeof(GLubyte) * 3;
} }
free(image); /* prenvents RAM consumption*/
TIFFClose(file); TIFFClose(file);
return 0; return 0;
} }
void init() /* initialisation of window */ void init() /* initialisation of window */
{ {
glLineWidth(3); glLineWidth(3);
@@ -135,8 +136,6 @@ void init() /* initialisation of window */
glOrtho(XMIN, XMAX, YMIN, YMAX , -1.0, 1.0); glOrtho(XMIN, XMAX, YMIN, YMAX , -1.0, 1.0);
} }
void rgb_color_scheme(int i, double rgb[3]) /* color scheme */ void rgb_color_scheme(int i, double rgb[3]) /* color scheme */
{ {
double hue, y, r; double hue, y, r;
@@ -180,7 +179,6 @@ void blank()
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
void save_frame() void save_frame()
{ {
static int counter = 0; static int counter = 0;
@@ -193,12 +191,16 @@ void save_frame()
sprintf(strstr(n2,"."), format, counter); sprintf(strstr(n2,"."), format, counter);
strcat(n2, ".tif"); strcat(n2, ".tif");
printf(" saving frame %s \n",n2); printf(" saving frame %s \n",n2);
writetiff(n2, "Billiard in an ellipse", 0, 0,
WINWIDTH, WINHEIGHT, COMPRESSION_LZW);
// choose one of the following according to the comment beside.
writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-40, COMPRESSION_LZW); /* to use with 1080p in drop_billiard.c- probably the best because it's
// generating 1080p image, lighter, and then cropping those 40 pixels to
// avoid the strange band*/
// writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-50, COMPRESSION_LZW); // works for 1080p -> "-50px" band!!!
// writetiff(n2, "Billiard in an ellipse", 0, 0, 1920, 1080-40, COMPRESSION_LZW); //another perfect 1080p from 1440p in setup
// writetiff(n2, "Billiard in an ellipse", -WINWIDTH/8+320, -WINHEIGHT/8+180, WINWIDTH-640, WINHEIGHT-400, COMPRESSION_LZW); // perfect 1040p from 1440p in setup
} }
void write_text_fixedwidth( double x, double y, char *st) void write_text_fixedwidth( double x, double y, char *st)
{ {
int l, i; int l, i;