Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Allow negative frame id in scene.setCell (scripting). #345

Merged
merged 1 commit into from
Jun 7, 2016

Conversation

Banbury
Copy link
Contributor

@Banbury Banbury commented May 21, 2016

This fix is necessary for creating animations in Javascript from raster images
with only one frame. For this Opentoonz expects a frame id of -2.
A frame id of -1 is an empty frame.
The original implementation only allows positive numbers.

I'm planning to release a converter from Papagayo to Opentoonz script. The script will create a new level with all the mouth shapes. But without this patch the script won't work.

This fix is necessary for creating animations in Javascript from raster images
with only one frame. For this Opentoonz expects a frame id of -2.
A frame id of -1 is an empty frame.
The original implementation onyl allows positive numbers.
@kogaki
Copy link
Member

kogaki commented May 23, 2016

Jenkins, confirm this

@kogaki
Copy link
Member

kogaki commented Jun 7, 2016

@Banbury I want know more detailed situation where negative indices are rquired. I tried following script, and of course, it works. I will be glad if you can show small sample script using negative indices.

>> l = new Level("/Applications/OpenToonz/OpenToonz_1.0_stuff/sandbox/drawings/fafaefaeafeae.tlv");
Toonz level (fafaefaeafeae, 1 frames)
>> l.getFrame("1")
Toonz raster image ( 768 x 576 ) # ok to access to frame1
>> l.getFrame("0")
undefined
>> l.getFrame("2")
undefined # only one frame
>> 

I am excited to hear about your plan to use Papagayo. So I will merge this as soon as I can understand your request.

@kogaki
Copy link
Member

kogaki commented Jun 7, 2016

Now I understood the problem.

In ver.1.0.2,

>> l = new Level("/Users/keisuke_ogaki/Desktop/ottest4.png")
Raster level (ottest4, 1 frames)
>> fids = l.getFrameIds();
["-"]
>> l.getFrame("-")
Error: Argument '-' does not look like a FrameId

@kogaki
Copy link
Member

kogaki commented Jun 7, 2016

OK, I confirmed this PR can solve the problem partially (I found another bug).

>> l = new Level("/Users/keisuke_ogaki/Desktop/ottest4.png") 
Raster level (ottest4, 1 frames)
>> fids = l.getFrameIds();
["-"]
>> l.getFrame("-") #I changed regexp
undefined
>> l.getFrame("-2")
Raster image ( 1920 x 1080 )

Thanks @Banbury . And we are looking forward to seeing your converter !!

@Banbury
Copy link
Contributor Author

Banbury commented Jun 7, 2016

Thanks for merging this. The converter itself is finished. But I've postponed packaging and releasing it, until Opentoonz supports it.

Below you'll find a part of the script for this animation.

scene = new Scene()
scene.insertColumn(0)
AI = scene.loadLevel("AI", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/AI.tif")
E = scene.loadLevel("E", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/E.tif")
etc = scene.loadLevel("etc", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/etc.tif")
FV = scene.loadLevel("FV", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/FV.tif")
L = scene.loadLevel("L", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/L.tif")
MBP = scene.loadLevel("MBP", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/MBP.tif")
O = scene.loadLevel("O", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/O.tif")
rest = scene.loadLevel("rest", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/rest.tif")
U = scene.loadLevel("U", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/U.tif")
WQ = scene.loadLevel("WQ", "d:/OpenToonz 1.0_stuff/projects/OotS/drawings/mouth1/WQ.tif")
scene.setCell(0, 0, { level:"etc", fid:'-2' })
scene.setCell(1, 0, { level:"etc", fid:'-2' })
scene.setCell(2, 0, { level:"AI", fid:'-2' })
scene.setCell(3, 0, { level:"AI", fid:'-2' })
scene.setCell(4, 0, { level:"etc", fid:'-2' })
scene.setCell(5, 0, { level:"etc", fid:'-2' })
scene.setCell(6, 0, { level:"etc", fid:'-2' })
scene.setCell(7, 0, { level:"E", fid:'-2' })
scene.setCell(8, 0, { level:"E", fid:'-2' })
scene.setCell(9, 0, { level:"etc", fid:'-2' })
scene.setCell(10, 0, { level:"etc", fid:'-2' })
scene.setCell(11, 0, { level:"U", fid:'-2' })
scene.setCell(12, 0, { level:"etc", fid:'-2' })
scene.setCell(13, 0, { level:"etc", fid:'-2' })
scene.setCell(14, 0, { level:"E", fid:'-2' })
scene.setCell(15, 0, { level:"etc", fid:'-2' })
scene.setCell(16, 0, { level:"etc", fid:'-2' })
scene.setCell(17, 0, { level:"etc", fid:'-2' })
scene.setCell(18, 0, { level:"etc", fid:'-2' })
scene.setCell(19, 0, { level:"U", fid:'-2' })
scene.setCell(20, 0, { level:"AI", fid:'-2' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants