*NEW* Stacked shape tools

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

*NEW* Stacked shape tools

Post by synthsin75 »

https://drive.google.com/uc?export=down ... Uudoxbqjad

Create shape tool:
  • This mod allows you to create stacked shapes on the exact same vector points.
    • Warning: Stacking too many shapes can cause aliased edges when rendered.
      The select shape tool will help you avoid that.
  • Update 7/4/19: This now displays selected end points as fat markers.

Select shape tool features:
  • A shape stack indicator: Shape ID: 0 [1] 2
    • When you select a shape, this shows all the IDs for the shapes below the cursor.
    • It indicates which shape in the stack is selected with "[ ]". So you can see either your selection change, using Ctrl+Up/Down, or the shape order change (IDs move), just using Up/Down.
    • Left to right is top to bottom in the stack.
  • No more Ctrl+Up/Down overrun...where you keep hitting the arrow and nothing happens.
  • You can also make contiguous shape selections in the stack using Ctrl+Shift+Up/Down. All selected shapes in the stack are indicated by "[ ]" and can be moved as a group.

:D :!: :!: :!:
Last edited by synthsin75 on Wed Apr 13, 2022 11:27 pm, edited 4 times in total.
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Re: *NEW* Stacked shape tools

Post by ulrik »

That is indeed a very useful tool, thank you for sharing this! :)
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 »

Updated the above link to correct a minor issue.
User avatar
onurbeiren
Posts: 7
Joined: Sun Dec 07, 2014 11:22 pm
Location: Brazil
Contact:

Re: *NEW* Stacked shape tools

Post by onurbeiren »

it will help a lot!
:arrow: :arrow: Image :!: - :idea:
https://www.youtube.com/user/animadorporacaso
Creator of the first Group Brazilian Anime Studio(Moho Pro 12): https://www.facebook.com/groups/998442436875703/
User avatar
A.Evseeva
Posts: 61
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Re: *NEW* Stacked shape tools

Post by A.Evseeva »

Oh, thank You very very much, it is very helpful!
I even wanted to write such a tool, but could not imagine how shoud an interface look like. Your idea is simple and perfect!

Sometimes the tool can not see some shapes.
Image
(two shapes selected but only no 11 shown)
Here is the file.

Also I have a tool mod wich can show an outline of selected shape. Maybe You want to implement it into Your tool?
It looks like this:
Image
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 »

A.Evseeva wrote:Oh, thank You very very much, it is very helpful!
I even wanted to write such a tool, but could not imagine how shoud an interface look like. Your idea is simple and perfect!
Yeah, I kicked myself for not thinking of it earlier.
Sometimes the tool can not see some shapes.
Image
(two shapes selected but only no 11 shown)
Here is the file.
It doesn't show all selected shape IDs. It only shows all selected and unselected IDs under where you last clicked.
In your picture, the hair line is shape 11 (selected) and the hair fill is shape 9 (unselected). The ear is shape 17, so you probably selected that and then shift-selected the hair line (shape 11).
Also I have a tool mod wich can show an outline of selected shape. Maybe You want to implement it into Your tool?
It looks like this:
Image
Interesting. Since there's already a checkerboard pattern, maybe I could use that to highlight the whole stack.
Is that mod in one of your existing tools?
User avatar
A.Evseeva
Posts: 61
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Re: *NEW* Stacked shape tools

Post by A.Evseeva »

Oh, thank You! Now I understand how does it work. I missed that I have to click to see numbers under cursor.

Here is my function for tracing shapes

Code: Select all

function LM_SelectShape:TraceSelected(moho, view)
	local mesh = moho:Mesh()
	if mesh == nil then return end	
	local g = view:Graphics()
	local matrix = LM.Matrix:new_local()
	moho.drawingLayer:GetFullTransform(moho.frame, matrix, moho.document)
	g:Push()
	g:ApplyMatrix(matrix)
	
	for s = 0, mesh:CountShapes()-1 do
		local shape = mesh:Shape(s)
		if shape.fSelected then
			for e = 0, shape:CountEdges()-1 do
				local c,p = shape:GetEdge(e)
				local startPercent, endPercent = mesh:Curve(c):GetSegmentRange(p)
				local step = (endPercent-startPercent)/10
				local p1 = mesh:Curve(c):GetPercentLocation(startPercent)
				for i=1,10 do
					local nextPercent = startPercent + step * i
					if nextPercent > endPercent then nextPercent = endPercent end
					local p2 = mesh:Curve(c):GetPercentLocation(nextPercent)
					g:DrawFatLine(3, p1.x, p1.y, p2.x, p2.y)
					p1:Set(p2)
				end
			end
		end
	end
	
	g:Pop()
	
end
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 »

Thanks for the tracing function.
User avatar
Greenlaw
Posts: 9192
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *NEW* Stacked shape tools

Post by Greenlaw »

This looks cool, Wes! Will try it out this evening.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 »

Per Victor's request here: http://www.lostmarble.com/forum/viewtop ... 20#p188420

Link: http://www.lostmarble.com/forum/viewtop ... 90#p184390

Create shape tool:
  • Update 7/4/19: This now displays selected end points as fat markers.
Last edited by synthsin75 on Fri Mar 25, 2022 12:11 am, edited 2 times in total.
User avatar
Greenlaw
Posts: 9192
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *NEW* Stacked shape tools

Post by Greenlaw »

This is great! Thanks Wes!
User avatar
alanthebox
Posts: 213
Joined: Sat Feb 03, 2018 5:31 pm
Contact:

Re: *NEW* Stacked shape tools

Post by alanthebox »

I installed this script tonight and have been playing around with it, but I'm having trouble understanding the application for it. Would someone fill me as to how you would use this in one of your projects?

Sorry, I'm sure it's super obvious but I feel like I'm missing it!
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 »

alanthebox wrote: Sat Jul 06, 2019 3:11 am I installed this script tonight and have been playing around with it, but I'm having trouble understanding the application for it. Would someone fill me as to how you would use this in one of your projects?

Sorry, I'm sure it's super obvious but I feel like I'm missing it!
The stacked shapes? Here's an example from Denis: https://www.lostmarble.com/forum/viewto ... 63#p184363

Chucky used to have a very nice example of a desk lamp that really showed off the potential of shape stacking, but I'm not finding it.
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: *NEW* Stacked shape tools

Post by chucky »

Well this is well over ten years old.
Good memory Wes.

Image

Because the shapes are stacked on the same vectors, it's possible to change the entire shape and all the effects move with it.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 »

That's it, Chucky. It's memorable because it makes an impact.
Post Reply