Mark Fisher
11/18/2019, 5:35 PMimageview(model.cardUrl) {
x = 0.0
y = 0.0
}.also {
// ensure we scale from 0,0
val scaleBy = model.scale.value
val scale = Scale(scaleBy, scaleBy, 0.0, 0.0)
it.transforms.setAll(scale)
}
but this is only changing on model.cardUrl
, and doesn't update when I change the scale value.
How can I use the model's scale value so it affects the scale of the drawn image?
When I update it, the image doesn't change size.
Note: I found I had to use an also
to scale, as the scaleX/Y
values in the imageview closure scale from the middle of the image and I couldn't work out how to do it from 0,0Bogdan
11/18/2019, 7:34 PMBogdan
11/18/2019, 7:36 PMbut this is only changing on model.cardUrl, and doesn't update when I change the scale value.
- you immediately change the scale, it will not change after the application starts (show view)Bogdan
11/18/2019, 7:49 PMMark Fisher
11/18/2019, 7:50 PMalso
. I tried
imageview() {
scaleX = 1.2
}
doesn't work, because I can't set the pivot point. Instead it scales the image around the centre, so shifts from its positionBogdan
11/18/2019, 7:52 PMBogdan
11/18/2019, 7:52 PMimageview() {
transforms.setAll(scale)
}
Mark Fisher
11/18/2019, 7:53 PMBogdan
11/18/2019, 7:54 PMImageView
or the image itself?Mark Fisher
11/18/2019, 7:55 PMMark Fisher
11/18/2019, 7:55 PMMark Fisher
11/18/2019, 7:56 PMBogdan
11/18/2019, 7:56 PMMark Fisher
11/18/2019, 7:57 PMBogdan
11/18/2019, 7:58 PMBogdan
11/18/2019, 7:59 PMMark Fisher
11/18/2019, 8:03 PMfun decreaseCardScale() {
model.scale.value -= 0.1
model.commit()
println("model: ${model.scale}")
}
Mark Fisher
11/18/2019, 8:05 PMMark Fisher
11/18/2019, 8:07 PMBogdan
11/18/2019, 8:11 PMclass Foo : View() {
val cardDataModel: CardDataModel by inject()
val urlProperty = stringProperty()
override val root = stackpane {
imageview(urlProperty) {
cardDataModel.scale.addListener { ob, old, new ->
println(new)
}
}
}
}
Bogdan
11/18/2019, 8:13 PMitemProperty
Bogdan
11/18/2019, 8:16 PMfun decreaseCardScale() {
cardDataModel.scale.value -= 0.1
cardDataModel.commit {
imageview.transforms.add(scale)
}
println("model: ${cardDataModel.scale}")
}
Mark Fisher
11/18/2019, 8:18 PMBogdan
11/18/2019, 8:20 PMimageview.transforms.add (scale)
, adds scaling (transformation), maybe you need imageview.scale ()
Bogdan
11/18/2019, 8:21 PMdo I need to save it during the creation of the view?
- yesMark Fisher
11/18/2019, 8:23 PMMark Fisher
11/18/2019, 8:24 PM