1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
3
4//include_path: ../../../examples/printerdemo/ui/images/
5
6TestCase := Rectangle {
7 img := Image {
8 source: @image-url("cat.jpg");
9 }
10
11 img2 := Image {
12 source: @image-url("cat.jpg");
13 source-clip-x: 20;
14 }
15
16 img3 := Image {
17 source: @image-url("image.slint");
18 }
19
20 out property <image> with-border: @image-url("dog.jpg", nine-slice(12 13 14 15));
21
22 property <length> img_width: img.width;
23 property <length> img_height: img.height;
24 property <bool> test: img2.source-clip-height * 1px == img2.height && img2.source-clip-width * 1px == img2.width &&
25 img2.width/1px == img2.source.width - 20 && img3.source.width == 0 && img3.source.height == 0;
26}
27
28/*
29```cpp
30auto handle = TestCase::create();
31const TestCase &instance = *handle;
32
33assert_eq(instance.get_img_width(), 320.);
34assert_eq(instance.get_img_height(), 480.);
35assert(instance.get_test());
36```
37
38
39```rust
40let instance = TestCase::new().unwrap();
41
42assert_eq!(instance.get_img_width(), 320.);
43assert_eq!(instance.get_img_height(), 480.);
44assert!(instance.get_test());
45```
46
47```js
48var instance = new slint.TestCase();
49
50
51assert.equal(instance.img_width, 320);
52assert.equal(instance.img_height, 480);
53assert(instance.test);
54```
55*/
56