Debian Codegraph @

pencil/source/draw/draw_diagram_ornaments.c

raw symbols SCIP
1 /* File: draw_diagram_ornaments.c; Copyright and License: see below */
2
3 #include "draw/draw_diagram_ornaments.h"
4 #include "u8/u8_trace.h"
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <assert.h>
8 #include <math.h>
9
10 void draw_diagram_ornaments_init( draw_diagram_ornaments_t *this_ )
11 {
12 U8_TRACE_BEGIN();
13 U8_TRACE_END();
14 }
15
16 void draw_diagram_ornaments_destroy( draw_diagram_ornaments_t *this_ )
17 {
18 U8_TRACE_BEGIN();
19 U8_TRACE_END();
20 }
21
22 void draw_diagram_ornaments_draw_scale( const draw_diagram_ornaments_t *this_,
23 const geometry_rectangle_t *bounds,
24 const pencil_size_t *pencil_size,
25 cairo_t *cr )
26 {
27 U8_TRACE_BEGIN();
28 assert ( NULL != bounds );
29 assert ( NULL != pencil_size );
30 assert ( NULL != cr );
31 const double left = geometry_rectangle_get_left ( bounds );
32 const double top = geometry_rectangle_get_top ( bounds );
33 const double width = geometry_rectangle_get_width ( bounds );
34 const double height = geometry_rectangle_get_height ( bounds );
35 const double bottom = top + height;
36
37 const unsigned int MAX_STEP = 60;
38 for ( unsigned int step = 0; step <= MAX_STEP; step ++ )
39 {
40 const double x = left + ( step * width ) / MAX_STEP;
41 const double phi = 1.6180339;
42 const double line_top = ( ( step % 5 ) == 0 ) ? top : top + ( height / phi );
43 cairo_move_to ( cr, x, line_top );
44 cairo_line_to ( cr, x, bottom );
45 cairo_stroke (cr);
46 }
47
48 U8_TRACE_END();
49 }
50
51
52 /*
53 Copyright 2026-2026 Andreas Warnke
54 http://www.apache.org/licenses/LICENSE-2.0
55
56 Licensed under the Apache License, Version 2.0 (the "License");
57 you may not use this file except in compliance with the License.
58 You may obtain a copy of the License at
59
60
61 Unless required by applicable law or agreed to in writing, software
62 distributed under the License is distributed on an "AS IS" BASIS,
63 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64 See the License for the specific language governing permissions and
65 limitations under the License.
66 */