diff --git a/README.md b/README.md index e9766ad23503bc883c769b5b6c4dd1b32863f7fc..f4152fce597c4ca2a80ad4560c1a2079cd2ac998 100644 --- a/README.md +++ b/README.md @@ -2,91 +2,18 @@ -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.iiens.net/lemarcha2017/baka-fx.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://git.iiens.net/lemarcha2017/baka-fx/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - ## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +A repository of Lua files containing various functions to help making karaoke effects in Aegisub. ## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +Clone this repository into your Aegisub's automation/include folder. ## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +You can include Lua files in your .ass in a `code once` commented line, using `_G.require("path.to.file")`. As such, all files here will be included with something that should look like `_G.require("baka-fx.xxx")`. The "all.lua" file includes all files of this repository, so if you just want a quick and easy access to everything, you can use `_G.require("baka-fx.all")`. +I encourage making your own aliases after importing, as typing the full `_G.function_name(...)` everytime can be a bit heavy and unaesthetic. Just create a `code once` commented line, and write `your_alias = _G.the_function`. -## License -For open source projects, say how it is licensed. +TL;DR: paste this line in Aegisub: `Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code once,_G.require("baka-fx.all")` and call functions with `_G.function_name(...)`. -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +## Organization +Files are organized in subfolders by theme (e.g. jump, shape...). Each theme subfolder has a corresponding lua file in its parent folder, which imports all of the files in the theme subfolder if imported. +This file also defines a table regrouping the subfolder's contents, acting as a sort of package, to organize everything into a tree. \ No newline at end of file diff --git a/all.lua b/all.lua new file mode 100644 index 0000000000000000000000000000000000000000..d799f64ff567cfb2574ffc49666c641951def2d8 --- /dev/null +++ b/all.lua @@ -0,0 +1,2 @@ +require "baka-fx.util" +require "baka-fx.jump" \ No newline at end of file diff --git a/examples/example_jump_frz.ass b/examples/example_jump_frz.ass new file mode 100644 index 0000000000000000000000000000000000000000..d09b25b105c0b78c30d898fc7c8d934483496ee6 --- /dev/null +++ b/examples/example_jump_frz.ass @@ -0,0 +1,121 @@ +[Script Info] +; Script generated by Aegisub 3.2.2 +; http://www.aegisub.org/ +Title: Default Aegisub file +ScriptType: v4.00+ +WrapStyle: 0 +ScaledBorderAndShadow: yes +YCbCr Matrix: TV.601 +PlayResX: 1920 +PlayResY: 1080 + +[Aegisub Project Garbage] +Last Style Storage: Default +Audio File: dummy-audio:silence?sr=44100&bd=16&ch=1&ln=396900000 +Video File: ?dummy:24.000000:240:1920:1080:0:0:0: +Video AR Value: 1.777778 +Video Zoom Percent: 0.500000 +Scroll Position: 3 +Active Line: 7 +Video Position: 114 + +[V4+ Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding +Style: Default-furigana,Arial,50,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,10,1 +Style: Regular Jump-furigana,Arial,50,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,10,1 +Style: Contextualized Jump-furigana,Arial,50,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,10,1 +Style: Contextualized Jump,Arial,100,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,10,10,10,1 +Style: Regular Jump,Arial,100,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,10,10,10,1 +Style: Default,Arial,100,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,10,10,10,1 + +[Events] +Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Importing files +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code once all,_G.require("baka-fx.jump") +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code once all,_G.require("baka-fx.util") +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Constants +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code once all,offset = -100 preline = -1000 postline = 1000 jump_height = 50 jump_accel = 0.5 +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Local aliases for imported functions (aesthetic) +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code once all,tag = _G.tag wrap = _G.wrap jump = _G.jump +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Two ways of using the same jump +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code once all,regular_jump = jump.frz +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code line all,contextualized_jump = function(duration) return jump.frz(line.middle + line.margin_v, jump_height, duration, jump_accel) end +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,String containing the necessary tags for positioning and alignment +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,code syl all,align = wrap(tag("an5") .. tag("pos", line.left + syl.center, line.middle + line.margin_v)) +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Templates +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,template syl all,!retime("preline", preline + offset, offset)!!align! +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,template syl all,!retime("start2syl", offset, offset)!!align! +Comment: 0,0:00:00.00,0:00:00.00,Regular Jump,,0,0,0,template syl,!retime("syl", offset, offset)!!align!{!regular_jump(line.left + syl.center, jump_height, syl.duration, jump_accel)!} +Comment: 0,0:00:00.00,0:00:00.00,Contextualized Jump,,0,0,0,template syl,!retime("syl", offset, offset)!!align!{!contextualized_jump(syl.duration)!} +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,template syl all,!retime("syl2end", offset, offset)!!align! +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,template syl all,!retime("postline", offset, postline + offset)!!align! +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Karaoke lines +Comment: 0,0:00:02.50,0:00:07.50,Regular Jump,,0,0,50,karaoke,{\k100}this {\k100}is {\k100}the {\k100}regular {\k100}jump +Comment: 0,0:00:02.50,0:00:07.50,Contextualized Jump,,0,0,150,karaoke,{\k100}this {\k100}is {\k100}the {\k100}contextualized {\k100}jump +Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,, +Dialogue: 0,0:00:01.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(509.71875, 150)} +Dialogue: 0,0:00:02.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(509.71875, 150)} +Dialogue: 0,0:00:02.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(509.71875, 150)}{\org(-100000, 509.71875)\frz0.028647889756541} +Dialogue: 0,0:00:02.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(509.71875, 150)} +Dialogue: 0,0:00:07.40,0:00:08.40,Regular Jump,,0,0,50,fx,{\an5\pos(509.71875, 150)} +Dialogue: 0,0:00:01.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(579.375, 150)}this +Dialogue: 0,0:00:02.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(579.375, 150)}this +Dialogue: 0,0:00:02.40,0:00:03.40,Regular Jump,,0,0,50,fx,{\an5\pos(579.375, 150)}{\org(-100000, 579.375)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}this +Dialogue: 0,0:00:03.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(579.375, 150)}this +Dialogue: 0,0:00:07.40,0:00:08.40,Regular Jump,,0,0,50,fx,{\an5\pos(579.375, 150)}this +Dialogue: 0,0:00:01.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(706.234375, 150)}is +Dialogue: 0,0:00:02.40,0:00:03.40,Regular Jump,,0,0,50,fx,{\an5\pos(706.234375, 150)}is +Dialogue: 0,0:00:03.40,0:00:04.40,Regular Jump,,0,0,50,fx,{\an5\pos(706.234375, 150)}{\org(-100000, 706.234375)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}is +Dialogue: 0,0:00:04.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(706.234375, 150)}is +Dialogue: 0,0:00:07.40,0:00:08.40,Regular Jump,,0,0,50,fx,{\an5\pos(706.234375, 150)}is +Dialogue: 0,0:00:01.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(825.65625, 150)}the +Dialogue: 0,0:00:02.40,0:00:04.40,Regular Jump,,0,0,50,fx,{\an5\pos(825.65625, 150)}the +Dialogue: 0,0:00:04.40,0:00:05.40,Regular Jump,,0,0,50,fx,{\an5\pos(825.65625, 150)}{\org(-100000, 825.65625)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}the +Dialogue: 0,0:00:05.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(825.65625, 150)}the +Dialogue: 0,0:00:07.40,0:00:08.40,Regular Jump,,0,0,50,fx,{\an5\pos(825.65625, 150)}the +Dialogue: 0,0:00:01.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(1052.0703125, 150)}regular +Dialogue: 0,0:00:02.40,0:00:05.40,Regular Jump,,0,0,50,fx,{\an5\pos(1052.0703125, 150)}regular +Dialogue: 0,0:00:05.40,0:00:06.40,Regular Jump,,0,0,50,fx,{\an5\pos(1052.0703125, 150)}{\org(-100000, 1052.0703125)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}regular +Dialogue: 0,0:00:06.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(1052.0703125, 150)}regular +Dialogue: 0,0:00:07.40,0:00:08.40,Regular Jump,,0,0,50,fx,{\an5\pos(1052.0703125, 150)}regular +Dialogue: 0,0:00:01.40,0:00:02.40,Regular Jump,,0,0,50,fx,{\an5\pos(1313.2734375, 150)}jump +Dialogue: 0,0:00:02.40,0:00:06.40,Regular Jump,,0,0,50,fx,{\an5\pos(1313.2734375, 150)}jump +Dialogue: 0,0:00:06.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(1313.2734375, 150)}{\org(-100000, 1313.2734375)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}jump +Dialogue: 0,0:00:07.40,0:00:07.40,Regular Jump,,0,0,50,fx,{\an5\pos(1313.2734375, 150)}jump +Dialogue: 0,0:00:07.40,0:00:08.40,Regular Jump,,0,0,50,fx,{\an5\pos(1313.2734375, 150)}jump +Dialogue: 0,0:00:01.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(362.890625, 350)} +Dialogue: 0,0:00:02.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(362.890625, 350)} +Dialogue: 0,0:00:02.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(362.890625, 350)}{\org(-100000, 350)\frz0.028647889756541} +Dialogue: 0,0:00:02.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(362.890625, 350)} +Dialogue: 0,0:00:07.40,0:00:08.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(362.890625, 350)} +Dialogue: 0,0:00:01.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(432.546875, 350)}this +Dialogue: 0,0:00:02.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(432.546875, 350)}this +Dialogue: 0,0:00:02.40,0:00:03.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(432.546875, 350)}{\org(-100000, 350)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}this +Dialogue: 0,0:00:03.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(432.546875, 350)}this +Dialogue: 0,0:00:07.40,0:00:08.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(432.546875, 350)}this +Dialogue: 0,0:00:01.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(559.40625, 350)}is +Dialogue: 0,0:00:02.40,0:00:03.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(559.40625, 350)}is +Dialogue: 0,0:00:03.40,0:00:04.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(559.40625, 350)}{\org(-100000, 350)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}is +Dialogue: 0,0:00:04.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(559.40625, 350)}is +Dialogue: 0,0:00:07.40,0:00:08.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(559.40625, 350)}is +Dialogue: 0,0:00:01.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(678.828125, 350)}the +Dialogue: 0,0:00:02.40,0:00:04.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(678.828125, 350)}the +Dialogue: 0,0:00:04.40,0:00:05.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(678.828125, 350)}{\org(-100000, 350)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}the +Dialogue: 0,0:00:05.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(678.828125, 350)}the +Dialogue: 0,0:00:07.40,0:00:08.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(678.828125, 350)}the +Dialogue: 0,0:00:01.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1052.0703125, 350)}contextualized +Dialogue: 0,0:00:02.40,0:00:05.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1052.0703125, 350)}contextualized +Dialogue: 0,0:00:05.40,0:00:06.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1052.0703125, 350)}{\org(-100000, 350)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}contextualized +Dialogue: 0,0:00:06.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1052.0703125, 350)}contextualized +Dialogue: 0,0:00:07.40,0:00:08.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1052.0703125, 350)}contextualized +Dialogue: 0,0:00:01.40,0:00:02.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1460.1015625, 350)}jump +Dialogue: 0,0:00:02.40,0:00:06.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1460.1015625, 350)}jump +Dialogue: 0,0:00:06.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1460.1015625, 350)}{\org(-100000, 350)\frz0\t(0, 500, 0.5, \frz0.028647889756541)\t(500, 1000, 2, \frz0)}jump +Dialogue: 0,0:00:07.40,0:00:07.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1460.1015625, 350)}jump +Dialogue: 0,0:00:07.40,0:00:08.40,Contextualized Jump,,0,0,150,fx,{\an5\pos(1460.1015625, 350)}jump diff --git a/jump.lua b/jump.lua new file mode 100644 index 0000000000000000000000000000000000000000..4b46836da8cc5189a7813b628bcfe5b8e4acaa48 --- /dev/null +++ b/jump.lua @@ -0,0 +1,6 @@ +require "baka-fx.jump.jump_frz" + +jump = +{ + frz = jump_frz +} \ No newline at end of file diff --git a/jump/jump_frz.lua b/jump/jump_frz.lua new file mode 100644 index 0000000000000000000000000000000000000000..5b39694874e272df83659bc87360e5791e6fc2af --- /dev/null +++ b/jump/jump_frz.lua @@ -0,0 +1,64 @@ +require "baka-fx.util" + +--[[ +[Description] +A rotation with a far away \org and a small \frz, +mimicking a straight vertical jump. + +[Usage] +jump_frz(base_y, height, dur) +jump_frz(base_y, height, dur, a) +jump_frz(base_y, height, dur, t1, t2) +jump_frz(base_y, height, dur, t1, t2, a) + +[Arguments] +base_y: vertical coordinate for the start and end of the jump +height: total height of the jump +dur: total duration of the jump +t1: duration between the start of the syl/line and the start of the jump +t2: duration between the end of the jump and dur +a: acceleration for the vertical movement (works the same as \t's) + +[Notes] +A chart is worth a thousand words: + +vertical +position + ^ + | + height - x-----x + | / \ + base_y - x x + | ' ' ' ' + +------0-t1---t2-dur---> time +--]] +function jump_frz(base_y, height, dur, ...) + local radius = 100000 + local rot = height / radius * 180 / math.pi + local a = 1 + local t1 = dur / 2 + local t2 = dur / 2 + local args = { ... } + + -- Checking arguments + if #args == 1 then + a = args[1] > 0 and args[1] or a + end + if #args >= 2 then + t1 = clamp(args[1], 0, dur) + t2 = clamp(args[2], 0, dur - t1) + end + if #args >= 3 then + a = args[3] > 0 and args[3] or a + end + + local org = tag("org", -radius, base_y) + local up = tag("t", 0, t1, a, tag("frz", rot)) + local down = tag("t", dur - t2, dur, 1 / a, tag("frz", 0)) + + if t1 == 0 and t2 == 0 then return org .. tag("frz", rot) end + if t1 == 0 then return org .. tag("frz", rot) .. down end + if t2 == 0 then return org .. tag("frz", 0) .. up end + + return org .. tag("frz", 0) .. up .. down +end \ No newline at end of file diff --git a/util.lua b/util.lua new file mode 100644 index 0000000000000000000000000000000000000000..1849367aa890f14d8c2cb9f80247c1d07023a2b4 --- /dev/null +++ b/util.lua @@ -0,0 +1,8 @@ +require "baka-fx.util.tag" +require "baka-fx.util.wrap" + +util = +{ + tag = tag, + wrap = wrap +} \ No newline at end of file diff --git a/util/tag.lua b/util/tag.lua new file mode 100644 index 0000000000000000000000000000000000000000..d904a858d60eab7ee8b99637344a686176d10b17 --- /dev/null +++ b/util/tag.lua @@ -0,0 +1,34 @@ +--[[ +[Description] +A function that generates an ASS tag, given a name and eventual parameters. + +[Usage] +tag(name) +tag(name, arg) +tag(name, arg1, arg2, ...) + +[Arguments] +name: the name of the tag (e.g. for \pos, name = "pos") +args: arguments of the tag + +[Note] +If no extra arguments are provided, the generated tag will be \<name> +If one extra argument is provided, the generated tag will be \<name><arg> +If multiple extra arguments are provided, the generated tag will be \<name>(<arg1>, <arg2>, ...) +--]] +function tag(name, ...) + local arg = { ... } + local str = "\\" .. name + + if (#arg > 1) then + str = str .. "(" + for i = 1, #arg - 1 do + str = str .. arg[i] .. ", " + end + str = str .. arg[#arg] .. ")" + elseif (#arg == 1) then + str = str .. arg[1] + end + + return str +end diff --git a/util/wrap.lua b/util/wrap.lua new file mode 100644 index 0000000000000000000000000000000000000000..054ebda3926db72605dc5f847053102afdff0fc2 --- /dev/null +++ b/util/wrap.lua @@ -0,0 +1,11 @@ +--[[ +[Description] +A very simple function that wraps a string between brackets {} + +[Usage] +wrap(str) + +[Arguments] +str: the string to wrap in brackets +--]] +function wrap(str) return "{" .. str .. "}" end \ No newline at end of file