flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maxim Solodovnik <solomax...@gmail.com>
Subject Re: Get mouse coordinates on high speed
Date Wed, 12 Oct 2016 06:35:07 GMT
Hello All,

just have tried to find "screenRedraw" event to add listener and was
unable to :( which one should I use?

I tried to add

stage.addEventListener("screenRedraw", drawLine);
But unfortunately got only 1 point instead of series.
I'll to experiment with predefined FPS, setting it in runtime seems to
have no effect


On Thu, Oct 6, 2016 at 10:15 PM, Alex Harui <aharui@adobe.com> wrote:
> Might be time to run the profiler to see how much work is being done on
> each mouse event.
> And you can try an ActionScript-only version of your test.  A variant of
> such a test would track timestamps on the mouse events and not draw
> anything until "much later" so you can get a sense for how many mouse
> events you can get if you don't do any display updates at all.  It could
> just be that the input rate is gated by the browser or Flash Player.
>
> On the other hand, remember that the Graphics object builds up a vector
> list, so if you scribbled long enough there would be thousands and
> eventually millions of lineTo's to render, and that would totally swamp
> the renderer.  Depending on what kind of "undo" logic you want to support,
> you can opt for a "Paint" approach and draw the vectors into a bitmap and
> then forget about them, and/or retain your own vector list and somehow cut
> off how far back you can undo.
>
> HTH,
> -Alex
>
> On 10/6/16, 1:24 AM, "Maxim Solodovnik" <solomax666@gmail.com> wrote:
>
>>>> Another possibility: don't attach the events to the stage, but to the
>>>>"area" object instead.
>>Maybe I'm doing something wrong, but this is what I have started from,
>>and it completely not working in my quickstart app
>>
>>will try "screenRedraw", we'll see it will allow more precise coordinates
>>:)
>>
>>On Thu, Oct 6, 2016 at 3:21 PM, Javier Guerrero García
>><javi.gg@gmail.com> wrote:
>>> And the 60fps? :)
>>>
>>> Also, try this: attach ALWAYS the mousemove event listener (even
>>>directly
>>> on MXML) instead of attaching it "on demand", and make mouseDown and
>>> mouseUp just set a "capturing" variable to either true of false.
>>>
>>> Another possibility: don't attach the events to the stage, but to the
>>> "area" object instead.
>>>
>>> Another one: IIRC, there was a "screenRedraw" event, triggering right
>>>after
>>> each frame is painted (30-60 times per sec). You could attach the
>>>capturing
>>> function directly to that event, just checking if the "capturing"
>>>variable
>>> is true or false before proceed with the points.push.
>>>
>>> On Thu, Oct 6, 2016 at 10:03 AM, Maxim Solodovnik <solomax666@gmail.com>
>>> wrote:
>>>
>>>> I tried to change the code as follows
>>>> grab points in event handler [1], then actually draw it after
>>>> capturing is over [2]
>>>> The result curve is not smooth in case of fast, long distance moves
>>>>
>>>> [1] https://github.com/solomax/FlexSandbox/blob/master/web/
>>>> src/Main1.mxml#L37
>>>> [2] https://github.com/solomax/FlexSandbox/blob/master/web/
>>>> src/Main1.mxml#L31
>>>>
>>>> On Thu, Oct 6, 2016 at 2:37 PM, Javier Guerrero García
>>>> <javi.gg@gmail.com> wrote:
>>>> > Yes, I understood, but you can do it in many ways:
>>>> >
>>>> >    - Capture mouse coordinates, and draw the new pixel on a bitmap
>>>>placed
>>>> >    underneath
>>>> >    - Capture mouse coordinates, and draw a new <Line> object from
the
>>>> last
>>>> >    captured point to the new coordinates, and so on
>>>> >    - Capture mouse coordinates, and perfom a graphics.lineTo on a
>>>>Sprite
>>>> on
>>>> >    each mouse move (a one liner for a one liner :)
>>>> >
>>>> > I think the vector approach should perform better on redraws, and I
>>>> really
>>>> > do think your problem is right there on the fullscreen redraws:
>>>>60fps or
>>>> > even 30fps should be more than enough to capture a signature.
>>>> >
>>>> > To confirm first, try first separating the areas, and see it that
>>>>makes
>>>> it
>>>> > smoother :)
>>>> >
>>>> > On Thu, Oct 6, 2016 at 9:27 AM, Maxim Solodovnik
>>>><solomax666@gmail.com>
>>>> > wrote:
>>>> >
>>>> >> It sort of "pencil drawing" by mouse/pen
>>>> >> I'll try to capture points and draw it later(or better in separated
>>>> thread)
>>>> >>
>>>> >> Thanks for the pointer
>>>> >>
>>>> >> On Thu, Oct 6, 2016 at 2:23 PM, Javier Guerrero García
>>>> >> <javi.gg@gmail.com> wrote:
>>>> >> > Hi Maxim!
>>>> >> >
>>>> >> > Are you capturing the points on line objects, or on a bitmap
>>>>drawn at
>>>> the
>>>> >> > bottom that has to be interpolated and redrawn on every mouse
>>>> movement?
>>>> >> Try
>>>> >> > separating the capture and paint areas, capturing line objects
>>>> instead of
>>>> >> > pixels on a bitmap, or at least draw the bitmap with the lowest
>>>> posible
>>>> >> > interpolation quality, to see if it helps.
>>>> >> >
>>>> >> > Hope it works :)
>>>> >> >
>>>> >> > On Thu, Oct 6, 2016 at 5:49 AM, Maxim Solodovnik <
>>>> solomax666@gmail.com>
>>>> >> > wrote:
>>>> >> >
>>>> >> >> changing FPS to 60 doesn't help :( (originally it was 30)
>>>> >> >> Final code for capturing events and drawing is the same
as
>>>>prototype
>>>> >> code
>>>> >> >> still got ugly, non-smooth curve in case mouse moving very
fast
>>>> >> >>
>>>> >> >> Line in much smoother in Gimp
>>>> >> >> In fact Flex desktop app produces smooth enough line
>>>> >> >> will try to create browser quick start and double check
>>>> >> >>
>>>> >> >> On Thu, Oct 6, 2016 at 9:18 AM, Maxim Solodovnik <
>>>> solomax666@gmail.com>
>>>> >> >> wrote:
>>>> >> >> > Hello,
>>>> >> >> >
>>>> >> >> > Thanks a lot for the quick answers, definitely flex
is one of
>>>>my
>>>> >> >> > favorite communities :)
>>>> >> >> > Here is example project: https://github.com/solomax/FlexSandbox
>>>> >> >> > since it is desktop and tiny it looks not that bad
>>>> >> >> > In my main project the resulting line is not smooth
at all :(
>>>> >> >> >
>>>> >> >> > I'll try to check the code and remove any delays,
thanks for
>>>>the
>>>> >> pointer.
>>>> >> >> >
>>>> >> >> > Additionally I'll try to check FFT, I have tried to
add
>>>>additional
>>>> >> >> > points and use cubicCurveTo, but was unable to finish
this (it
>>>>is
>>>> >> >> > currently commented)
>>>> >> >> >
>>>> >> >> > On Thu, Oct 6, 2016 at 1:47 AM, OK <post@olafkrueger.net>
>>>>wrote:
>>>> >> >> >> Alex Harui wrote
>>>> >> >> >>>>can't you just up the frame per second
of the swf to say 60,
>>>>and
>>>> if
>>>> >> >> >>>>needed interpolate data points to smooth
it?
>>>> >> >> >>> That is a possibility, but the interpolation
code may also
>>>>affect
>>>> >> input
>>>> >> >> >>> rate.
>>>> >> >> >>
>>>> >> >> >> For this approach it might be helpful to google
with "spline
>>>> >> >> interpolation"
>>>> >> >> >> and "FFT" (Fast Fourier Transformation). Maybe
you find some
>>>> ready to
>>>> >> >> use
>>>> >> >> >> AS3 implementations.
>>>> >> >> >>
>>>> >> >> >> Olaf
>>>> >> >> >>
>>>> >> >> >>
>>>> >> >> >>
>>>> >> >> >>
>>>> >> >> >> --
>>>> >> >> >> View this message in context: http://apache-flex-users.
>>>> >> >> 2333346.n4.nabble.com/Get-mouse-coordinates-on-high-
>>>> >> >> speed-tp13737p13748.html
>>>> >> >> >> Sent from the Apache Flex Users mailing list archive
at
>>>> Nabble.com.
>>>> >> >> >
>>>> >> >> >
>>>> >> >> >
>>>> >> >> > --
>>>> >> >> > WBR
>>>> >> >> > Maxim aka solomax
>>>> >> >>
>>>> >> >>
>>>> >> >>
>>>> >> >> --
>>>> >> >> WBR
>>>> >> >> Maxim aka solomax
>>>> >> >>
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> WBR
>>>> >> Maxim aka solomax
>>>> >>
>>>>
>>>>
>>>>
>>>> --
>>>> WBR
>>>> Maxim aka solomax
>>>>
>>
>>
>>
>>--
>>WBR
>>Maxim aka solomax
>



-- 
WBR
Maxim aka solomax

Mime
View raw message