The Daily Click ::. Forums ::. Klik Coding Help ::. Anyone know of a good smooth drawing coding?
 

Post Reply  Post Oekaki 
 

Posted By Message

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
22nd April, 2010 at 01:24:16 -

So yea ... I'm building this graphics app, and getting alot done, except I'm beginning to realize just how lame it's going to be without a nice smooth line. If you move the mouse too quick it makes dots instead of lines. The problem seems to be that TGF just won't paste into the background quick enough to keep up with the mouse on a quick flick of the wrist.

I'm thinking maybe I could constantly store positions into seperate variables and have it paste into background after already having traversed the path with the mouse, and set that variable back to zero to be re-used again for the next section of line after it's been pasted for that variable (for each variable used, there'd need to be many). Sort of a List that it goes down and checks if the value is zero and if it's not, stores the current x and y positions in it, then moves on to the next one doing the same and so on.

The real problem is that I don't know how to do that!
Please Please Please let one of you know the solution to this. It's probably simple for alot of you out there. Would ini's be a good start for this Or should I try an' fiddle round with counters or alterable values or some sort of grid of data storage, or what?
I don't know where to begin with this one.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
22nd April, 2010 at 01:34:46 -

use a fast loop to draw your lines between the last known mouse position and the current mouse position.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
22nd April, 2010 at 02:38:53 -

But won't that make the lines straight and decrease the overall smoothness of a curve?

EDIT: I tried that using the DrawLine object but I must be doing something wrong because it's slowing the app way down and making dots, no lines.


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
22nd April, 2010 at 03:13:26 -

unfortunately yes. the faster you scribble the mouse the less smooth your drawing will become. you can use bezier curves if youre comfortable with the math. but other than that, using lines to complete point to point drawing is the easiest way.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
22nd April, 2010 at 03:48:33 -

You wouldn't happen to have an example laying around for either way would ya?
I've been trying the DrawLine way with FastLoop and I'm obviously doing something wrong.

Also, I've tried to look at this example in MMF2, but the DrawLine.mfx does not seem to exist.
What's up with that? All I can find anywhere is DrawLine.cox and DrawLine.gox and neither of those will work when I change the end to .mfx



 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
22nd April, 2010 at 03:56:34 -

How do you plan to save the changes to pictures in this graphics editor?

 

  		
  		

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
22nd April, 2010 at 04:03:02 -

I was thinking paste to clipboard or something. Hopefully that's possible in TGF. I can always do something more complicated once it's finished and I'm revising it in MMF2.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

nim



Registered
  17/05/2002
Points
  7234
22nd April, 2010 at 04:09:28 -

Save the coordinates of the dots to an array and use Active Overlay or Overlay Redux to draw lines between them.

 
//

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
22nd April, 2010 at 05:00:32 -

Can I bum ActiveOverlay off of ya? ... I tried dl-ing but it's not there.
It gives a 404 Page Not Found error.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

nim



Registered
  17/05/2002
Points
  7234
22nd April, 2010 at 05:08:36 -

Did you try using FusionUpdater to download it?
http://complex.ovh.org/download.php?k=b7c32c29d359baaa69e2322b1dde3f01c0d0d6b9&f=./products/FusionUpdater.rar
(From: http://complex.ovh.org/index.php?p=products )

 
//

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
22nd April, 2010 at 05:10:09 -

Yea, nevermind, I have it now ...

Thanks .. that'll work for MMF2 probably but not TGF1 right? I might have to move the graphics editor to MMF2 sooner than I had planned.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Xgoff



Registered
  22/02/2009
Points
  135
22nd April, 2010 at 05:41:17 -


Originally Posted by Robot Cecil
unfortunately yes. the faster you scribble the mouse the less smooth your drawing will become. you can use bezier curves if youre comfortable with the math. but other than that, using lines to complete point to point drawing is the easiest way.


though the problem with bezier curves is that you have to figure out how you're going to generate decent inside control point(s) from your mouse movement

 
Image

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
22nd April, 2010 at 09:21:45 -


Originally Posted by Xgoff
though the problem with bezier curves is that you have to figure out how you're going to generate decent inside control point(s) from your mouse movement



Bezier Curves in general:
http://en.wikipedia.org/wiki/Bezier_curve

I would say use a Cubic Bezier curve:
P0 = Starting Point
P1 = Point halfway between the two with mouse speed multiplied by some factor added to it.
P2 = End Point


So you know P0 and P2, Then to calculate speed you can simply take:
(P2-P0) / 50

Where 50 is the framerate, or some value that you need to modify to taste. Then you multiply that by some constant to taste, for example:

P1 = 0.08(P2-P0)

Do that in both the X and Y direction and I think it would curve pretty well.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
23rd April, 2010 at 05:32:59 -

Aren't you missing the P3? .. or is that needed? ... an' that's all well and good, but I'm at a complete loss on what to do in TGF to actually make it happen.

There is another way that might work as well .... BUT .. I don't know how to put that into action either.
Basically, the idea would be to have a "ninja shadow" that follows the same path that the mouse takes but at a slower speed so the line which gets drawn will be solid rather than dotted.

I think that may be the easiest method to understand and accomplish, but I could be wrong.
Anyone know how to do such a thing in a simple to understand way?


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd April, 2010 at 12:26:50 -

Use the "Move Safely" extension.
http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/drawer.mfa

 
n/a
   

Post Reply



 



Advertisement

Worth A Click