Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Drawing brush strokes  (Read 2719 times)
0 Members and 1 Guest are viewing this topic.
Offline Death33284

Junior Devvie





« Posted 2007-07-03 18:59:23 »

I am currently drawing lines between each call of mouseDragged from a MouseListener, which seems like a crude and basic way of drawing brush strokes and using Graphics2D to change stroke size.



How would I be able to make the strokes smoother, would it require a different base code (not using the mouseDragged event and Graphics2D), processing the strokes afterwards, or both?
Offline keldon85

Senior Devvie


Medals: 1



« Reply #1 - Posted 2007-07-03 21:52:33 »

What you basically have to do is interpolate between the points!

Offline broumbroum

Junior Devvie





« Reply #2 - Posted 2007-07-03 22:57:05 »

Do you use the Double Buffering to draw on the Canvas? This would give you smoother graphics while drawing in real-time.

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Death33284

Junior Devvie





« Reply #3 - Posted 2007-07-04 01:07:33 »

Do you use the Double Buffering to draw on the Canvas? This would give you smoother graphics while drawing in real-time.

I am currently not using active rendering.  I am just concerned with the actual strokes at this point.
Offline Jamison

Junior Devvie




We're all idiots in one way or another.


« Reply #4 - Posted 2007-07-04 11:22:37 »

Maybe enabling anti-aliasing would smooth it out?

I don't like you. Check out my site Smiley www.gamedevforums.com
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #5 - Posted 2007-07-04 11:38:44 »

Is that picture meant to be representative of the output generated by your current implementation?

If so, how did you end up with gaps in your path? (unless you purposefully released the mouse button at those points.)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline keldon85

Senior Devvie


Medals: 1



« Reply #6 - Posted 2007-07-04 17:16:50 »

It's all to do with (a) interpolation, and (b) smoothing!

Offline Death33284

Junior Devvie





« Reply #7 - Posted 2007-07-06 00:41:24 »

Would anyone mind going into more detail about interpolation and smoothing?  Google isn't being my friend right now, as I can't seem to find any good resources.

And yes, that is a screenshot of the current implementation and the gaps are intentional, I was just showing the jagged-ness of the strokes
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #8 - Posted 2007-07-06 01:37:39 »

I think I would do something like... making it actual line position lag 4 inputs behind, using some spline for the last... like... dunno... 6 points to that lagged point. On release finish the remaining stuff via spline-ing and enable antialiasing.

Something like that perhaps Smiley

弾幕 ☆ @mahonnaiseblog
Offline keldon85

Senior Devvie


Medals: 1



« Reply #9 - Posted 2007-07-06 07:12:40 »

First off your aim is to second guess the users curve - knowing that it is likely to have inaccuracies. People have difficulty using the mouse, and quick strokes (even with tablets) are prone to a few errors so you want to smooth the curve out a little.

There is a general, all purpose smoothing method called low pass. It is so general that it is used by both music applications (as a low pass filter, and is an EQ filter) and in image applications as blur! In fact it belongs to the same family of processes that is used for image sharpening, sound frequency boosting and edge detection!!!

You will be doing a similar thing with paths. I have found an article explaining the basics of line smoothing algorithms. When calculating this from any given path you have the distances of the points as an estimation of the speed of drawing, however when your user has just drawn it you have the true speed of movement.

One thing that I always thought was missing from the many drawing packages was the ability to sketch a line - where you draw many short lines and will go over many of your lines. That way you have better data to work with and the user will be able to make much more accurate drawings!

P.s. my google search terms were "curve smoothing algorithm", take algorithm off of it and you will have a lot of non-helpful results Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #10 - Posted 2007-07-06 07:45:15 »

Is that picture meant to be representative of the output generated by your current implementation?

If so, how did you end up with gaps in your path? (unless you purposefully released the mouse button at those points.)

There are no gaps in the source image, it got scaled down by the forum software.

Play Minecraft!
Offline Death33284

Junior Devvie





« Reply #11 - Posted 2007-07-06 08:15:56 »

Oh, those gaps, yeah silly forum  Grin

Thanks for the link to the article, going to look into it tomorrow after I get some sleep
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (22 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!