| 270 | } |
| 271 | |
| 272 | void ruler_window() { |
| 273 | static pose_t window_pose = pose_t{{0, 0, 0.5f}, quat_identity}; |
| 274 | ui_handle_begin("Ruler", window_pose, |
| 275 | bounds_t{vec3_zero, vec3{30*cm2m, 4*cm2m, 1*cm2m}}, |
| 276 | true, ui_move_exact); |
| 277 | color32 color = color_to_32(color_hsv(0.6f, 0.5f, 1, 1)); |
| 278 | text_add_at("Centimeters", |
| 279 | matrix_trs(vec3{14.5f*cm2m, -1.5f*cm2m, -0.6f*cm2m}, |
| 280 | quat_identity, vec3{0.3f, 0.3f, 0.3f}), |
| 281 | 0, text_align_bottom_left); |
| 282 | for (int d = 0; d <= 60; d++) { |
| 283 | float x = d / 2.0f; |
| 284 | float size = (d % 2 == 0) ? 1.0f : 0.15f; |
| 285 | line_add(vec3{(15 - x)*cm2m, 2*cm2m, -0.6f*cm2m}, |
| 286 | vec3{(15 - x)*cm2m, (2 - size)*cm2m, -0.6f*cm2m}, |
| 287 | color, color, 0.5f*mm2m); |
| 288 | |
| 289 | if (d % 2 == 0 && d / 2 != 30) { |
| 290 | text_add_at(std::to_string(d / 2).c_str(), |
| 291 | matrix_trs(vec3{(15 - x - 0.1f)*cm2m, |
| 292 | (2 - size)*cm2m, -0.6f*cm2m}, |
| 293 | quat_identity, vec3{0.2f, 0.2f, 0.2f}), |
| 294 | 0, text_align_bottom_left); |
| 295 | } |
| 296 | } |
| 297 | ui_handle_end(); |
| 298 | } |
no test coverage detected