Konva.js How can I resize the image with fixed position? - konvajs

I'm trying to resize image with Transformer.
The problem lies that when the image is resized, the image is not fixed and moves as much as it is reduced in that direction.
For these reasons, I removed offset offsetX={image ? image.width / 2 : 0} offsetY={image ? image.height / 2 : 0} in Image tag then now the image is dropped based on the left side Transformer's first point.
codesandbox here: https://codesandbox.io/embed/romantic-moon-d9cer?fontsize=14&hidenavigation=1&theme=dark
any and all help is greatly appreciated.

Related

Point selection in pictures with custom scale

I try to analyze images with Fiji. Therefore I first “calibrate” the scale with set scale run(“Set Scale…”, “distance=52.6 known=30 pixel=1 unit=no global”); and then make a rectangle as seen in the picture: Pic 1. Then I execute a measurement with run(“Measure”); and try to make a point at the centre of the rectangle with makePoint(XPos, YPos, “small yellow hybrid”); as shown here: Pic 2.
XPos and YPos refer to the measured center coordinates of the rectangle. However the point is totally misplaced. I saw that the point is placed based on the pixels in the brackets and not based on my scale as seen in the second picture. Does anyone understand this behaviour, and how to help it?
Full Code:
run("Set Measurements...", "area centroid fit display redirect=None decimal=3");
run("Measure");
XPos=getResult("X", nResults-1);
YPos=getResult("Y", nResults-1);
print("Point placed at X "+XPos+" and Y "+YPos+".");
makePoint(XPos, YPos, "small yellow hybrid");
Would be happy if you could help me.
Best Max
Answer from biovoxxel on forum.image.sc
You can try the following after running the measurement. waitForUser("make a rectangular selection"); getSelectionBounds(x, y, width, height); makePoint(x+width/2, y+height/2); This is independent of the Results table and should produce the correct point position.

Offset two child-charts within a VictoryChart

I have a boxplot and a scatterplot within a VictoryChart and want them shifted a number of pixels in the non-domain axis.
My current code and resulting chart are here: https://codesandbox.io/s/beautiful-violet-opclp?file=/index.js
Now I want the red triangle to be placed a bit higher, so about 15 pixels in the y-direction upwards. I tried padding, domainPadding, dx, dy, but nothing works really.
Any hints are appreciated!
By creating a custom point, the actual position can be set. See https://codesandbox.io/s/focused-lederberg-i8ddx?file=/index.js

Make an image in Kivy exactly the same size as the widget bounding box

I'm having trouble in Kivy setting an image size. I want to keep the aspect ratio fixed but I also want to position things precisely over the top of the image.
To do this, I make a RelativeLayout that has the same size and position as the image. However, when I check the size of the layout, it is always slightly larger than the displayed image. Making precise alignment very difficult. The wiki mentions something like this:
By default, the image is centered and fits inside the widget bounding box. If you don’t want that, you can set allow_stretch to True and keep_ratio to False.
They also include code if you want to make the image slightly larger than the containing widget:
<-FullImage>:
canvas:
Color:
rgb: (1, 1, 1)
Rectangle:
texture: self.texture
size: self.width + 20, self.height + 20
pos: self.x - 10, self.y - 10
But nothing about making them exactly the same size!? Surely I should be able to dictate the containing widgets size so the aspect ratio etc. is exactly as required.
I have tried many things but whatever I try, I cannot get the outside edges of the displayed image and a layout to coincide.
Does anyone have any experience with this?
Apologies, I have discovered the problem, the images had a transparent border that I wasn't aware of (the images were passed on to me from elsewhere) I have removed this and it has solved the problem.

jassor Increase the width and height of the nested slider

I have downloaded the jassor. The nested slider is the perfect solution for our requirement. But the problem is client need full size images in the slider (90 % height, 100% width of the window). How the size can be changed ?
Please change the size of 'outer container' and 'slides' container.
Btw, jssor slider will always keep aspect ratio while scale.
Reference: http://www.jssor.com/development/tip-arrange-layout-adjust-size.html

Repositioning images on FormResize proportionally

I have a Delphi form with TImages on it. Actually, it's a "fake" desktop with "icons" (the TImages).
When the user resizes the form (scales it or maximizes it, for example) the icons on the form should align proportionally.
Right now, I'm doing something like this with the images:
ImageX.Left:=Round(ImageX.Left * (Width / OldWidth));
ImageX.Top:=Round(ImageX.Top * (Height / OldHeight));
Now this is OK, as long as I start to make the maximized form smaller.
In that case the rightmost images are cut in part by the form's border (they're off the form's client area).
If I reposition these images to fit the client area, then the position of the icons get distorted upon scaling back to maximum size.
Any ideas for a better algorithm/fix?
Thanks!
First of all, you can't have a correctly scaled desktop when you only move the images, and don't scale them as well. You can do slightly better by moving the midpoints of your images, not their top left corner. It still won't be perfect, but it will work better. Of course, now the images will be cropped on all four sides, not just bottom and right, but at least it will be symmetrical :-)
Second, you will get accumulative rounding errors since you constantly override the "original" values (ImageX's top and left coordinate). You'd be better off having the original values stored in some sort of collection or array, and setting the new position based on the original value, rather than the previous value.
Something like this:
ImageX.Left:=Round(ImageX_OriginalLeft * (Width / Original_Width));

Resources