Line data Source code
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 0 : void draw_diagram_ornaments_init( draw_diagram_ornaments_t *this_ )
11 : {
12 0 : U8_TRACE_BEGIN();
13 0 : U8_TRACE_END();
14 0 : }
15 :
16 0 : void draw_diagram_ornaments_destroy( draw_diagram_ornaments_t *this_ )
17 : {
18 0 : U8_TRACE_BEGIN();
19 0 : U8_TRACE_END();
20 0 : }
21 :
22 0 : 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 0 : U8_TRACE_BEGIN();
28 0 : assert ( NULL != bounds );
29 0 : assert ( NULL != pencil_size );
30 0 : assert ( NULL != cr );
31 0 : const double left = geometry_rectangle_get_left ( bounds );
32 0 : const double top = geometry_rectangle_get_top ( bounds );
33 0 : const double width = geometry_rectangle_get_width ( bounds );
34 0 : const double height = geometry_rectangle_get_height ( bounds );
35 0 : const double bottom = top + height;
36 :
37 0 : const unsigned int MAX_STEP = 60;
38 0 : for ( unsigned int step = 0; step <= MAX_STEP; step ++ )
39 : {
40 0 : const double x = left + ( step * width ) / MAX_STEP;
41 0 : const double phi = 1.6180339;
42 0 : const double line_top = ( ( step % 5 ) == 0 ) ? top : top + ( height / phi );
43 0 : cairo_move_to ( cr, x, line_top );
44 0 : cairo_line_to ( cr, x, bottom );
45 0 : cairo_stroke (cr);
46 : }
47 :
48 0 : U8_TRACE_END();
49 0 : }
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 : */
|