working types and random
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
TARGET ?= margen
|
TARGET ?= margen
|
||||||
INSTALL_DIR ?= $(HOME)/.local/bin
|
INSTALL_DIR ?= $(HOME)/.local/bin
|
||||||
TEST_ARGS ?= -w=100 -h=100
|
TEST_ARGS ?= -w=100
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
@@ -9,7 +9,7 @@ clean:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
@mkdir -p build
|
@mkdir -p build
|
||||||
gcc -Wall src/*.c src/*.h -o build/$(TARGET)
|
gcc -Wall src/*.c src/*.h -lm -o build/$(TARGET)
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: build
|
install: build
|
||||||
|
|||||||
+112
-86
@@ -1,16 +1,18 @@
|
|||||||
#include "args.h"
|
#include "args.h"
|
||||||
|
#include "rand.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
void print_help(int status_code)
|
void print_help(int status_code) {
|
||||||
{
|
|
||||||
puts("usage: margen "
|
puts("usage: margen "
|
||||||
"[--help] "
|
"[--help] "
|
||||||
"[-q] "
|
"[-q] "
|
||||||
"[-w=WIDTH] "
|
"[-w=WIDTH] "
|
||||||
"[-h=HEIGHT] "
|
"[-h=HEIGHT] "
|
||||||
"[-o=PATH] "
|
"[-o=PATH] "
|
||||||
|
"[--seed=SEED]"
|
||||||
"[-p=PIXEL_SIZE] "
|
"[-p=PIXEL_SIZE] "
|
||||||
"[-s=SLOPE] "
|
"[-s=SLOPE] "
|
||||||
"[-c=R,G,B] "
|
"[-c=R,G,B] "
|
||||||
@@ -22,6 +24,7 @@ void print_help(int status_code)
|
|||||||
" -w, --width image width (default: 1920)\n"
|
" -w, --width image width (default: 1920)\n"
|
||||||
" -h, --height image height (default: 1080)\n"
|
" -h, --height image height (default: 1080)\n"
|
||||||
" -o, --output output file (default: output.bmp)\n"
|
" -o, --output output file (default: output.bmp)\n"
|
||||||
|
" -seed random seed (default: time based)\n"
|
||||||
" -p, --pixel pixel size (default: random)\n"
|
" -p, --pixel pixel size (default: random)\n"
|
||||||
" -s, --slope slope [0-255] (default: random)\n"
|
" -s, --slope slope [0-255] (default: random)\n"
|
||||||
" -c, --color base color [0-255,0-255,0-255] (default: random)\n"
|
" -c, --color base color [0-255,0-255,0-255] (default: random)\n"
|
||||||
@@ -30,20 +33,15 @@ void print_help(int status_code)
|
|||||||
exit(status_code);
|
exit(status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalid_arg(char *arg)
|
void invalid_arg(char *arg) {
|
||||||
{
|
|
||||||
fprintf(stderr, "invalid argument: '%s'\n\n", arg);
|
fprintf(stderr, "invalid argument: '%s'\n\n", arg);
|
||||||
print_help(1);
|
print_help(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalid_value(char *arg, char *subarg, char *value)
|
void invalid_value(char *arg, char *subarg, char *value) {
|
||||||
{
|
if (subarg == NULL) {
|
||||||
if (subarg == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "invalid value for argument '%s': '%s'\n\n", arg, value);
|
fprintf(stderr, "invalid value for argument '%s': '%s'\n\n", arg, value);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "invalid value for argument '%s' %s: '%s'\n\n", arg, subarg,
|
fprintf(stderr, "invalid value for argument '%s' %s: '%s'\n\n", arg, subarg,
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
@@ -52,129 +50,157 @@ void invalid_value(char *arg, char *subarg, char *value)
|
|||||||
|
|
||||||
bool is_arg(char *arg, char *ref) { return strcoll(arg, ref) == 0; }
|
bool is_arg(char *arg, char *ref) { return strcoll(arg, ref) == 0; }
|
||||||
|
|
||||||
char *split_arg_value(char *arg)
|
char *split_arg_value(char *arg) {
|
||||||
{
|
|
||||||
strtok(arg, "=");
|
strtok(arg, "=");
|
||||||
return strtok(NULL, "=");
|
return strtok(NULL, "=");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_digit(char c) { return c >= '0' && c <= '9'; }
|
bool is_digit(char c) { return c >= '0' && c <= '9'; }
|
||||||
|
|
||||||
bool is_number(char *value)
|
bool is_number(char *value, char *max) {
|
||||||
{
|
if (value == NULL) {
|
||||||
if (value == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
unsigned long value_len = strlen(value);
|
unsigned long value_len = strlen(value);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < value_len; i++)
|
for (i = 0; i < value_len; i++) {
|
||||||
{
|
if (!is_digit(value[i])) {
|
||||||
if (!is_digit(value[i]))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return strcmp(value, max) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long parse_number(char *arg, char *value)
|
unsigned char parse_char(char *arg, char *value) {
|
||||||
{
|
if (!is_number(value, "255")) {
|
||||||
if (!is_number(value))
|
|
||||||
{
|
|
||||||
invalid_value(arg, NULL, value);
|
invalid_value(arg, NULL, value);
|
||||||
}
|
}
|
||||||
return atol(value);
|
return (char)atoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_color(char *arg, char *value, unsigned char color[3])
|
unsigned short parse_ushort(char *arg, char *value) {
|
||||||
{
|
if (!is_number(value, "65535")) {
|
||||||
|
invalid_value(arg, NULL, value);
|
||||||
|
}
|
||||||
|
return (unsigned short)atoi(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short parse_ulong(char *arg, char *value) {
|
||||||
|
if (!is_number(value, "18446744073709551615")) {
|
||||||
|
invalid_value(arg, NULL, value);
|
||||||
|
}
|
||||||
|
return (unsigned long)atoll(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_color(char *arg, char *value, unsigned char color[3]) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
tmp = strtok(value, ",");
|
tmp = strtok(value, ",");
|
||||||
if (!is_number(tmp))
|
if (!is_number(tmp, "255")) {
|
||||||
{
|
|
||||||
invalid_value(arg, "(R)", tmp);
|
invalid_value(arg, "(R)", tmp);
|
||||||
}
|
}
|
||||||
color[0] = (unsigned char)atoi(tmp);
|
color[0] = (char)atoi(tmp);
|
||||||
tmp = strtok(NULL, ",");
|
tmp = strtok(NULL, ",");
|
||||||
if (!is_number(tmp))
|
if (!is_number(tmp, "255")) {
|
||||||
{
|
|
||||||
invalid_value(arg, "(G)", tmp);
|
invalid_value(arg, "(G)", tmp);
|
||||||
}
|
}
|
||||||
color[1] = (unsigned char)atoi(tmp);
|
color[1] = (char)atoi(tmp);
|
||||||
tmp = strtok(NULL, ",");
|
tmp = strtok(NULL, ",");
|
||||||
if (!is_number(tmp))
|
if (!is_number(tmp, "255")) {
|
||||||
{
|
|
||||||
invalid_value(arg, "(B)", tmp);
|
invalid_value(arg, "(B)", tmp);
|
||||||
}
|
}
|
||||||
color[2] = (unsigned char)atoi(tmp);
|
color[2] = (char)atoi(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters parse_args(int argc, char **argv)
|
parameters parse_args(int argc, char **argv) {
|
||||||
{
|
|
||||||
parameters params;
|
parameters params;
|
||||||
|
|
||||||
params.quiet = false;
|
params.quiet = false;
|
||||||
params.width = 1920;
|
params.seed = (unsigned long)time(NULL);
|
||||||
params.height = 1080;
|
params.width = 0;
|
||||||
|
params.height = 0;
|
||||||
params.file_path = "output.bmp";
|
params.file_path = "output.bmp";
|
||||||
params.size = 1; // TODO random
|
|
||||||
params.slope = 128; // TODO random
|
bool size_set = false;
|
||||||
params.start[0] = 128; // TODO random
|
bool slope_set = false;
|
||||||
params.start[1] = 128; // TODO random
|
bool start_set = false;
|
||||||
params.start[2] = 128; // TODO random
|
bool var_set = false;
|
||||||
params.var[0] = 20; // TODO random
|
|
||||||
params.var[1] = 20; // TODO random
|
|
||||||
params.var[2] = 20; // TODO random
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char *arg;
|
char *arg;
|
||||||
char *value;
|
char *value;
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++) {
|
||||||
{
|
|
||||||
arg = argv[i];
|
arg = argv[i];
|
||||||
value = split_arg_value(arg);
|
value = split_arg_value(arg);
|
||||||
if (is_arg(arg, "--help"))
|
if (is_arg(arg, "--help")) {
|
||||||
{
|
|
||||||
print_help(0);
|
print_help(0);
|
||||||
}
|
} else if (is_arg(arg, "-q") || is_arg(arg, "--quiet")) {
|
||||||
else if (is_arg(arg, "-q") || is_arg(arg, "--quiet"))
|
|
||||||
{
|
|
||||||
params.quiet = true;
|
params.quiet = true;
|
||||||
}
|
} else if (is_arg(arg, "-w") || is_arg(arg, "--width")) {
|
||||||
else if (is_arg(arg, "-w") || is_arg(arg, "--width"))
|
params.width = parse_ushort(arg, value);
|
||||||
{
|
if (params.width == 0) {
|
||||||
params.width = (unsigned long)parse_number(arg, value);
|
invalid_value(arg, NULL, value);
|
||||||
}
|
}
|
||||||
else if (is_arg(arg, "-h") || is_arg(arg, "--height"))
|
if (params.height == 0) {
|
||||||
{
|
params.height = params.width;
|
||||||
params.height = (unsigned long)parse_number(arg, value);
|
}
|
||||||
}
|
} else if (is_arg(arg, "-h") || is_arg(arg, "--height")) {
|
||||||
else if (is_arg(arg, "-o") || is_arg(arg, "--output"))
|
params.height = parse_ushort(arg, value);
|
||||||
{
|
if (params.height == 0) {
|
||||||
|
invalid_value(arg, NULL, value);
|
||||||
|
}
|
||||||
|
if (params.width == 0) {
|
||||||
|
params.width = params.height;
|
||||||
|
}
|
||||||
|
} else if (is_arg(arg, "--seed")) {
|
||||||
|
params.seed = parse_ulong(arg, value);
|
||||||
|
} else if (is_arg(arg, "-o") || is_arg(arg, "--output")) {
|
||||||
params.file_path = value;
|
params.file_path = value;
|
||||||
}
|
} else if (is_arg(arg, "-p") || is_arg(arg, "--pixel")) {
|
||||||
else if (is_arg(arg, "-p") || is_arg(arg, "--pixel"))
|
params.size = parse_ushort(arg, value);
|
||||||
{
|
if (params.size == 0) {
|
||||||
params.size = (unsigned char)parse_number(arg, value);
|
invalid_value(arg, NULL, value);
|
||||||
}
|
}
|
||||||
else if (is_arg(arg, "-s") || is_arg(arg, "--slope"))
|
size_set = true;
|
||||||
{
|
} else if (is_arg(arg, "-s") || is_arg(arg, "--slope")) {
|
||||||
params.size = (unsigned char)parse_number(arg, value);
|
params.slope = parse_char(arg, value);
|
||||||
}
|
slope_set = true;
|
||||||
else if (is_arg(arg, "-c") || is_arg(arg, "--color"))
|
} else if (is_arg(arg, "-c") || is_arg(arg, "--color")) {
|
||||||
{
|
|
||||||
parse_color(arg, value, params.start);
|
parse_color(arg, value, params.start);
|
||||||
}
|
start_set = true;
|
||||||
else if (is_arg(arg, "-v") || is_arg(arg, "--variation"))
|
} else if (is_arg(arg, "-v") || is_arg(arg, "--variation")) {
|
||||||
{
|
parse_color(arg, value, params.var);
|
||||||
parse_color(arg, value, params.start);
|
var_set = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
invalid_arg(arg);
|
invalid_arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.width == 0 && params.height == 0) {
|
||||||
|
params.width = 1920;
|
||||||
|
params.height = 1080;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_seed(params.seed);
|
||||||
|
|
||||||
|
if (!size_set) {
|
||||||
|
params.size = rand_ushort(10) + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!slope_set) {
|
||||||
|
params.slope = rand_uchar(50) + 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!start_set) {
|
||||||
|
params.start[0] = rand_uchar(256);
|
||||||
|
params.start[1] = rand_uchar(256);
|
||||||
|
params.start[2] = rand_uchar(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!var_set) {
|
||||||
|
params.var[0] = rand_uchar(30);
|
||||||
|
params.var[1] = rand_uchar(30);
|
||||||
|
params.var[2] = rand_uchar(30);
|
||||||
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
@@ -4,32 +4,35 @@
|
|||||||
|
|
||||||
#define HEADER_SIZE 54
|
#define HEADER_SIZE 54
|
||||||
|
|
||||||
void write_str(char *buffer, int offset, int size, char *value) {
|
void write_str(unsigned char *buffer, unsigned short offset,
|
||||||
|
unsigned short size, unsigned char *value) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
buffer[offset + i] = value[i];
|
buffer[offset + i] = (unsigned char)value[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_num(char *buffer, int offset, int size, unsigned long value) {
|
void write_num(unsigned char *buffer, unsigned short offset,
|
||||||
|
unsigned short size, unsigned short value) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
buffer[offset + i] = (char)((value >> (8 * i)) & 0xFFu);
|
buffer[offset + i] = (unsigned char)((value >> (8 * i)) & 0xFFu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_nul(char *buffer, int offset, int size) {
|
void write_nul(unsigned char *buffer, unsigned short offset,
|
||||||
|
unsigned short size) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
buffer[offset + i] = 0;
|
buffer[offset + i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *bmp_header(unsigned long width, unsigned long height,
|
unsigned char *bmp_header(unsigned short width, unsigned short height,
|
||||||
unsigned int color_depth) {
|
unsigned char color_depth) {
|
||||||
char *output = (char *)malloc(HEADER_SIZE);
|
unsigned char *output = (unsigned char *)malloc(HEADER_SIZE);
|
||||||
|
|
||||||
write_str(output, 0x00, 0x02, "BM"); // 0x00(2) BM
|
write_str(output, 0x00, 0x02, (unsigned char *)"BM"); // 0x00(2) BM
|
||||||
write_num(output, 0x02, 0x04,
|
write_num(output, 0x02, 0x04,
|
||||||
HEADER_SIZE + width * height * color_depth); // 0x02(4) file size
|
HEADER_SIZE + width * height * color_depth); // 0x02(4) file size
|
||||||
write_nul(output, 0x06, 0x04); // 0x06(4) application reserved
|
write_nul(output, 0x06, 0x04); // 0x06(4) application reserved
|
||||||
@@ -50,34 +53,34 @@ char *bmp_header(unsigned long width, unsigned long height,
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long bmp_data_line_length(unsigned long width,
|
unsigned short bmp_data_line_length(unsigned short width,
|
||||||
unsigned int color_depth) {
|
unsigned char color_depth) {
|
||||||
unsigned long line_offset = (width * color_depth) % 4;
|
unsigned short line_offset = (width * color_depth) % 4;
|
||||||
unsigned long line_padding = line_offset > 0 ? 4 - line_offset : 0;
|
unsigned short line_padding = line_offset > 0 ? 4 - line_offset : 0;
|
||||||
return width * color_depth + line_padding;
|
return width * color_depth + line_padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bmp_data_line(char *buffer, unsigned long width, unsigned int color_depth,
|
void bmp_data_line(unsigned char *buffer, unsigned short width,
|
||||||
char *data) {
|
unsigned char color_depth, unsigned char *data) {
|
||||||
unsigned long line_offset = (width * color_depth) % 4;
|
unsigned short line_offset = (width * color_depth) % 4;
|
||||||
unsigned long line_padding = line_offset > 0 ? 4 - line_offset : 0;
|
unsigned short line_padding = line_offset > 0 ? 4 - line_offset : 0;
|
||||||
write_str(buffer, 0, width * color_depth, data);
|
write_str(buffer, 0, width * color_depth, data);
|
||||||
if (line_padding > 0) {
|
if (line_padding > 0) {
|
||||||
write_nul(buffer, width * color_depth, line_padding);
|
write_nul(buffer, width * color_depth, line_padding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bmp_generate(unsigned long width, unsigned long height,
|
void bmp_generate(unsigned short width, unsigned short height,
|
||||||
unsigned int color_depth, char *file_path,
|
unsigned char color_depth, char *file_path,
|
||||||
line_fn generate_line) {
|
line_fn generate_line) {
|
||||||
FILE *fptr;
|
FILE *fptr;
|
||||||
fptr = fopen(file_path, "w");
|
fptr = fopen(file_path, "w");
|
||||||
char *header = bmp_header(width, height, color_depth);
|
unsigned char *header = bmp_header(width, height, color_depth);
|
||||||
fwrite(header, HEADER_SIZE, 1, fptr);
|
fwrite(header, HEADER_SIZE, 1, fptr);
|
||||||
free(header);
|
free(header);
|
||||||
int y;
|
unsigned short y;
|
||||||
char *data_buffer = malloc(width * color_depth);
|
unsigned char *data_buffer = malloc(width * color_depth);
|
||||||
char *line_buffer = malloc(bmp_data_line_length(width, color_depth));
|
unsigned char *line_buffer = malloc(bmp_data_line_length(width, color_depth));
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
generate_line(height - y - 1, data_buffer);
|
generate_line(height - y - 1, data_buffer);
|
||||||
bmp_data_line(line_buffer, width, color_depth, data_buffer);
|
bmp_data_line(line_buffer, width, color_depth, data_buffer);
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
#ifndef BMP_H
|
#ifndef BMP_H
|
||||||
#define BMP_H
|
#define BMP_H
|
||||||
|
|
||||||
void bmp_generate(unsigned long width, unsigned long height,
|
void bmp_generate(unsigned short width, unsigned short height,
|
||||||
unsigned int color_depth, char *file_path,
|
unsigned char color_depth, char *file_path,
|
||||||
line_fn generate_line);
|
line_fn generate_line);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+16
-1
@@ -1,17 +1,32 @@
|
|||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "bmp.h"
|
#include "bmp.h"
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define COLOR_DEPTH 3
|
#define COLOR_DEPTH 3
|
||||||
|
|
||||||
parameters global_params;
|
parameters global_params;
|
||||||
|
|
||||||
void generate_line(unsigned long y, char *data_buffer) {
|
void generate_line(unsigned short y, unsigned char *data_buffer) {
|
||||||
memset(data_buffer, y, global_params.width * COLOR_DEPTH);
|
memset(data_buffer, y, global_params.width * COLOR_DEPTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_parameters(parameters params) {
|
||||||
|
if (!params.quiet) {
|
||||||
|
printf("output %s\n", params.file_path);
|
||||||
|
printf("seed %ld\n", params.seed);
|
||||||
|
printf("width %d\n", params.width);
|
||||||
|
printf("height %d\n", params.height);
|
||||||
|
printf("pixel %d\n", params.size);
|
||||||
|
printf("color %u,%u,%u\n", params.start[0], params.start[1],
|
||||||
|
params.start[2]);
|
||||||
|
printf("var. %u,%u,%u\n", params.var[0], params.var[1], params.var[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int generate(parameters params) {
|
int generate(parameters params) {
|
||||||
global_params = params;
|
global_params = params;
|
||||||
|
debug_parameters(params);
|
||||||
bmp_generate(params.width, params.height, COLOR_DEPTH, params.file_path,
|
bmp_generate(params.width, params.height, COLOR_DEPTH, params.file_path,
|
||||||
generate_line);
|
generate_line);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
float seed;
|
||||||
|
|
||||||
|
void set_seed(unsigned long new_seed) { seed = (float)(new_seed % 1000000); }
|
||||||
|
|
||||||
|
float rand(float seed) {
|
||||||
|
float v = powf(fabs(seed), 6. / 7.);
|
||||||
|
v *= sinf(v) + 1.;
|
||||||
|
return v - floorf(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rand_uchar(unsigned int max) {
|
||||||
|
return (unsigned char)(rand(seed++) * max);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short rand_ushort(unsigned int max) {
|
||||||
|
return (unsigned short)(rand(seed++) * max);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
#ifndef RAND_H
|
#ifndef RAND_H
|
||||||
#define RAND_H
|
#define RAND_H
|
||||||
|
|
||||||
|
void set_seed(float new_seed);
|
||||||
|
unsigned char rand_uchar(unsigned int max);
|
||||||
|
unsigned short rand_ushort(unsigned int max);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+5
-4
@@ -5,10 +5,11 @@
|
|||||||
|
|
||||||
struct Parameters {
|
struct Parameters {
|
||||||
bool quiet;
|
bool quiet;
|
||||||
unsigned long width;
|
unsigned long seed;
|
||||||
unsigned long height;
|
unsigned short width;
|
||||||
|
unsigned short height;
|
||||||
char *file_path;
|
char *file_path;
|
||||||
unsigned char size;
|
unsigned short size;
|
||||||
unsigned char slope;
|
unsigned char slope;
|
||||||
unsigned char start[3];
|
unsigned char start[3];
|
||||||
unsigned char var[3];
|
unsigned char var[3];
|
||||||
@@ -16,6 +17,6 @@ struct Parameters {
|
|||||||
|
|
||||||
typedef struct Parameters parameters;
|
typedef struct Parameters parameters;
|
||||||
|
|
||||||
typedef void line_fn(unsigned long y, char *data_buffer);
|
typedef void line_fn(unsigned short y, unsigned char *data_buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user