Logo

index : 0x2lib

Library extension for Jai

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/0x2lib.git/html/tests/rectcut.jai blob: 0d43001b89a5a440300e180fd5c6f25d561fd88a [raw] [clear marker]

        
0
1
2
3run :: () -> bool {
4 root := Rectangle.{
5 0.0,
6 0.0,
7 1000.0,
8 1000.0,
9 };
10
11 t := rcut_from_right(*root, 0.5);
12 ass(t, Rectangle.{ 500.0, 0.0, 500.0, 1000.0 });
13
14 t = rcut_from_left(*root, 0.1);
15 ass(t, Rectangle.{ 0, 0, 50, 1000 });
16
17 t = rcut_from_top(*root, 0.8);
18 ass(t, Rectangle.{ 50, 0, 450, 800 });
19
20 t = rcut_from_bottom(*root, 0.34);
21 ass(t, Rectangle.{ 50, 932, 450, 68 });
22
23 return true;
24}
25
26
27#scope_file
28
29
30Rectangle :: struct {
31 x: float; /** top-left corner position x */
32 y: float; /** top-left corner position y */
33 width: float;
34 height: float;
35}
36
37
38ass :: (a: Rectangle, b: Rectangle, loc := #caller_location) #expand {
39 ok := true;
40 ok &= a.x == b.x;
41 ok &= a.y == b.y;
42 ok &= a.width == b.width;
43 ok &= a.height == b.height;
44 if !ok then #insert,scope() ASS_CODE;
45}
46
47
48#import "Basic";
49#import "Print_Vars";
50#import,file "../0x2_Rectcut.jai";
51
52#load "assertion.jai";
53
54
55
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit