From 1fb0614af4d18ed223ef8399a33bc1b2473515e4 Mon Sep 17 00:00:00 2001 From: det-fys Date: Mon, 30 Dec 2024 19:09:04 +0100 Subject: [PATCH] komentare k ps_graph --- ps_graph.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ps_graph.c b/ps_graph.c index 2ef6cb0..801f75e 100644 --- a/ps_graph.c +++ b/ps_graph.c @@ -109,6 +109,7 @@ static void generate_grid(FILE *file, const struct graph_range *range) { } + /* popisky os */ set_font(file, FONT, FONT_SIZE_LABEL); generate_text_align(file, -HALF_GRAPH_SIZE + Y_LABEL_OFFSET_X, Y_LABEL_OFFSET_Y, ALIGN_RIGHT, "y"); generate_text_align(file, X_LABEL_OFFSET_X, -HALF_GRAPH_SIZE + X_LABEL_OFFSET_Y, ALIGN_CENTER, "x"); @@ -131,6 +132,7 @@ static void generate_function(FILE *file, const struct expr_node *node, const st x = range->xmin + (range->xmax - range->xmin) * (double)i / (double)FUNCTION_SEGMENTS; + /* funkce není definována */ if (node_eval(node, x, &y) != EVAL_OK) { first = 1; continue; @@ -155,8 +157,10 @@ static void generate_function(FILE *file, const struct expr_node *node, const st void ps_generate_graph(FILE *file, const struct expr_node *node, const struct graph_range *range, const char *function) { char buf[TEMP_BUF_SIZE]; + /* posun na střed */ fprintf(file, "%d %d translate\n", GRAPH_CENTER_X, GRAPH_CENTER_Y); + /* hlavička */ if (function) { set_font(file, FONT, FONT_SIZE_HEADER); snprintf(buf, TEMP_BUF_SIZE, "y = %s", function); @@ -165,6 +169,7 @@ void ps_generate_graph(FILE *file, const struct expr_node *node, const struct gr generate_grid(file, range); + /* ořezová oblast pro graf */ fprintf(file, "[] 0 setdash\n" "newpath\n" @@ -178,8 +183,10 @@ void ps_generate_graph(FILE *file, const struct expr_node *node, const struct gr -HALF_GRAPH_SIZE, -HALF_GRAPH_SIZE, GRAPH_SIZE, GRAPH_SIZE, -GRAPH_SIZE ); + /* samotný graf */ generate_function(file, node, range); + /* rámeček */ fprintf(file, "grestore\n" "2 setlinewidth\n"