How to change measurement pivot for layouts in jetpack compose? - kotlin

Start point for each layout is 0.0 top left corner. I wanna change start position to get result like that:
Found just Modifier.graphicsLayer { transformOrigin } which can change layout transformation point from center to other side.
Right now just using Modifier.offset - layout center point coordinates but wonder if there are better way to do this.

Related

How to move the colorbar in Folium?

Does anyone know how to move the color bar in a Folium map? It seems to be stuck at the top, but I would like to position it either vertically at the side or on the bottom of the map. I can't see anything in the documentation about this, but there must be a solution...

react-native-reanimated and react-native-gesture-handler X/Y coordinates

I've setup an expo snack here, where you can drag an image and see the X/Y coordinates.
I don't understand why if I drag the image on the top left corner, the coordinates are negative numbers.
You could argue that the position is relative to the starting point. But as you can se in the Cardeditor.js file the cardItems state X and Y are both set to 1.
In my app (not in the example) the user is able to navigate to another screen where the cards is in landscape mode, so I have to reposition the image in the correct spot, for this I need to be sure that the top left corner is always x:0 and y:0.
This issue probably has to do with absolute/relative positioning, but I can't find any source of information on the net.
try to main container position:'relative' and other components position: 'absolute'

Using MapKit, MKMapview how can I orientate the map by aligning two coordinates vertical on the screen

I have two coordinates that represent a portion of a route, and I want to orientate the MKMapView such that the route, polyline is displayed going from the bottom of the screen to the top of the screen.
Currently I first calculate the angle between the two coordinates, and then rotate the map by setting the camera heading, where 90 degrees is facing north and vertically centred on the screen.
Is there perhaps an easier approach, sample code would be great in either Swift or Objective-C.
Currently I first calculate the angle between the two coordinates, and then rotate the map by setting the camera heading, where 90 degrees is facing north and vertically centred on the screen.
You've got the right idea. There's no way to set the map view's heading directly, so setting the camera heading is the right way to go. Be sure to set the map view's rotationEnabled property to YES to get the map view to use the camera's heading, and if you want to always see the map in plan view (i.e. looking straight down), you can set pitchEnabled to NO.

Difficulty finding correct anchor point for rotation transforms

I'm animating a button's position, rotating it around a circle. This creates a UISwitch-like behavior, except it is a lot more fancy. The button rotates, but it ends up off the desired position by about 0.25 radians. I'm trying to figure out where to put the anchor point to make the button rotate in a perfect circle around its origin.
Here's the code that I use to make the button "orbit" with a 120 pixel radius from the original location.
float offsetX=120;
float offsetY=0;
enableDisableButton.layer.anchorPoint =
CGPointMake(offsetX/enableDisableButton.frame.size.width,
offsetY/enableDisableButton.frame.size.height);
I use the following method to do the calculations. Passing an argument of 90 for degrees, I expect to see the button start at a 180˚ position and move to 90˚, still 120 pixels away from its origin
-(CGAffineTransform)calculateLabelPositionFromFixedPointWithOffsetClockwiseInDegrees:(float)degrees
{
float rotation = degrees*(2*M_PI/360);
CGAffineTransform transform24 = CGAffineTransformMakeRotation(rotation);
NSLog(#"rotation: %f", rotation);
return transform24;
}
This little 0.25 radian or so offset means that I need to visually confirm the location of each button and cannot easily adjust its location programmatically. Any help in determining the correct way to rotate the button is appreciated.
I tried other ways to rotate objects. For example, I have an arrow
<--------x, and I would like to rotate this arrow in a circle around x . What is the correct anchor point placement for this operation? Is it [1, 0.5]?
An easier way to do this kind of rotations is to put an object within a symmetric UIView, center it at the desired point of rotation and assign a rotation transform. This works, but requires the view to be twice as big:
Y----x----Y < this rotates Y around center point X without any anchor point adjustments. this is a very useful method to rotate arrows within analog gauges and such.
"An easier way to do this kind of rotations is to put an object within a symmetric UIView, center it at the desired point of rotation and assign a rotation transform." this way is fine.
The anchor point of your enableDisableButton in the example would be
CGPointMake(offsetX/enableDisableButton.frame.size.width, 0)
i.e. not vertically centered in your button. Rotating around the anchor point would result in the button being offset to the top or bottom of the desired position. The transform looks alright, so I think it is just the anchor point. It should be:
CGPointMake(offsetX/enableDisableButton.frame.size.width, 0.5f)

What's the RIGHT way to draw an image in the upper left corner on a mac?

I have an NSView in a ScrollView and I'm trying to draw an image in it. The problem is that I want the upper left corner of the image locked to the upper left corner of the frame, instead of the lower left corner, which is what the View wants me to do. I will need to be able to zoom in and out, and rotate.
currently, I have a kludge of a system where I calculate how much I have to translate my image based on the size of the image and the size of the window. In order to do this, I needed to create an extra view outside the scrollview, so that I could get the size of the window, not including decorations. Then I can calculate the size of the view based on the size of the image and the size of the window, and based on THAT, I can figure out where to translate the image to.
My only other thought was to use the isFlipped: method, but that ends up reversing my image L-R which is bad.
Is there another way I should be doing this?
If you want 0,0 to be in the upper-left corner, then overriding -isFlipped to return YES is the way to go. It should not affect the coordinate systems of any subviews (I think!), but images drawn directly into the flipped view will appear upside-down unless you apply a transform to them.
View Programming Guide for Cocoa: View Geometry