@@ -10,8 +10,8 @@ EXTEND(EXTENSION: image)
1010
1111IMPORT(path)
1212
13- FUNC TNS: LOAD(STR: img_path){
14- STR: ext = path.EXTNAME(img_path)
13+ FUNC TNS LOAD(STR img_path){
14+ STR ext = path.EXTNAME(img_path)
1515 IF(EQ(ext, "png")){
1616 RETURN(LOAD_PNG(img_path))
1717 } ELSEIF (OR(EQ(ext, "jpg"),EQ(ext, "jpeg"))){
@@ -23,70 +23,70 @@ FUNC TNS: LOAD(STR: img_path){
2323 }
2424}
2525
26- FUNC INT: WIDTH(TNS: img){
26+ FUNC INT WIDTH(TNS img){
2727 RETURN(TLEN(img, 0d1))
2828}
2929
30- FUNC INT: HEIGHT(TNS: img){
30+ FUNC INT HEIGHT(TNS img){
3131 RETURN(TLEN(img, 0d2))
3232}
3333
34- FUNC INT: CHANNELS(TNS: img){
34+ FUNC INT CHANNELS(TNS img){
3535 RETURN(TLEN(img, 0d3))
3636}
3737
38- FUNC TNS: R(TNS: img){
38+ FUNC TNS R(TNS img){
3939 RETURN(img[*, *, 0d1])
4040}
4141
42- FUNC TNS: G(TNS: img){
42+ FUNC TNS G(TNS img){
4343 RETURN(img[*, *, 0d2])
4444}
4545
46- FUNC TNS: B(TNS: img){
46+ FUNC TNS B(TNS img){
4747 RETURN(img[*, *, 0d3])
4848}
4949
50- FUNC TNS: A(TNS: img){
50+ FUNC TNS A(TNS img){
5151 RETURN(img[*, *, 0d4])
5252}
5353
54- FUNC TNS: PIXEL(TNS: img, INT: x, INT: y){
54+ FUNC TNS PIXEL(TNS img, INT x, INT y){
5555 RETURN(img[x, y, *])
5656}
5757
58- FUNC INT: PIXEL_R(TNS: img, INT: x, INT: y){
58+ FUNC INT PIXEL_R(TNS img, INT x, INT y){
5959 RETURN(img[x, y, 0d1])
6060}
6161
62- FUNC INT: PIXEL_G(TNS: img, INT: x, INT: y){
62+ FUNC INT PIXEL_G(TNS img, INT x, INT y){
6363 RETURN(img[x, y, 0d2])
6464}
6565
66- FUNC INT: PIXEL_B(TNS: img, INT: x, INT: y){
66+ FUNC INT PIXEL_B(TNS img, INT x, INT y){
6767 RETURN(img[x, y, 0d3])
6868}
6969
70- FUNC INT: PIXEL_A(TNS: img, INT: x, INT: y){
70+ FUNC INT PIXEL_A(TNS img, INT x, INT y){
7171 RETURN(img[x, y, 0d4])
7272}
7373
74- FUNC TNS: FLIP_V(TNS: img){
74+ FUNC TNS FLIP_V(TNS img){
7575 RETURN(TFLIP(img, 0d1))
7676}
7777
78- FUNC TNS: FLIP_H(TNS: img){
78+ FUNC TNS FLIP_H(TNS img){
7979 RETURN(TFLIP(img, 0d2))
8080}
8181
82- FUNC TNS: INVERT(TNS: img){
83- TNS: return = MSUB(TNS(SHAPE(img), 0xFF), img)
82+ FUNC TNS INVERT(TNS img){
83+ TNS return = MSUB(TNS(SHAPE(img), 0xFF), img)
8484 return[*, *, 0d4] = img[*, *, 0d4] ! Preserve alpha
8585 POP(return)
8686}
8787
88- FUNC TNS: RECT(TNS: img, INT: x, INT: y, INT: width, INT: height, TNS: color, INT: fill, INT: thickness){
89- TNS: pts = [ ^
88+ FUNC TNS RECT(TNS img, INT x, INT y, INT width, INT height, TNS color, INT fill, INT thickness){
89+ TNS pts = [ ^
9090 [x, y], ^
9191 [ADD(x, SUB(width, 0d1)), y], ^
9292 [ADD(x, SUB(width, 0d1)), ADD(y, SUB(height, 0d1))], ^
@@ -96,37 +96,37 @@ FUNC TNS: RECT(TNS: img, INT: x, INT: y, INT: width, INT: height, TNS: color, IN
9696 RETURN(POLYGON(img, pts, color, fill, thickness))
9797}
9898
99- FUNC TNS: RECTANGLE(TNS: img, INT: x, INT: y, INT: width, INT: height, TNS: color, INT: fill, INT: thickness){
99+ FUNC TNS RECTANGLE(TNS img, INT x, INT y, INT width, INT height, TNS color, INT fill, INT thickness){
100100 RETURN(RECT(img, x, y, width, height, color, fill, thickness))
101101}
102102
103- FUNC TNS: FILL_RECT(TNS: img, INT: x, INT: y, INT: width, INT: height, TNS: color){
103+ FUNC TNS FILL_RECT(TNS img, INT x, INT y, INT width, INT height, TNS color){
104104 RETURN(RECT(img, x, y, width, height, color, 0d1, 0d1))
105105}
106106
107- FUNC TNS: FILL_ELLIPSE(TNS: img, TNS: center, INT: rx, INT: ry, TNS: color){
107+ FUNC TNS FILL_ELLIPSE(TNS img, TNS center, INT rx, INT ry, TNS color){
108108 RETURN(ELLIPSE(img, center, rx, ry, color, 0d1, 0d1))
109109}
110110
111- FUNC TNS: SQUARE(TNS: img, INT: x, INT: y, INT: size, TNS: color, INT: fill, INT: thickness){
111+ FUNC TNS SQUARE(TNS img, INT x, INT y, INT size, TNS color, INT fill, INT thickness){
112112 RETURN(RECT(img, x, y, size, size, color, fill, thickness))
113113}
114114
115- FUNC TNS: CIRCLE(TNS: img, TNS: center, INT: radius, TNS: color, INT: fill, INT: thickness){
115+ FUNC TNS CIRCLE(TNS img, TNS center, INT radius, TNS color, INT fill, INT thickness){
116116 RETURN(ELLIPSE(img, center, radius, radius, color, fill, thickness))
117117}
118118
119- FUNC TNS: CROP(TNS: img, TNS: corners){
119+ FUNC TNS CROP(TNS img, TNS corners){
120120 IF(NEQ(SHAPE(corners), [0d4, 0d2])){
121121 THROW("CROP corners must be a 0d4 by 0d2 tensor: [[tl_x, tl_y], [tr_x, tr_y], [bl_x, bl_y], [br_x, br_y]]")
122122 }
123123 RETURN(img[MIN(corners[*, 0d1])-MAX(corners[*, 0d1]), MIN(corners[*, 0d2])-MAX(corners[*, 0d2]), *])
124124}
125125
126- FUNC BOOL: SHOW(TNS: img){
126+ FUNC BOOL SHOW(TNS img){
127127 ! Save the image to the provided path and open it with the system default
128128 ! viewer on Windows. `img_path` is treated as the target file path.
129- STR: img_path = "C:/Windows/Temp/tmp_img.png"
129+ STR img_path = "C:/Windows/Temp/tmp_img.png"
130130 SAVE_PNG(img, img_path, 0d0)
131131 ! ShellExecuteW(hwnd, operation, file, params, dir, showcmd)
132132 ! Use NULL hwnd (0), operation "open", empty params and dir, showcmd=1
0 commit comments