free-transform | Free Transform Tool Utility
kandi X-RAY | free-transform Summary
kandi X-RAY | free-transform Summary
A set of functions to calculate boundries element resizing, translating, rotating and styles object extraction.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of free-transform
free-transform Key Features
free-transform Examples and Code Snippets
Community Discussions
Trending Discussions on free-transform
QUESTION
When using a global mousemove
event attached to the window
object, the mouse coordinates are not available when the mouse moves over a disabled element. Disabled elements do not fire any events, presenting a problem.
Part of my application includes a free-transform tool which allows elements to be rotated, scaled, resized and dragged around the viewport (drag & drop). The flow of my app is broken if the mouse is moved over a disabled element while freely transforming an object, because suddenly the mouse coordinates are not available to my objects until the mouse leaves the element, giving a choppy / laggy feel and a poor user experience.
I've tried the readonly
attribute instead. However, this is not a viable solution as it is only supported by two elements (input and textarea) source: https://www.w3.org/TR/html4/interact/forms.html#h-17.12 and has different behaviour.
Here's a Fiddle showing the choppy / laggy behaviour: https://jsfiddle.net/rmw9anLs/2/
I understand the element itself doesn't fire any events, but I'm not attaching any events to the disabled element. I would expect the window.mousemove
event to fire regardless and don't understand why a disabled element on the page would interrupt a global event listener.
Aside from implementing a custom disabled
feature using JavaScript, is there a way to get the mouse coordinates without having to account for the mouse being on top of disabled elements?
ANSWER
Answered 2019-Aug-22 at 12:14You cannot, hence the disabled attribute has no effect, other than making your HTML invalid.
To stop the mouse event working, attach an event handler to the element using event.preventDefault()
on it, check for a data-disabled
attribute on the element in your existing click handlers or use pointer-events: none
in a CSS class which you toggle on/off as needed. Also be aware that pointer-events is not well supported in IE <11
QUESTION
I have a code that manipulates and renders a QImage
onto a QWidget
. Manipulation includes typical homogeneous transformations as well as clipping, applying a color-transfer function, etc.
Now I have to deform the image onto a four-vertices polygon (a quad), not necessarily a rectangle. To be clear, I'm not talking about clipping the image, but deforming it.
I know how to do it using OpenGL (a textured quad), but I wonder if it is possible to do it without switching to OpenGL.
Does Qt have any 2D-like textured polygon or any other way to deform a QImage
, like the free-transformation tool in PhotoShop?
ANSWER
Answered 2019-Jul-12 at 06:40QPainter::transform()
is indeed the solution as I already recommended in my comment. I was not fully sure about this but QPainter::transform()
even covers drawn images deforming the original image rectangle respectively. (Otherwise, I had applied the transformation to the QImage
itself.)
However, while making a small sample I realized that's only half of the story.
A small Qt sample application was done ASAP but I struggled to find a way to setup the transformation properly.
By the way I had to realize that translate()
, scale()
, and shear()
are at best good for a 3 point deformation. A 4 point deformation may introduce perspective distortion as well. Hence, project()
may be needed also. Feeling, that I had reached the border of my personal math capabilities I googled how other guys have solved that and found
OpenCVgetPerspectiveTransform()
Calculates a perspective transform from four pairs of the corresponding points.
That sounded promising. Having a look into the (not so long) implementation of cv::getPerspectiveTransform()
, I realized that they made a linear equation and used a solver to yield the respective transformation.
So, I did another search on google and found an IMHO straight-forward implementation by Martin Thoma Solving linear equations with Gaussian elimination. (I somehow remember that I must have heard about Gaussian elimination in my math lessons but that's decades ago, and I never have needed this in daily business since then.)
So, this is what I did for a solver (applying minor stylistic changes to the original code of Martin Thoma) – solveLin.h
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install free-transform
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page