Files
Panayot Cankov 43659799bc Implement non uniform border corner radiuses and fix blinking image-view radiuses (#4573)
* Image corners were blinking in #4322 and CSS border will now draw non uniform corner radiuses if the border color is uniform

* Implement per-side corner radiuses for iOS

* Update stretch-mode example

* Update matrix-mode example

* Update image resources

* Add clipping for non uniform radii without border width, don't throw for missing image resources in css
2017-07-27 15:36:47 +03:00

57 lines
1.8 KiB
TypeScript

import { Image, Stretch } from "tns-core-modules/ui/image";
import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
import { Color } from "tns-core-modules/color";
import * as imageSource from "tns-core-modules/image-source";
const sources = [
{ src: "up", rotation: 0 },
{ src: "upcw", rotation: -90 },
{ src: "upflip", rotation: 180 },
{ src: "upccw", rotation: 90 }
].map(({ src, rotation }) => ({ src: `res://${src}`, rotation }));
const stretchModes: Stretch[] = ["none", "aspectFill", "aspectFit", "fill"];
export function navigatingTo(args) {
const grid: GridLayout = args.object.getViewById("root");
for (let x = 0; x < 12; x++) {
for (let y = 0; y < 16; y++) {
const image = new Image();
const img = sources[x % 4];
const src = imageSource.fromFileOrResource(img.src);
src.rotationAngle = img.rotation;
image.src = src;
image.stretch = stretchModes[y % 4];
image.row = y;
image.col = x;
grid.addChild(image);
switch(Math.floor(x / 4)) {
case 1:
image.borderWidth = "3";
break;
case 2:
image.borderWidth = "3";
image.borderColor = "blue";
break;
}
switch(Math.floor(y / 4)) {
case 1:
image.borderRadius = "12";
break;
case 2:
image.borderRadius = "6 18 6 18";
break;
case 3:
image.borderWidth = "0 2 4 6";
image.borderRadius = "6 18 6 18";
break;
}
image.backgroundColor = new Color(0x6600FFFF);
}
}
}