I want to draw a rectangle on a chart and have it move with the rest of the chart. However, it stays where it was originally rendered in pixel coordinates.
I would have thought there would be a way to add annotations such as this in world coordinates rather than screen coordinates, but I was not able to find a way. Is such a thing possible?
Assuming I am stuck with annotating in screen coordinates, what event(s) do I need to handle to redraw the rectangle when the user zooms or scrolls?
Simple example:
chart.renderer.rect(chart.xAxis[0].toPixels(1432897200000),chart.yAxis[0].toPixels(1.09674),14,14, 0)
http://jsfiddle.net/bz3t79p5/
Also, I have had no luck with using axis.toPixels() for setting the rectangle's width and height. I was getting values that were way out of whack. Is there a trick to converting width and height from world coordinates to pixels?
Related
The problem
I would like to have an area inside love2d in which movable objects are drawn. The movement of the objects is not restricted by the area boundries but drawing is. Think of it as looking outside through a window. For example: a blue rectangle in an area, if it moves to the side its drawing should be truncated to the boundries of the area.
Before moving:
After moving (wrong):
After moving (right):
Restrictions and assumptions
You can assume the area is rectangular.
The object to draw inside can be anything: polygon, image or text.
The area covers anything behind it (as if it has its own background)
Objects not 'belonging' to the area should be drawn as usual.
Atempted solutions
I know I could stop drawing objects as soon as they 'touch' the boundries of the area, but that would cause them to suddenly disappear and then appear when they are wholly inside the area. I guess it takes some sort of layering system but I have no clue on how to include that in love2d.
I think you are looking for love.graphics.setScissor.
The scissor limits the drawing area to a specified rectangle.
Calling the function without any arguments (i.e. love.graphics.setScissor()) disables scissor.
Example:
function love.draw ()
-- sets the drawing area to the top left quarter of the screen
local width, height = love.graphics.getDimensions()
love.graphics.setScissor(0, 0, width / 2, height / 2)
-- code to draw things
love.graphics.setScissor()
end
I'm finding that any annotation image marker that is above some undefined size does not align the bottom of the marker to the coordinates. I've been unable to locate any documentation on it. Why is this and can it be fixed?
The coordinates are for the middle of Manhattan, New York City. Note how the green border sits well into the ocean. The coordinates are definitely right. When I use a different smaller image the annotation sits correctly and when I zoom in it sits correctly. But at anything above a 10.0 zoom level it does not sit correctly.
The coordinate will align with the center of the custom image. Since there currently isn't a way to specify a custom offset, you will need an image with its bottom 50% empty so that its center aligns with the coordinate on the map when placed.
Does an affine transform reposition the content within the view or transform the view's output?
In my experiments, it appears to be the latter. If I apply a translation moving the contents off the view the right, I do not appear to be able to draw in the area within the view to the left.
As requested: I would like to be able to create a scrolling view that rotates. Imagine viewing part of a globe viewed parallel to the axis. The content has to rotate with scrolling.
If I use an affine transform, it appears that the view display is transformed, not the content within the view. If I scroll the content to the right using an affine transform, I get a black area to the left visible in the view that I cannot draw in.
I am trying to confirm whether my interpretation of what is happening is correct. If so, I need to try a different approach.
I have chart images that are conical projections. Whenever the chart position moves, I need to rotate the chart. Imagine viewing a globe from above. The change in rotation is generally less than 1 degrees for a full screen of scrolling.
I am currently doing this in an image view within a scroll view, redrawing the images when the position changes. Any small change in position requires a complete redraw.
Is there a way to have IOS rotate the images within the layer without having to redraw them.
I am imaging something like in the maps app where you can scroll-rotate your course.
Another way of looking at it would be to have something like a scroll view that can scroll up/down or rotate its contents around an axis that may be way off the top of the screen.
I'm adding annotations to an MkMapView and am using a custom image to do so. My custom image is box shaped with a little triangular arrow that's supposed to be right on the place that's being annotated. It seems like MapView by default annotates using the geometric center of the image. What's the best way to design around this problem? Manually moving the icon? Creating the icon in a specific way?
Here's the Apple docs for MKAnnotationView's centerOffset property:
By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in pixels. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.