Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CoffeeStraw committed Feb 6, 2019
0 parents commit 5628d5d
Show file tree
Hide file tree
Showing 22 changed files with 1,789 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.pytest_cache/
docs/build/
examples/__pycache__/
examples/Output.ass
pyonfx/__pycache__/
tests/Ass - Crazy/
tests/__pycache__/
tests/Output.ass
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<p align="center">
<img src="/docs/source/_static/PyonFX Logo.png" alt="PyonFX Logo"/>
</p>

**PyonFX** is an *easy way* to do **KFX** and **complex typesetting** based on subtitle format **ASS** (Advanced Substation Alpha).

Powered by **Python3**, **PyonFX** aims to offer stability, efficiency and ease of use
for everyone who wants to create something more visually complex with the ASS format.

## Getting Started

TO DO.

## Installing

TO DO.

```
pip install ...
```

## Examples

*Examples* directory contains templates which are ready to go for testing, for absolute beginners until advanced users. You can load and execute them, look into the code, reuse parts of them, learn by doing.

## Contributing

If you want to contribute to PyonFX, be sure to review the [contribution
guidelines](CONTRIBUTING.md) (TO DO).

This project will use [GitHub issues](link_to_project_issues) for
tracking **requests and bugs**, so please *don't use* issues for general questions and discussion.

## License

This project is licensed under the LGPL v3.0 License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

* **Youka** for the original main functions ideas of **NyuFX**;
* **McWhite** for the original functions ideas of his library for **NyuFX**;
* **Siplas** for helping me out in the realization of the logo of **PyonFX**.
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd
Binary file added docs/source/_static/PyonFX Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/source/ass utility.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This file contains all the functions and class definitions to work with the ASS format.

PyonFX Ass Utility
==================
.. automodule:: pyonfx.ass_utility
:members:
167 changes: 167 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.

import os
import sys
import sphinx_rtd_theme

# Updating path
sys.path.insert(0, os.path.abspath('..//..'))
sys.setrecursionlimit(1500)

from pyonfx import __version__

# -- Project information -----------------------------------------------------

project = 'PyonFX'
copyright = '2019, Antonio Strippoli'
author = 'Antonio Strippoli (CoffeeStraw/YellowFlash)'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = __version__


# -- General configuration ---------------------------------------------------
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
htm_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further.
html_theme_options = {
'canonical_url': '',
'logo_only': True,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True,
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}

html_logo = "_static/PyonFX Logo.png"


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'PyonFXdoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
'papersize': 'letterpaper',
'pointsize': '10pt',
'preamble': '',
'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PyonFX.tex', 'PyonFX Documentation',
'Antonio Strippoli (CoffeeStraw/YellowFlash)', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pyonfx', 'PyonFX Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PyonFX', 'PyonFX Documentation',
author, 'PyonFX', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------
extensions = ['sphinxcontrib.napoleon']

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
6 changes: 6 additions & 0 deletions docs/source/convert.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This file contains the Convert class definition.

PyonFX Convert Functions
========================
.. automodule:: pyonfx.convert
:members:
13 changes: 13 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. toctree::
:hidden:
:maxdepth: 2

ass utility
convert
utils
settings

The PyonFX API Reference
************************

.. automodule:: pyonfx
6 changes: 6 additions & 0 deletions docs/source/settings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This file contains some settings that can be customized by the user in the top of their .py file.

PyonFX Settings
===============
.. automodule:: pyonfx.settings
:members:
6 changes: 6 additions & 0 deletions docs/source/utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This file contains the Utils class definition.

PyonFX Utils
============
.. automodule:: pyonfx.utils
:members:
72 changes: 72 additions & 0 deletions examples/First Effect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# If you're trying this example having downloaded the repository
# and not only installed PyonFX, uncomment the following lines:
# import sys
# sys.path.insert(0,'../')

from pyonfx import *

io = Ass("..\\tests\\Ass\\in.ass")
meta, styles, lines = io.get_data()

def romaji_kanji(line, l):
# Leadin Effect
for syli, syl in Utils.all_non_empty(line.syls):
l.layer = 0

l.start_time = line.start_time - line.leadin/2
l.end_time = line.start_time + syl.start_time
l.dur = l.end_time - l.start_time

l.text = "{\\an5\\pos(%.3f,%.3f)\\fad(%d,0)}%s" % (
syl.center, syl.middle, line.leadin/2, syl.text)

io.write_line(l)

# Main Effect
for syli, syl in Utils.all_non_empty(line.syls):
l.layer = 1

l.start_time = line.start_time + syl.start_time
l.end_time = line.start_time + syl.end_time
l.dur = l.end_time - l.start_time

l.text = "{\\an5\\pos(%.3f,%.3f)"\
"\\t(0,%d,0.5,\\1c&HFFFFFF&\\3c&HABABAB&\\fscx125\\fscy125)"\
"\\t(%d,%d,1.5,\\fscx100\\fscy100\\1c%s\\3c%s)}%s" % (
syl.center, syl.middle,
l.dur/3, l.dur/3, l.dur, line.styleref.color1, line.styleref.color3, syl.text)

io.write_line(l)

# Leadout Effect
for syli, syl in Utils.all_non_empty(line.syls):
l.layer = 0

l.start_time = line.start_time + syl.end_time
l.end_time = line.end_time + line.leadout/2
l.dur = l.end_time - l.start_time

l.text = "{\\an5\\pos(%.3f,%.3f)\\fad(0,%d)}%s" % (
syl.center, syl.middle, line.leadout/2, syl.text)

io.write_line(l)

def lyrics(line, l):
# Translation Effect
l.start_time = line.start_time - line.leadin/2
l.end_time = line.end_time + line.leadout/2
l.dur = l.end_time - l.start_time

l.text = "{\\fad(%d,%d)}%s" % (
line.leadin/2, line.leadout/2, line.text_stripped)

io.write_line(l)

for li, line in enumerate(lines):
# Generating lines
if line.styleref.alignment >= 4:
romaji_kanji(line, line.copy())
elif line.styleref.alignment <= 3:
lyrics(line, line.copy())

io.save()
Loading

0 comments on commit 5628d5d

Please sign in to comment.