Smooth strokes

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Fri May 30, 2014 8:29 pm

Hi -hh,

I like your post, brilliant like your code. :D

I tried to implement a simplified version of your smoothIt handler in a drawing stack, I post it here.
Attachments
Test.livecode.zip
(2.49 KiB) Downloaded 244 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Smooth strokes

Post by [-hh] » Fri May 30, 2014 9:29 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:06 pm, edited 1 time in total.
shiftLock happens

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Mon Jun 16, 2014 11:00 am

Ok, I made some tests, here is a stack with the results.

1. To avoid to remove edges the stack splits every polygon in different segments (e.g an N is split in 3 segments), processes individually each segment and then re-compose the segments before to assign the points to the graphic.

2. The external dimension of the polygon (the rectangle), is preserved by restoring the original rect after the process. In this way I try to avoid to change the dimensions of the polygons created by the user.

4. Straight lines (for example the bars of a T) are not processed by excluding graphics with a certain wide or height of the rect. Maybe here would be better to use some proportional algorithm I think, or more better a way to distinguish a line from a curve.

All this can be improved a lot, if you have ideas or solutions please modify the stack.
Attachments
SmoothTest.livecode.zip
(3.36 KiB) Downloaded 202 times

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Wed Jun 18, 2014 1:27 am

No one has any idea on how to improve the polygons created with the finger?

PS
I am also willing to consider professional solutions as long as the result is good. Please contact me in private.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Smooth strokes

Post by [-hh] » Thu Jun 19, 2014 8:48 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:05 pm, edited 1 time in total.
shiftLock happens

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Smooth strokes

Post by capellan » Fri Jun 20, 2014 1:28 am

Mag wrote:No one has any idea on how to improve the polygons created with the finger?
[snip]
Hi Mag,

Check if this stack could help in this task:
http://andregarzia.on-rev.com/alejandro ... orithm.zip

This stack implements two polygon smoothing algorithms:
Chaikin and Shemanarev

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Sun Jun 22, 2014 10:08 pm

Great work [-hh]!

Thank you capellan, I will check these stacks. Are you involved in the developing of them?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Smooth strokes

Post by [-hh] » Mon Jun 23, 2014 2:53 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:05 pm, edited 1 time in total.
shiftLock happens

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Tue Jun 24, 2014 6:38 am

Hi Hermann,

thank you. What I'm trying to do is an app for write and draw with the finger. Unfortunately to date I haven't find a way to have smooth polygons. All the project are interesting in theory but I can't find a way to implement these ideas in my project, probably because this requires knowledge of mathematics that I don't have. For example, the stack with the Bezier lines is very nice, but I don't know how to implement it in a project where the user draws with the finger.

For this reason, I said that if someone finds a working solution, even professional (with the meaning that the programmer realizes it for work, so for a fee), I'd be willing to consider pay for it or fund the project.

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Location: UK
Contact:

Re: Smooth strokes

Post by splash21 » Tue Jun 24, 2014 12:36 pm

Hi, Mag. If you look in the LiveCode user samples for "Air Traffic Control", you'll find an example of some smoothing as lines are drawn with the mouse. It's not great, but does work - and can be improved if you really need it :D

Also have a look at the Doodle Cards app (created with LC for iOS). It doesn't use any smoothing, but works fine for drawing with fingers - I've got a LOT of examples created with it, as a few of us were using the same drawing code in a 'draw something' style game.

https://itunes.apple.com/gb/app/doodle- ... 56219?mt=8
1.png
1.png (3.33 KiB) Viewed 8646 times
2.png
2.png (2.25 KiB) Viewed 8646 times
9.png
9.png (1.79 KiB) Viewed 8646 times
LiveCode Development & Training : http://splash21.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Smooth strokes

Post by [-hh] » Tue Jun 24, 2014 12:44 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:05 pm, edited 1 time in total.
shiftLock happens

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Tue Jun 24, 2014 2:08 pm

Hi splash21, thank you for the tip, I will study the stack.

Hi [-hh], I tried the stack but unfortunately it seems that 5 becomes a S, 3 becomes a kind of snake... maybe there is something to set that I don't understand :oops:

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Smooth strokes

Post by [-hh] » Tue Jun 24, 2014 4:56 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:05 pm, edited 1 time in total.
shiftLock happens

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Smooth strokes

Post by Mag » Tue Jun 24, 2014 8:26 pm

Ah, ok, now I understand. Thank you.

Rounding that you have achieved is very good but has a problem: forces the user to draw what they wrote in different segments. If the process of separating a polygon in segments it were made by the code you would have a really great tool.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Smooth strokes

Post by [-hh] » Tue Jun 24, 2014 9:12 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:05 pm, edited 1 time in total.
shiftLock happens

Post Reply

Return to “iOS Deployment”