Bugfix for Freehand Tool
Moderators: Víctor Paredes, Belgarath, slowtiger
Bugfix for Freehand Tool
Hi all-
I've been frustrated with the freehand tool in Moho 13 for a while now, particularly having problems with the tapering. I know the Moho team is in active development, but I've actually gone through the lua and figured out a fix for how to re-enable tapering on freehand strokes (both via a mouse and a tablet). I'd love to share my fix with the community, but am not sure how I can publish it or submit it. I don't want to infringe on MohoAnimation's rights as the owner of the source code by re-distributing the code.
Is there a mechanism for making these kind of things available? I'm also toying with adding a few more modifications of my own. Would anyone else be interested? Particularly I'm looking at having a configurable length to the tapering effect on the start and ends, an adjustable flare (or taper) at intersections when auto welded...things like that to make it look a little more organic.
I've been frustrated with the freehand tool in Moho 13 for a while now, particularly having problems with the tapering. I know the Moho team is in active development, but I've actually gone through the lua and figured out a fix for how to re-enable tapering on freehand strokes (both via a mouse and a tablet). I'd love to share my fix with the community, but am not sure how I can publish it or submit it. I don't want to infringe on MohoAnimation's rights as the owner of the source code by re-distributing the code.
Is there a mechanism for making these kind of things available? I'm also toying with adding a few more modifications of my own. Would anyone else be interested? Particularly I'm looking at having a configurable length to the tapering effect on the start and ends, an adjustable flare (or taper) at intersections when auto welded...things like that to make it look a little more organic.
- synthsin75
- Posts: 10254
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Bugfix for Freehand Tool
You can freely distribute modded Moho tools. I even double-checked when LM bought Moho.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Bugfix for Freehand Tool
Awesome! Thanks, Wes. I'll put some polish on what I have and then put it up here since it probably will get better visibility than in the scripting forum.
Re: Bugfix for Freehand Tool
Sounds very interesting! Would love to see it.
Cheers
D.K
Cheers
D.K
http://www.creativetvandmedia.com
My store on Renderosity:
https://www.renderosity.com/mod/bcs/?uid=921315
My store on Renderosity:
https://www.renderosity.com/mod/bcs/?uid=921315
Re: Bugfix for Freehand Tool
This sounds pretty cool! Looking forward to trying your mods.
NEW! Visit our Little Green Dog Channel on YouTube!
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
Re: Bugfix for Freehand Tool
Here is my most basic version....I've not really altered anything aside from fixing the stroke tapering (it was more of a function of removing some of the code SM added that was disabling tapering too aggressively). You may get some extra tapering in places where you don't quite want it. Anyway, to install just drop this lua in C:\Program Files\Smith Micro\Moho 13\Resources\Support\scripts\tool (sorry, I'm a Windows guy, so I'm not sure where to install it on other OSes). Please make sure to back up your un-edited one...I'd hate to break someone else's freehand tool.
The freehandtool with fixed tapering is here:
https://www.oddvisitors.com/resources/lm_freehand.lua
I also made a quick tool for auto formatting strokes. It tapers ends of strokes, and flares at the junctions similar to how I probably will implement in the freehand tool. You just select the points you would like to format, and it will auto format the stroke widths. Feel free to muck about with it as well:
https://www.oddvisitors.com/resources/o ... tCurve.lua
Like I said, these are very early scripts...considering them the earliest of alphas. Bugs may happen, and they're not very user friendly, but we all have to start somewhere. Hope they'll be helpful to someone.
The freehandtool with fixed tapering is here:
https://www.oddvisitors.com/resources/lm_freehand.lua
I also made a quick tool for auto formatting strokes. It tapers ends of strokes, and flares at the junctions similar to how I probably will implement in the freehand tool. You just select the points you would like to format, and it will auto format the stroke widths. Feel free to muck about with it as well:
https://www.oddvisitors.com/resources/o ... tCurve.lua
Like I said, these are very early scripts...considering them the earliest of alphas. Bugs may happen, and they're not very user friendly, but we all have to start somewhere. Hope they'll be helpful to someone.
- synthsin75
- Posts: 10254
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Bugfix for Freehand Tool
Could you upload those to mediafire or another file host?
Firefox is flagging your site as dangerous, and well, I just met you.
You should also be installing custom tools to your Custom Content Folder, rather than the install folder.
Firefox is flagging your site as dangerous, and well, I just met you.
You should also be installing custom tools to your Custom Content Folder, rather than the install folder.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Bugfix for Freehand Tool
I recommend using the Custom Content Folder instead of replacing the original lua files.
Just rename everything in your script from "LM_Freehand" to "OI_Freehand" (or something) and add this code to disable the original tool:
I'm pretty sure you'll even still be able to call LM_Freehand's functions. So there's less chance of breaking things overall. (Certain tools reference other tools)
I also tried to mod some stuff in the Freehand tool. I added <Shift> modifier to turn weld ends on. I also wanted it to auto-close on mouse up if you were not near an endpoint, but I broke some stuff...auto-close is no longer available... I'll share it if I can get it to work. It's super useful. All the checkboxes in the toolbar are confusing and take me out of the flow.
(But honestly, shift should probably allow you to draw straight lines like in any other software... So it should probably use Control instead and force you to use the Eraser tool)
Just rename everything in your script from "LM_Freehand" to "OI_Freehand" (or something) and add this code to disable the original tool:
Code: Select all
-- **************************************************
-- Prevent LM_Freehand from showing up in the Tools window because it is replaced by OI_Freehand
-- **************************************************
function LM_Freehand:IsRelevant(moho)
return false
end
I also tried to mod some stuff in the Freehand tool. I added <Shift> modifier to turn weld ends on. I also wanted it to auto-close on mouse up if you were not near an endpoint, but I broke some stuff...auto-close is no longer available... I'll share it if I can get it to work. It's super useful. All the checkboxes in the toolbar are confusing and take me out of the flow.
(But honestly, shift should probably allow you to draw straight lines like in any other software... So it should probably use Control instead and force you to use the Eraser tool)
Re: Bugfix for Freehand Tool
When you place a Tool mod with the same filename in the Custom Content Folder, doesn't it automatically prevent the original Tool in Programs from loading?
It seems to work that way for me and that's the assumption I've always had. Just wondering if there are exceptions I'm not aware of? Or is the bit of code just for safety?
Thanks for any additional info.
Last edited by Greenlaw on Sat Apr 10, 2021 9:14 pm, edited 2 times in total.
NEW! Visit our Little Green Dog Channel on YouTube!
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
Re: Bugfix for Freehand Tool
I totally get being cautious...a lot of people have been doing sketchy stuff lately. (Also, I have you at a disadvantage....I've been lurking since before the Anime Studio days, so of course I know who you are, but not vice versa.)
Is a google drive link okay? They do virus scanning if memory serves.
Here is the lm_freehand tool:
https://drive.google.com/file/d/1nnBLWA ... sp=sharing
And my format points script/tool:
https://drive.google.com/file/d/1yXoLMK ... sp=sharing
I need to get the namespace stuff fixed, possibly today while the kids are busy doing something (I hope). I'll post an update when I've got it.
Is a google drive link okay? They do virus scanning if memory serves.
Here is the lm_freehand tool:
https://drive.google.com/file/d/1nnBLWA ... sp=sharing
And my format points script/tool:
https://drive.google.com/file/d/1yXoLMK ... sp=sharing
I need to get the namespace stuff fixed, possibly today while the kids are busy doing something (I hope). I'll post an update when I've got it.
Re: Bugfix for Freehand Tool
Also, thanks for the tips, Wes and Lukas. To be honest this is my first stab at lua scripting (C# is my lingua franca, with Javascript and Java in a close second and third). Its been kind of a humbling experiment going back to writing scripts without a debugger and the usual IDE tools.
- synthsin75
- Posts: 10254
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Bugfix for Freehand Tool
Thanks, Oik, just downloaded. And welcome from the shadows.
Yeah, a custom tool with the same name just replaces the LM tool. But if you want a tool with your own name and the factory tool suppressed (to free up toolbar space), you do what Lukas said.Greenlaw wrote: ↑Sat Apr 10, 2021 3:26 pmWhen you place a Tool mod with the same filename in the Custom Content Folder, doesn't it automatically prevent the original Tool in Programs from loading?
It seems to work that way for me and that's the assumption I've always had. Just wondering if there are exceptions I'm not aware of? Or is the bit of code just for safety?
Thanks for any additional info.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Bugfix for Freehand Tool
Ah! Now that makes sense to me. Thanks for explaining, Wes!
NEW! Visit our Little Green Dog Channel on YouTube!
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
Re: Bugfix for Freehand Tool
Yeah, it's just nice and clean to keep the "LM_" files unmodified and you'll always be able to tell where new files came from. I recently found out it didn't work for the Set Origin tool though, because that tool is always relevant (LM_SetOrigin:IsRelevant is never called)... First tool I've seen that it doesn't work on though.
But the best part is is that the original functions will still be called by other tools. For example, I think, the translate points tool uses the code of the select points tool when you press control. But if you replace that tool, the translate points tool also is affected. Which is not always desired, especially when official Moho updates change some tools. I also made a button that disables all custom tools and shows the original tools, which is useful if stuff goes wrong and you don't know what custom tools might be buggy. I'll share it in the Scripting section sometime.
But the best part is is that the original functions will still be called by other tools. For example, I think, the translate points tool uses the code of the select points tool when you press control. But if you replace that tool, the translate points tool also is affected. Which is not always desired, especially when official Moho updates change some tools. I also made a button that disables all custom tools and shows the original tools, which is useful if stuff goes wrong and you don't know what custom tools might be buggy. I'll share it in the Scripting section sometime.
Re: Bugfix for Freehand Tool
Thanks for the insight, Lukas! This is good to know.
NEW! Visit our Little Green Dog Channel on YouTube!
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel
D.R. Greenlaw
Artist/Partner - Little Green Dog
Little Green Dog Channel | Greenlaw's Demo Reel Channel