Yutils: an ASS typeset utilities library

For submission of patches, language translations, discussing implementation of some feature, etc.

Yutils: an ASS typeset utilities library

Unread postby Youka » Sun Jun 29, 2014 2:37 am

Description:
Yutils is a Lua (/LuaJIT) library for some complex tasks. The main purpose is to manipulate geometries.

What can i do with it?
Code: Select all
local Yutils = require("Yutils")

local shape = Yutils.decode.create_font("Arial", true, false, true, false, 40).text_to_shape("Test")   -- 1)
shape = Yutils.shape.flatten(shape)   -- 2)
shape = Yutils.shape.to_outline(shape, 2)   -- 3)
shape = Yutils.shape.split(shape, 1)   -- 4)
shape = Yutils.shape.filter(shape, function(x, y) return x + math.sin(y / 10) * 2, y + math.sin(x / 10) * 2 end)   -- 5)
local pixels = Yutils.shape.to_pixels(shape)   -- 6)
1) -> 2) -> 3) -> 4) -> 5) -> 6)*
* visualized pixels with random colors

Inner blur (text outline shape with blur gets clipped by text shape)
Custom depth perspective (text shape points get filtered with use of a matrix which scales the final scale value/4th coordinate by depth/3rd coordinate)

Download:
Yutils on Github
Last edited by Youka on Tue Jul 15, 2014 4:43 am, edited 1 time in total.
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Re: Yutils: an ASS typeset utilities library

Unread postby vict8r » Mon Jun 30, 2014 2:31 pm

User avatar
vict8r
{\move}
{\move}
 
Posts: 29
Joined: Fri Apr 05, 2013 11:07 pm

Re: Yutils: an ASS typeset utilities library

Unread postby jfs » Mon Jun 30, 2014 5:31 pm

This won't work with current release versions of Aegisub, wait until version 3.2 comes out, or use experimental builds that have LuaJit instead of plain Lua.
Do not PM me asking for help with Aegisub, Automation, karaoke or anything like that, I won't reply.
Ask your questions in the public forums. Use the Search function, somebody probably asked the same question before.
All rights reserved to call you insults if you ask poorly thought out or redundant questions.
Experimenting is free and is a great way to learn things.
User avatar
jfs
Developer
 
Posts: 2947
Joined: Mon Dec 19, 2005 8:18 pm
Location: Denmark

Re: Yutils: an ASS typeset utilities library

Unread postby Youka » Mon Jun 30, 2014 7:44 pm

ffi (foreign function interface) is part of LuaJIT, not official Lua. Your Aegisub version is too old, download an actual one from Plorkyeran's trunk builds (aegisub.org -> Downloads -> Upcoming Versions).
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Re: Yutils: an ASS typeset utilities library

Unread postby vict8r » Mon Jun 30, 2014 8:59 pm

Thank you ^^'...
User avatar
vict8r
{\move}
{\move}
 
Posts: 29
Joined: Fri Apr 05, 2013 11:07 pm

Re: Yutils: an ASS typeset utilities library

Unread postby vict8r » Wed Jul 02, 2014 3:52 am

fx using Yutils.decode.create_font.text_to_shape and Yutils.shape.to_pixels ^^'...
Image
Image
http://puu.sh/9T7Zf/34c18c5aa6.mp4 (view in full screen)
User avatar
vict8r
{\move}
{\move}
 
Posts: 29
Joined: Fri Apr 05, 2013 11:07 pm

Re: Yutils: an ASS typeset utilities library

Unread postby Youka » Wed Jul 02, 2014 2:11 pm

Welcome to the world of pixel effects. Just don't overdo it, pixels blow scripts up. Don't underestimate the awesomeness of shape deformations & masking.
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Re: Yutils: an ASS typeset utilities library

Unread postby vict8r » Fri Jul 04, 2014 4:52 am

Using text_to_shape & shape.filter ^^'...
Image

Image
User avatar
vict8r
{\move}
{\move}
 
Posts: 29
Joined: Fri Apr 05, 2013 11:07 pm

Re: Yutils: an ASS typeset utilities library

Unread postby Youka » Sat Jul 05, 2014 5:18 pm

Yutils gets updated continuously.
Since the last post, there were small fixes, optimizations and function extensions, so remember to update your library from github repo (see first post) if problems occur.
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Re: Yutils: an ASS typeset utilities library

Unread postby vict8r » Sat Jul 05, 2014 7:18 pm

