*NEW* Stacked shape tools

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

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

*NEW* Stacked shape tools

Post by synthsin75 » Mon Sep 10, 2018 10:46 am

https://sites.google.com/site/synthsin/ ... ects=0&d=1

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.

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 :!: :!: :!:
- Wes
ImageImageImage
ulrik
Posts: 1063
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Re: *NEW* Stacked shape tools

Post by ulrik » Tue Sep 11, 2018 6:13 am

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

Re: *NEW* Stacked shape tools

Post by synthsin75 » Tue Sep 11, 2018 5:12 pm

Updated the above link to correct a minor issue.
- Wes
ImageImageImage
onurbeiren
Posts: 3
Joined: Sun Dec 07, 2014 11:22 pm
Location: Brazil
Contact:

Re: *NEW* Stacked shape tools

Post by onurbeiren » Thu Sep 13, 2018 9:56 pm

it will help a lot!
A.Evseeva
Posts: 33
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Re: *NEW* Stacked shape tools

Post by A.Evseeva » Thu Oct 11, 2018 4:31 am

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: 7015
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 » Thu Oct 11, 2018 4:55 am

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?
- Wes
ImageImageImage
A.Evseeva
Posts: 33
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Re: *NEW* Stacked shape tools

Post by A.Evseeva » Thu Oct 11, 2018 7:04 am

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: 7015
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Stacked shape tools

Post by synthsin75 » Thu Oct 11, 2018 11:30 pm

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

Re: *NEW* Stacked shape tools

Post by Greenlaw » Fri Oct 12, 2018 12:31 am

This looks cool, Wes! Will try it out this evening.
D.R. Greenlaw
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2017
Lead Digital Animator, Dreamworks Animation

Image
Post Reply