|
5 | 5 | </ActionBar> |
6 | 6 |
|
7 | 7 | <GridLayout rows="*, auto, auto"> |
8 | | - <NSImg backgroundColor="yellow" ref="opacityImg" placeholderImageUri="res://logo" :colorMatrix="colorMatrix" :src="src"> </NSImg> |
9 | | - <StackLayout orientation="horizontal" row="1"> |
10 | | - <Button text="nightVision" row="1" @tap="onSetNightVision"></Button> |
11 | | - <Button text="polaroid" @tap="onSetPolaroid"></Button> |
12 | | - <Button text="grayscale" @tap="onSetGrayscale"></Button> |
13 | | - <Button text="bw" @tap="onSetBW"></Button> |
14 | | - <Button text="clear" @tap="onSetClear"></Button> |
15 | | - </StackLayout> |
16 | | - |
| 8 | + <NSImg backgroundColor="yellow" ref="opacityImg" placeholderImageUri="res://logo" :colorMatrix="colorMatrix" :src="src"> </NSImg> |
| 9 | + <StackLayout orientation="horizontal" row="1"> |
| 10 | + <Button text="nightVision" row="1" @tap="onSetNightVision"></Button> |
| 11 | + <Button text="polaroid" @tap="onSetPolaroid"></Button> |
| 12 | + <Button text="grayscale" @tap="onSetGrayscale"></Button> |
| 13 | + <Button text="bw" @tap="onSetBW"></Button> |
| 14 | + <Button text="clear" @tap="onSetClear"></Button> |
| 15 | + </StackLayout> |
| 16 | + |
17 | 17 | <Button text="change image" row="2" @tap="onChangeImage"></Button> |
18 | 18 | </GridLayout> |
19 | 19 | </Page> |
|
23 | 23 | import { ImageSource } from '@nativescript/core'; |
24 | 24 |
|
25 | 25 | const filters = { |
26 | | - nightVision:[0.1, 0.4, 0, 0, 0, |
27 | | - 0.3, 1, 0.3, 0, 0, |
28 | | - 0, 0.4, 0.1, 0, 0, |
29 | | - 0, 0, 0, 1, 0], |
30 | | - polaroid: [ |
31 | | - 1.438, -0.062, -0.062, 0, 0, |
32 | | - -0.122, 1.378, -0.122, 0, 0, |
33 | | - -0.016, -0.016, 1.483, 0, 0, |
34 | | - 0, 0, 0, 1, 0 |
35 | | - ], |
36 | | - grayscale:[ |
37 | | - .299, 0.587, 0.114, 0, 0, |
38 | | - 0.299, 0.587, 0.114, 0, 0, |
39 | | - 0.299, 0.587, 0.114, 0, 0, |
40 | | - 0, 0, 0, 1, 0 |
41 | | - ], |
42 | | - bw: [1.5, 1.5, 1.5, -1, 0, 1.5, 1.5, 1.5, -1, 0, 1.5, 1.5, 1.5, -1, 0, 0, 0, 0, 1, 0], |
43 | | -
|
44 | | -} |
| 26 | + nightVision: [0.1, 0.4, 0, 0, 0, 0.3, 1, 0.3, 0, 0, 0, 0.4, 0.1, 0, 0, 0, 0, 0, 1, 0], |
| 27 | + polaroid: [1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 0, 1, 0], |
| 28 | + grayscale: [0.299, 0.587, 0.114, 0, 0, 0.299, 0.587, 0.114, 0, 0, 0.299, 0.587, 0.114, 0, 0, 0, 0, 0, 1, 0], |
| 29 | + bw: [1.5, 1.5, 1.5, -1, 0, 1.5, 1.5, 1.5, -1, 0, 1.5, 1.5, 1.5, -1, 0, 0, 0, 0, 1, 0] |
| 30 | +}; |
45 | 31 |
|
46 | 32 | export default { |
47 | | - data: function() { |
| 33 | + data: function () { |
48 | 34 | return { |
49 | | - colorMatrix:filters.nightVision, |
50 | | - src:'~/assets/images/dessert.jpg', |
| 35 | + colorMatrix: filters.nightVision, |
| 36 | + src: '~/assets/images/dessert.jpg' |
51 | 37 | // warning image source native android image will not be released! |
52 | 38 | // imgSource: ImageSource.fromFileSync('~/assets/images/dessert.jpg') |
53 | 39 | }; |
54 | 40 | }, |
55 | 41 | methods: { |
56 | 42 | onSetNightVision(args) { |
57 | | - this.colorMatrix = filters.nightVision |
| 43 | + this.colorMatrix = filters.nightVision; |
58 | 44 | }, |
59 | 45 | onSetPolaroid(args) { |
60 | | - this.colorMatrix = filters.polaroid |
| 46 | + this.colorMatrix = filters.polaroid; |
61 | 47 | }, |
62 | 48 | onSetGrayscale(args) { |
63 | | - this.colorMatrix = filters.grayscale |
| 49 | + this.colorMatrix = filters.grayscale; |
64 | 50 | }, |
65 | 51 | onSetBW(args) { |
66 | | - this.colorMatrix = filters.bw |
| 52 | + this.colorMatrix = filters.bw; |
67 | 53 | }, |
68 | 54 | onSetClear(args) { |
69 | | - this.colorMatrix = null |
| 55 | + this.colorMatrix = null; |
70 | 56 | }, |
71 | | - onChangeImage(){ |
72 | | - this.src= this.src=== '~/assets/images/dessert.jpg' ? '~/assets/images/drink.jpg': '~/assets/images/dessert.jpg'; |
| 57 | + onChangeImage() { |
| 58 | + this.src = this.src === '~/assets/images/dessert.jpg' ? '~/assets/images/drink.jpg' : '~/assets/images/dessert.jpg'; |
73 | 59 | } |
74 | 60 | } |
75 | 61 | }; |
|
0 commit comments