Thank you so much!
is possible to make png_to_pixel or png_to_shape in Yutils.lua?
User avatar
vict8r
{\move}
{\move}
 
Posts: 29
Joined: Fri Apr 05, 2013 11:07 pm

Re: Yutils: an ASS typeset utilities library

Unread postby Youka » Sat Jul 05, 2014 8:25 pm

PNG isn't supported, but Yutils.decode.create_bmp_reader supports decoding of Microsoft Bitmap files with 24 or 32 bit depth.
You can convert PNG to BMP 32bit files with another program and decode those with Yutils. The Yutils bitmap reader can output data in a packed format (table with color values) or as text (bitmap in one ASS line). For more, see and execute the decode.lua test.
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Re: Yutils: an ASS typeset utilities library

Unread postby kinen » Tue Jul 15, 2014 2:01 am

some of my desired function:(some are bullshit ,maybe all are,just ingore it)

1:some shape composition operation.like add or subtract from one shape 2 another.
sometimes like mask one shape from another.(I think it will better than \clip )

2:set the (0,0) position ,of course transformation can do it,but a include function will help a lot

3:shape simplify

4:bitmap trace
kinen
{\b1}
{\b1}
 
Posts: 10
Joined: Tue Dec 24, 2013 5:59 am

Re: Yutils: an ASS typeset utilities library

Unread postby Youka » Tue Jul 15, 2014 5:11 am

kinen wrote:some of my desired function:(some are bullshit ,maybe all are,just ingore it)

1:some shape composition operation.like add or subtract from one shape 2 another.
sometimes like mask one shape from another.(I think it will better than \clip )

2:set the (0,0) position ,of course transformation can do it,but a include function will help a lot

3:shape simplify

4:bitmap trace
1) It's not an absolutely needed feature because ASS tags provide clipping, but a thought worth - maybe.
2) Yutils.shape.move and Yutils.shape.bounding should be all needed for this task - rejected.
3) What you mean exactly? Shape as table?
4) Pixel / bitmap operations are a bit over the edge, i don't want to write a complete graphics library. I already thought about a vectorization function for extracting colored shapes out of a bitmap file, but not more - rejected.
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Re: Yutils: an ASS typeset utilities library

Unread postby kinen » Tue Jul 15, 2014 8:24 am

Youka wrote:
kinen wrote:some of my desired function:(some are bullshit ,maybe all are,just ingore it)

1:some shape composition operation.like add or subtract from one shape 2 another.
sometimes like mask one shape from another.(I think it will better than \clip )

2:set the (0,0) position ,of course transformation can do it,but a include function will help a lot

3:shape simplify

4:bitmap trace
1) It's not an absolutely needed feature because ASS tags provide clipping, but a thought worth - maybe.
2) Yutils.shape.move and Yutils.shape.bounding should be all needed for this task - rejected.
3) What you mean exactly? Shape as table?
4) Pixel / bitmap operations are a bit over the edge, i don't want to write a complete graphics library. I already thought about a vectorization function for extracting colored shapes out of a bitmap file, but not more - rejected.



3)something like this,when a line split into pixel dot(like flattern function?) ,simplify is the way back,it's kind of function interpolate the points to shape,this could reduce file size when come to per-frame shape transform(maybe more)

Will SSBRender keep going?
kinen
{\b1}
{\b1}
 
Posts: 10
Joined: Tue Dec 24, 2013 5:59 am

Re: Yutils: an ASS typeset utilities library

Unread postby Youka » Tue Jul 15, 2014 11:25 pm

kinen wrote:3)something like this,when a line split into pixel dot(like flattern function?) ,simplify is the way back,it's kind of function interpolate the points to shape,this could reduce file size when come to per-frame shape transform(maybe more)
Converting lines to a curve is counter-productive, because renderers will split the curve to lines anyway (and maybe with worse precision than Yutils do) and the resulting curve would just be an approximation. Merging neighbour lines with same direction would be rather something that could be done, but who splits long lines into short lines when not wanting to destroy this potential?

kinen wrote:Will SSBRender keep going?
When i have more time and feel like to continue this project. But i will definitely keep working on it.
(On Yutils i just work a few minutes when i have nothing to do at work, so that's less complicated.)
User avatar
Youka
Moderator
Moderator
 
Posts: 370
Joined: Sat Aug 08, 2009 5:53 pm
Location: Darmstadt

Next

Return to Development

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests