Smooth form resizing in Delphi Firemonkey - delphi

If I create a Multi-Device application in Delphi 10 Seattle (no controls on the form), run the app., and resize the form to make it larger, I see a hint of a black background rectangle following my cursor and every so often the form jumps to the new position indicated by the black rectangle.
With a form loaded with many controls, the black background rectangle is much more pronounced (extending far outside the edges of the form especially if I drag the cursor fast) and there is a very noticeable delay before the form jumps to each new position. The enlargement of the form appears to take place in a series of big jumps. To my eyes, this is ugly. Is there any way to have the form enlarge smoothly rather than in this jerky fashion?
PS I just noticed this only occurs when compiled for Windows. Compiled for OS X, the form does enlarge smoothly.

Related

draw line over my screen to indicate mouse movement

I'm working with opencv and I want to do the following procedure:
Every second I check the difference between the current position of the mouse and the position it was 1 second ago.
Then I want to draw a line in my screen, from the position 1 second ago and the current position. This line should stay on the screen for 1 second until the difference is evaluated again, so the line should be renderer in the new position.
I've already done all the logics, position calculations and everything. What I want to know is how to draw a line in my screen. I wish to use my PC normally while I can see those lines, that means clicking with the mouse, keyboard events and opening windows should not stop the lines from being renderer on my screen.
How can I do that?
That isn't trivial.
You need some GUI toolkit that can show a window with the following properties:
full-screen
no window decoration (title bar...)
always-on-top
"intangible", i.e. allowing mouse and keyboard events to pass through to whatever other windows are underneath it
a working alpha channel (per-pixel transparency)
That's the general idea. Pick a popular GUI toolkit, then google around. You'll likely find ways to do each and all of those points.
I don't think OpenCV does this. Its GUI facilities are a convenience, not flexible to this degree.

Scaling SVG past unknown threshold causes elements to disappear

I'm using openseadragon with the excellent svg overlay plugin.
On Chrome, the app behaves as expected: users can tap to zoom in until a table rendered in SVG is fully visible, the note on the table is legible.
Here's the link to the demo. Zoom out to see the SVG version of the table appear, overlaying the fuzzy raster version of the background.
On Safari on iOS or OSX when zooming past a seemingly arbitrary threshold the table and everything on it start to disappear. The point of disappearance seems to depend on other factors I don't understand, hence this question for insight. For example, a orange circle drawn with two.js will disappear when the scale transform is precisely 51201 (at 51200 the circle is there). For the more complex table SVG, elements on the table will disappear at different scale levels, between ~23000 to 50000. Sometimes they'll disappear and then reappear upon a slight zoom in. Sometimes they'll disappear on zoom and then reappear as I pan around, the objects nearing the edge of the viewport.
IE 11 has a very similar issue.
Has anyone dealt with this before or solved it?
That's a really slick project!
In my experience, that kind of problem with SVG disappearing has to do with extreme amounts of zoom. The good news is you should be able to work around it by changing your viewport coordinates. By default the width of the image is a viewport value of 1, but you can set your image to be width 10,000 or some such, which will look exactly the same on the screen, but it means that the SVG thinks it's zoomed out a lot at first, so when you zoom in you can go a lot further.
If you're using two.js, another possible fix would be to switch over to canvas rendering and use https://github.com/altert/OpenSeadragonCanvasOverlay.
Btw, I'd love to share your project when it's done... please file a ticket at https://github.com/openseadragon/site-build/issues when you're ready and we can add it to http://openseadragon.github.io/examples/in-the-wild/.

How to get a control that is underneath another control?

I am trying to create a basic map editor for fun which consists of a scrollbox and paintbox (to draw the grid).
In the OnMouseDown event for the paintbox I create images at runtime and add them inside the scrollbox, the grid paintbox is painted above the images ( because if the grid was at the back it just would not look good ).
Here is a sample screen:
My question would solve two of my problems in one.
I need to be able to drag and drop (to move) the images around at runtime.
I also need to be able to get the X and Y position of the image to display as information.
Here is where my problem lies, to solve the problems above I first need to get the Image under the mouse cursor. But because I paint my grid (paintbox) above the images, the cursor will only ever 'see' the paintbox grid, and not the underlying images.
I did experiment with copying the paintbox grid to a TImage but it came out all wrong and I was getting out of memory errors. The size of the maps could be quite large and so putting the grid onto a bitmap is not ideal due the memory and limitations etc.
The grid must go on the top, otherwise it would look something like this:
Which hides the grid, and I don't want that to happen.
So, how can I see past the paintbox and get to the images underneath, using FindVCLWindow or something similar?
Set the Enabled property of the PaintBox to False. That will let the mouse messages go through.
Further:
In the OnMouseDown event for the PaintBox I create images at runtime and add them inside the scrollbox
Change that to the OnMouseDown event on the ScrollBox. Adjust the coordinates by ScrollBox.[Horz/Vert]Scrollbar.Position.

C# XNA - Drawing into a form that is bigger than the main window

Drawing into a form that is bigger than the main window with GraphicsDevice.Present results in the form cutting the stuff that is drawn along an imaginary border, which has exactly the size of the main window. I added a picture to be clear
The red rectangle has the same size as the Main Form.
Main Form is an XNA Game, whereas Secondary Form is a Windows Form, which Main Form draws on with GraphicsDevice.Present
I tried setting the Viewport which results in an exception.
Use the official WinForms sample. It has correct support for multiple windows (and includes an explanation of how it works).
The Game class doesn't support this.

Animate Text Display In-A-Way That Simulates Magical Ink Writing in a Magical Book

I am working on a Cocos2d iPad game that includes a magical book. From time-to-time, new text appears in the book.
I would like to animate the new text in a way that looks like ink magically appearing on the page of the book. I have tried the following (but am not happy with the quality):
Outside the game: create the text as an image, create a second image of the text and blur it. During runtime: fade from the blurred text image to the non-blurred text image
Runtime: create random ink dots in the region of the text, scale the ink dots until the obscure much of the area, and then fade them to out leaving the text behind.
My question is this: What is a creative way to have text look like it is magically appearing on an old page of a magic book using Cocos2d on the iPad?
What about creating a particle system (choose one from the examples coming with cocos and customize) which will move on your book and new text characters will appear under it ?
Or it can be a big system to cover all the text line. So it will appear (particles) then text will be created under it and particles emitter will stop, so the current particles will disappear beautiful.
I'm not familiar with cocos, but how about just slowly increasing the text color saturation starting from white (assuming your page color is white).
If you want to make it look like it's being magically written, you could create the text as an image, and have a second image similar to the book background on top, and slide it to the right thus slowly revealing the unmasked text.
If you wanna get fancy, remember that fonts are defined as Bezier curves. These can be animated. In this manner you could create some awesome effects, although the coding would probably not be effortless.

Resources