Initial release. v0.1.0
21
.editorconfig
Normal file
@@ -0,0 +1,21 @@
|
||||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
|
||||
[*.bat]
|
||||
indent_style = tab
|
||||
end_of_line = crlf
|
||||
|
||||
[LICENSE]
|
||||
insert_final_newline = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
15
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
* nider version:
|
||||
* Python version:
|
||||
* Operating System:
|
||||
|
||||
### Description
|
||||
|
||||
Describe what you were trying to get done.
|
||||
Tell us what happened, what went wrong, and what you expected to happen.
|
||||
|
||||
### What I Did
|
||||
|
||||
```
|
||||
Paste the command(s) you ran and the output.
|
||||
If there was a crash, please include the traceback here.
|
||||
```
|
||||
62
.gitignore
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# pyenv python configuration file
|
||||
.python-version
|
||||
29
.travis.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This file was autogenerated and will overwrite each time you run travis_pypi_setup.py
|
||||
deploy:
|
||||
distributions: sdist bdist_wheel
|
||||
user: pythad
|
||||
provider: pypi
|
||||
true:
|
||||
python: 3.5
|
||||
repo: pythad/nider
|
||||
tags: true
|
||||
password:
|
||||
secure: !!binary |
|
||||
Y0ZRVmI4MHpreFp0UHFsRTU2YWIvQ25rR0tBZFpkRDBEYlNqcXRtZ0wzaW8venkxcWIxeGhjL0RR
|
||||
RjEvOFdEbE5XYUliRHpLd3M2U3dUbHI5U0hrbm5veStaSjQvM1NjWXFWblVtMTd4disySGpTY1Zi
|
||||
WlpGaVlkVEhHa2tid0Nlbk11VWR3ZDJkZEhxL1dBQXFsR0lWN1JFU3VFNVppRkhWekRubUpSbEdr
|
||||
c0JZOFNQVm40MUtiQWxGajJZbUYwaml0WDBvME1FMkZjSnIzM1hIS2dQQmZ5dXVGZHNwQ1ovNFdv
|
||||
aS9rZGpDU1VYQXp1UkdPdkE4NTJrUVU0Qmg3cUtQZDNucDl6WDEwcDRCZDNjRlhMb3gzWTE1L0Z1
|
||||
d1M4ZkRmZFc3d0RyMElEcG41SEtRTWVTLzFQb0c1cjhlbGlTYTAwbHJzSlBudStRNldadExpdUdM
|
||||
c0dBU3d0UjBVYkMxc1Q2ZGdCTlMrbXVaZVphT1NVOWNJQ1ZTSW85T1Zwc01maXgreVZkbUpRb2N1
|
||||
Mk1zckRCZ0xReVVyMCtTS2ZLNVEwTm1BSS9SV2ZXWnFkMDNNbE9NT1p1TTlKbDhZUFg1T1drbzVR
|
||||
TDU4dDFrZnJWYWJtSHBNbnJ4RjZPTUZXa0RaMVp2TGI5eWpVR0xwNUNTakRodlVMRSs1QmlaSXEx
|
||||
OEZNaVg3Uk5UMC9vRk9EZzZOWG1tTDhDVlYvVFdZdGUxVlNoMDliallEdy9CZHUyelVDMzJTZ0h1
|
||||
eHFtK0cwV3RoOENuMWVQejlYYjM2SkREaXhFaFBSbUF1VHdDVGhMMUVReGI5cWwvSU5IWVVhbVND
|
||||
dkJFWUh5T3BjUmI0clN0aHlDWFEzcmRMd3JOSUc1dWsybk9BVmQ2Z0twdlFrbGJWNTNZejI2bjg9
|
||||
install: pip install -U tox-travis
|
||||
language: python
|
||||
python:
|
||||
- 3.5
|
||||
- 3.4
|
||||
script: tox
|
||||
13
AUTHORS.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
=======
|
||||
Credits
|
||||
=======
|
||||
|
||||
Development Lead
|
||||
----------------
|
||||
|
||||
* Vladyslav Ovchynnykov <ovd4mail@gmail.com>
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
None yet. Why not be the first?
|
||||
114
CONTRIBUTING.rst
Normal file
@@ -0,0 +1,114 @@
|
||||
.. highlight:: shell
|
||||
|
||||
============
|
||||
Contributing
|
||||
============
|
||||
|
||||
Contributions are welcome, and they are greatly appreciated! Every
|
||||
little bit helps, and credit will always be given.
|
||||
|
||||
You can contribute in many ways:
|
||||
|
||||
Types of Contributions
|
||||
----------------------
|
||||
|
||||
Report Bugs
|
||||
~~~~~~~~~~~
|
||||
|
||||
Report bugs at https://github.com/pythad/nider/issues.
|
||||
|
||||
If you are reporting a bug, please include:
|
||||
|
||||
* Your operating system name and version.
|
||||
* Any details about your local setup that might be helpful in troubleshooting.
|
||||
* Detailed steps to reproduce the bug.
|
||||
|
||||
Fix Bugs
|
||||
~~~~~~~~
|
||||
|
||||
Look through the GitHub issues for bugs. Anything tagged with "bug"
|
||||
and "help wanted" is open to whoever wants to implement it.
|
||||
|
||||
Implement Features
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Look through the GitHub issues for features. Anything tagged with "enhancement"
|
||||
and "help wanted" is open to whoever wants to implement it.
|
||||
|
||||
Write Documentation
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
nider could always use more documentation, whether as part of the
|
||||
official nider docs, in docstrings, or even on the web in blog posts,
|
||||
articles, and such.
|
||||
|
||||
Submit Feedback
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
The best way to send feedback is to file an issue at https://github.com/pythad/nider/issues.
|
||||
|
||||
If you are proposing a feature:
|
||||
|
||||
* Explain in detail how it would work.
|
||||
* Keep the scope as narrow as possible, to make it easier to implement.
|
||||
* Remember that this is a volunteer-driven project, and that contributions
|
||||
are welcome :)
|
||||
|
||||
Get Started!
|
||||
------------
|
||||
|
||||
Ready to contribute? Here's how to set up `nider` for local development.
|
||||
|
||||
1. Fork the `nider` repo on GitHub.
|
||||
2. Clone your fork locally::
|
||||
|
||||
$ git clone git@github.com:your_name_here/nider.git
|
||||
|
||||
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
|
||||
|
||||
$ mkvirtualenv nider
|
||||
$ cd nider/
|
||||
$ python setup.py develop
|
||||
|
||||
4. Create a branch for local development::
|
||||
|
||||
$ git checkout -b name-of-your-bugfix-or-feature
|
||||
|
||||
Now you can make your changes locally.
|
||||
|
||||
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
|
||||
|
||||
$ flake8 nider tests
|
||||
$ python setup.py test or py.test
|
||||
$ tox
|
||||
|
||||
To get flake8 and tox, just pip install them into your virtualenv.
|
||||
|
||||
6. Commit your changes and push your branch to GitHub::
|
||||
|
||||
$ git add .
|
||||
$ git commit -m "Your detailed description of your changes."
|
||||
$ git push origin name-of-your-bugfix-or-feature
|
||||
|
||||
7. Submit a pull request through the GitHub website.
|
||||
|
||||
Pull Request Guidelines
|
||||
-----------------------
|
||||
|
||||
Before you submit a pull request, check that it meets these guidelines:
|
||||
|
||||
1. The pull request should include tests.
|
||||
2. If the pull request adds functionality, the docs should be updated. Put
|
||||
your new functionality into a function with a docstring, and add the
|
||||
feature to the list in README.rst.
|
||||
3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check
|
||||
https://travis-ci.org/pythad/nider/pull_requests
|
||||
and make sure that the tests pass for all supported Python versions.
|
||||
|
||||
Tips
|
||||
----
|
||||
|
||||
To run a subset of tests::
|
||||
|
||||
|
||||
$ python -m unittest tests.test_nider
|
||||
8
HISTORY.rst
Normal file
@@ -0,0 +1,8 @@
|
||||
=======
|
||||
History
|
||||
=======
|
||||
|
||||
0.1.0 (2017-07-27)
|
||||
------------------
|
||||
|
||||
* First release on PyPI.
|
||||
11
LICENSE
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017, Vladyslav Ovchynnykov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
11
MANIFEST.in
Normal file
@@ -0,0 +1,11 @@
|
||||
include AUTHORS.rst
|
||||
include CONTRIBUTING.rst
|
||||
include HISTORY.rst
|
||||
include LICENSE
|
||||
include README.rst
|
||||
|
||||
recursive-include tests *
|
||||
recursive-exclude * __pycache__
|
||||
recursive-exclude * *.py[co]
|
||||
|
||||
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
|
||||
87
Makefile
Normal file
@@ -0,0 +1,87 @@
|
||||
.PHONY: clean clean-test clean-pyc clean-build docs help
|
||||
.DEFAULT_GOAL := help
|
||||
define BROWSER_PYSCRIPT
|
||||
import os, webbrowser, sys
|
||||
try:
|
||||
from urllib import pathname2url
|
||||
except:
|
||||
from urllib.request import pathname2url
|
||||
|
||||
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
|
||||
endef
|
||||
export BROWSER_PYSCRIPT
|
||||
|
||||
define PRINT_HELP_PYSCRIPT
|
||||
import re, sys
|
||||
|
||||
for line in sys.stdin:
|
||||
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
|
||||
if match:
|
||||
target, help = match.groups()
|
||||
print("%-20s %s" % (target, help))
|
||||
endef
|
||||
export PRINT_HELP_PYSCRIPT
|
||||
BROWSER := python -c "$$BROWSER_PYSCRIPT"
|
||||
|
||||
help:
|
||||
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
|
||||
|
||||
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
|
||||
|
||||
|
||||
clean-build: ## remove build artifacts
|
||||
rm -fr build/
|
||||
rm -fr dist/
|
||||
rm -fr .eggs/
|
||||
find . -name '*.egg-info' -exec rm -fr {} +
|
||||
find . -name '*.egg' -exec rm -f {} +
|
||||
|
||||
clean-pyc: ## remove Python file artifacts
|
||||
find . -name '*.pyc' -exec rm -f {} +
|
||||
find . -name '*.pyo' -exec rm -f {} +
|
||||
find . -name '*~' -exec rm -f {} +
|
||||
find . -name '__pycache__' -exec rm -fr {} +
|
||||
|
||||
clean-test: ## remove test and coverage artifacts
|
||||
rm -fr .tox/
|
||||
rm -f .coverage
|
||||
rm -fr htmlcov/
|
||||
|
||||
lint: ## check style with flake8
|
||||
flake8 nider tests
|
||||
|
||||
test: ## run tests quickly with the default Python
|
||||
|
||||
python setup.py test
|
||||
|
||||
test-all: ## run tests on every Python version with tox
|
||||
tox
|
||||
|
||||
coverage: ## check code coverage quickly with the default Python
|
||||
coverage run --source nider setup.py test
|
||||
coverage report -m
|
||||
coverage html
|
||||
$(BROWSER) htmlcov/index.html
|
||||
|
||||
docs: ## generate Sphinx HTML documentation, including API docs
|
||||
rm -f docs/nider.rst
|
||||
rm -f docs/modules.rst
|
||||
sphinx-apidoc -o docs/ nider
|
||||
$(MAKE) -C docs clean
|
||||
$(MAKE) -C docs html
|
||||
$(BROWSER) docs/_build/html/index.html
|
||||
|
||||
servedocs: docs ## compile the docs watching for changes
|
||||
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
|
||||
|
||||
release: clean ## package and upload a release
|
||||
python setup.py sdist upload
|
||||
python setup.py bdist_wheel upload
|
||||
|
||||
dist: clean ## builds source and wheel package
|
||||
python setup.py sdist
|
||||
python setup.py bdist_wheel
|
||||
ls -l dist
|
||||
|
||||
install: clean ## install the package to the active Python's site-packages
|
||||
python setup.py install
|
||||
106
README.rst
Normal file
@@ -0,0 +1,106 @@
|
||||
=====
|
||||
nider
|
||||
=====
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/nider.svg
|
||||
:target: https://pypi.python.org/pypi/nider
|
||||
|
||||
.. image:: https://img.shields.io/travis/pythad/nider.svg
|
||||
:target: https://travis-ci.org/pythad/nider
|
||||
|
||||
.. image:: https://readthedocs.org/projects/nider/badge/?version=latest
|
||||
:target: https://nider.readthedocs.io/en/latest/?badge=latest
|
||||
:alt: Documentation Status
|
||||
|
||||
.. image:: https://pyup.io/repos/github/pythad/nider/shield.svg
|
||||
:target: https://pyup.io/repos/github/pythad/nider/
|
||||
:alt: Updates
|
||||
|
||||
|
||||
Python package to add text to images, textures and different backgrounds
|
||||
|
||||
|
||||
* Free software: MIT license
|
||||
* Documentation: https://nider.readthedocs.io.
|
||||
|
||||
``nider`` is an approach to make generation of text based images simple yet flexible. Creating of an image is as simple as describing units you want to be rendered to the image and choosing a method that will be used for drawing.
|
||||
|
||||
************
|
||||
Installation
|
||||
************
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install nider
|
||||
|
||||
********
|
||||
Features
|
||||
********
|
||||
|
||||
Drawing on a texture
|
||||
====================
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Content
|
||||
from nider.models import Header
|
||||
from nider.models import Linkback
|
||||
from nider.models import Paragraph
|
||||
from nider.models import TwitterPost
|
||||
|
||||
# TODO: change this fontpath to the fontpath on your machine
|
||||
roboto = '/home/ovd/.local/share/fonts/Roboto/'
|
||||
|
||||
header = Header(text='Your super interesting title!',
|
||||
fontfullpath=roboto + 'Roboto-Bold.ttf',
|
||||
fontsize=30,
|
||||
text_width=40,
|
||||
align='left',
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
para = Paragraph(text='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
|
||||
fontfullpath=roboto + 'Roboto-Medium.ttf',
|
||||
fontsize=29,
|
||||
text_width=65,
|
||||
align='left',
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
linkback = Linkback(text='foo.com | @username',
|
||||
fontfullpath=roboto + 'Roboto-Bold.ttf',
|
||||
fontsize=24,
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
content = Content(para, header=header, linkback=linkback, padding=60)
|
||||
|
||||
img = TwitterPost(content,
|
||||
fullpath='result.png',
|
||||
)
|
||||
|
||||
# TODO: change this texture path to the texture path on your machine
|
||||
img.draw_on_texture('texture.png')
|
||||
|
||||
|
||||
.. image:: https://github.com/pythad/nider/raw/master/examples/draw_on_texture_example/result.png
|
||||
:alt: Draw on texture example
|
||||
|
||||
Drawing on a solid color
|
||||
========================
|
||||
|
||||
.. image:: https://github.com/pythad/nider/raw/master/examples/draw_on_bg_example/result.png
|
||||
:alt: Draw on background example
|
||||
:height: 500px
|
||||
:width: 500px
|
||||
|
||||
Drawing on an image
|
||||
===================
|
||||
|
||||
.. image:: https://github.com/pythad/nider/raw/master/examples/draw_on_image_example/result.png
|
||||
:alt: Draw on image example
|
||||
|
||||
|
||||
===================
|
||||
|
||||
Code used to generate featured images can be found `here <https://github.com/pythad/nider/tree/master/examples>`_
|
||||
3
docs/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/nider.rst
|
||||
/nider.*.rst
|
||||
/modules.rst
|
||||
177
docs/Makefile
Normal file
@@ -0,0 +1,177 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/nider.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/nider.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/nider"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/nider"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
1
docs/authors.rst
Normal file
@@ -0,0 +1 @@
|
||||
.. include:: ../AUTHORS.rst
|
||||
275
docs/conf.py
Executable file
@@ -0,0 +1,275 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# nider documentation build configuration file, created by
|
||||
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another
|
||||
# directory, add these directories to sys.path here. If the directory is
|
||||
# relative to the documentation root, use os.path.abspath to make it
|
||||
# absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# Get the project root dir, which is the parent dir of this
|
||||
cwd = os.getcwd()
|
||||
project_root = os.path.dirname(cwd)
|
||||
|
||||
# Insert the project root dir as the first element in the PYTHONPATH.
|
||||
# This lets us ensure that the source package is imported, and that its
|
||||
# version is used.
|
||||
sys.path.insert(0, project_root)
|
||||
|
||||
import nider
|
||||
|
||||
# -- General configuration ---------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'nider'
|
||||
copyright = u"2017, Vladyslav Ovchynnykov"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement
|
||||
# for |version| and |release|, also used in various other places throughout
|
||||
# the built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = nider.__version__
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = nider.__version__
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to
|
||||
# some non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built
|
||||
# documents.
|
||||
#keep_warnings = False
|
||||
|
||||
|
||||
# -- 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 = 'default'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a
|
||||
# theme further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as
|
||||
# html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the
|
||||
# top of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon
|
||||
# of the docs. This file should be a Windows icon file (.ico) being
|
||||
# 16x16 or 32x32 pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# 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']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page
|
||||
# bottom, using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names
|
||||
# to template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer.
|
||||
# Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer.
|
||||
# Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages
|
||||
# will contain a <link> tag referring to it. The value of this option
|
||||
# must be the base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'niderdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass
|
||||
# [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'nider.tex',
|
||||
u'nider Documentation',
|
||||
u'Vladyslav Ovchynnykov', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at
|
||||
# the top of the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings
|
||||
# are parts, not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'nider',
|
||||
u'nider Documentation',
|
||||
[u'Vladyslav Ovchynnykov'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- 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 = [
|
||||
('index', 'nider',
|
||||
u'nider Documentation',
|
||||
u'Vladyslav Ovchynnykov',
|
||||
'nider',
|
||||
'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
1
docs/contributing.rst
Normal file
@@ -0,0 +1 @@
|
||||
.. include:: ../CONTRIBUTING.rst
|
||||
1
docs/history.rst
Normal file
@@ -0,0 +1 @@
|
||||
.. include:: ../HISTORY.rst
|
||||
BIN
docs/images/available_units.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
22
docs/index.rst
Normal file
@@ -0,0 +1,22 @@
|
||||
Welcome to nider's documentation!
|
||||
======================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
readme
|
||||
installation
|
||||
usage
|
||||
modules
|
||||
contributing
|
||||
authors
|
||||
history
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
51
docs/installation.rst
Normal file
@@ -0,0 +1,51 @@
|
||||
.. highlight:: shell
|
||||
|
||||
============
|
||||
Installation
|
||||
============
|
||||
|
||||
|
||||
Stable release
|
||||
--------------
|
||||
|
||||
To install nider, run this command in your terminal:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install nider
|
||||
|
||||
This is the preferred method to install nider, as it will always install the most recent stable release.
|
||||
|
||||
If you don't have `pip`_ installed, this `Python installation guide`_ can guide
|
||||
you through the process.
|
||||
|
||||
.. _pip: https://pip.pypa.io
|
||||
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
|
||||
|
||||
|
||||
From sources
|
||||
------------
|
||||
|
||||
The sources for nider can be downloaded from the `Github repo`_.
|
||||
|
||||
You can either clone the public repository:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clone git://github.com/pythad/nider
|
||||
|
||||
Or download the `tarball`_:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ curl -OL https://github.com/pythad/nider/tarball/master
|
||||
|
||||
Once you have a copy of the source, you can install it with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ python setup.py install
|
||||
|
||||
|
||||
.. _Github repo: https://github.com/pythad/nider
|
||||
.. _tarball: https://github.com/pythad/nider/tarball/master
|
||||
242
docs/make.bat
Normal file
@@ -0,0 +1,242 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=_build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
if "%1" == "help" (
|
||||
:help
|
||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||
echo. html to make standalone HTML files
|
||||
echo. dirhtml to make HTML files named index.html in directories
|
||||
echo. singlehtml to make a single large HTML file
|
||||
echo. pickle to make pickle files
|
||||
echo. json to make JSON files
|
||||
echo. htmlhelp to make HTML files and a HTML help project
|
||||
echo. qthelp to make HTML files and a qthelp project
|
||||
echo. devhelp to make HTML files and a Devhelp project
|
||||
echo. epub to make an epub
|
||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||
echo. text to make text files
|
||||
echo. man to make manual pages
|
||||
echo. texinfo to make Texinfo files
|
||||
echo. gettext to make PO message catalogs
|
||||
echo. changes to make an overview over all changed/added/deprecated items
|
||||
echo. xml to make Docutils-native XML files
|
||||
echo. pseudoxml to make pseudoxml-XML files for display purposes
|
||||
echo. linkcheck to check all external links for integrity
|
||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "clean" (
|
||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||
del /q /s %BUILDDIR%\*
|
||||
goto end
|
||||
)
|
||||
|
||||
|
||||
%SPHINXBUILD% 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
|
||||
)
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dirhtml" (
|
||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "singlehtml" (
|
||||
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pickle" (
|
||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the pickle files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "json" (
|
||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the JSON files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "qthelp" (
|
||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\nider.qhcp
|
||||
echo.To view the help file:
|
||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\nider.ghc
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "devhelp" (
|
||||
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "epub" (
|
||||
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latex" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdf" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf
|
||||
cd %BUILDDIR%/..
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdfja" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf-ja
|
||||
cd %BUILDDIR%/..
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "text" (
|
||||
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "man" (
|
||||
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "texinfo" (
|
||||
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "gettext" (
|
||||
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "changes" (
|
||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.The overview file is in %BUILDDIR%/changes.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "linkcheck" (
|
||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Link check complete; look for any errors in the above output ^
|
||||
or in %BUILDDIR%/linkcheck/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "doctest" (
|
||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of doctests in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/doctest/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "xml" (
|
||||
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The XML files are in %BUILDDIR%/xml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pseudoxml" (
|
||||
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
|
||||
goto end
|
||||
)
|
||||
|
||||
:end
|
||||
1
docs/readme.rst
Normal file
@@ -0,0 +1 @@
|
||||
.. include:: ../README.rst
|
||||
375
docs/usage.rst
Normal file
@@ -0,0 +1,375 @@
|
||||
=====
|
||||
Usage
|
||||
=====
|
||||
|
||||
TODO: say that content.padding isn't always took into consideration
|
||||
|
||||
This article is a tutorial for ``nider`` package and at the same time it is a full reference of all ``nider`` models and possibilities.
|
||||
|
||||
***********
|
||||
Image units
|
||||
***********
|
||||
|
||||
There are three main units each ``nider.Image`` can consist of:
|
||||
|
||||
- header
|
||||
- paragraph
|
||||
- linkback
|
||||
|
||||
.. image:: images/available_units.png
|
||||
|
||||
Paragraph unit is required for each image whereas header and linkback are optional.
|
||||
|
||||
Each of the units is represented by a class in ``nider.models``:
|
||||
|
||||
- ``nider.models.Header``
|
||||
- ``nider.models.Paragraph``
|
||||
- ``nider.models.Linkback``
|
||||
|
||||
``nider.models.Header``
|
||||
=========================
|
||||
|
||||
.. class:: Header(text, \
|
||||
fontfullpath, fontsize=18, \
|
||||
text_width=21, line_padding=6, \
|
||||
color='#000', drop_shadow=False, shadowcolor='#646464', \
|
||||
align='center')
|
||||
|
||||
Base class for the header unit
|
||||
|
||||
:param str text: Text used in the header
|
||||
:param str fontfullpath: Path to the font used in the header
|
||||
:param int text_width: Header's text width - number of characters in a line
|
||||
:param int line_padding: Header's line padding - padding (in pixels) between the lines
|
||||
:param int fontsize: Size of the font
|
||||
:param color: Either hex or rgb representation of text color
|
||||
:type color: str or tuple(int, int, int)
|
||||
:param bool drop_shadow: Boolean flag that indicates if text has to drop shadow
|
||||
:param shadowcolor: Either hex or rgb representation of shadowcolor color
|
||||
:type shadowcolor: str or tuple(int, int, int)
|
||||
:param align: Side with respect to which the text will be aligned
|
||||
:type align: 'left' or 'center' or 'right'
|
||||
:raises nider.exceptions.InvalidAlignException: if ``align`` is not one of 'left' or 'center' or 'right'
|
||||
:raises nider.exceptions.DefaultFontWarning: if ``fontfullpath`` is ``None``
|
||||
:raises nider.exceptions.FontNotFoundWarning: if ``fontfullpath`` does not exist
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Header
|
||||
|
||||
header = Header(text='Your super interesting title!',
|
||||
fontfullpath='/home/me/.local/share/fonts/Roboto/Roboto-Bold.ttf',
|
||||
fontsize=30,
|
||||
text_width=40,
|
||||
align='left',
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
|
||||
``nider.models.Paragraph``
|
||||
============================
|
||||
|
||||
The class has the same attribures and behaviour as ``nider.models.Header``.
|
||||
|
||||
.. class:: Paragraph(text, \
|
||||
fontfullpath, fontsize=18, \
|
||||
text_width=21, line_padding=6, \
|
||||
color='#000', drop_shadow=False, shadowcolor='#646464', \
|
||||
align='center')
|
||||
|
||||
Base class for the paragraph unit
|
||||
|
||||
:param str text: Text used in the paragraph
|
||||
:param str fontfullpath: Path to the font used in the paragraph
|
||||
:param int text_width: Paragraph's text width - number of characters in a line
|
||||
:param int line_padding: Paragraph's line padding - padding (in pixels) between the lines
|
||||
:param int fontsize: Size of the font
|
||||
:param color: Either hex or rgb representation of text color
|
||||
:type color: str or tuple(int, int, int)
|
||||
:param bool drop_shadow: Boolean flag that indicates if text has to drop shadow
|
||||
:param shadowcolor: Either hex or rgb representation of shadowcolor color
|
||||
:type shadowcolor: str or tuple(int, int, int)
|
||||
:param align: Side with respect to which the text will be aligned
|
||||
:type align: 'left' or 'center' or 'right'
|
||||
:raises nider.exceptions.InvalidAlignException: if ``align`` is not one of 'left' or 'center' or 'right'
|
||||
:raises nider.exceptions.DefaultFontWarning: if ``fontfullpath`` is ``None``
|
||||
:raises nider.exceptions.FontNotFoundWarning: if ``fontfullpath`` does not exist
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Paragraph
|
||||
|
||||
para = Paragraph(text='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
|
||||
fontfullpath='/home/me/.local/share/fonts/Roboto/Roboto-Medium.ttf',
|
||||
fontsize=29,
|
||||
text_width=65,
|
||||
align='left',
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
|
||||
``nider.models.Linkback``
|
||||
===========================
|
||||
|
||||
.. class:: Linkback(text, \
|
||||
fontfullpath, fontsize=18, \
|
||||
color='#000', drop_shadow=False, shadowcolor='#646464', \
|
||||
align='center', bottom_padding=20)
|
||||
|
||||
Base class for the linkback unit
|
||||
|
||||
:param str text: Text used in the linkback
|
||||
:param str fontfullpath: Path to the font used in the linkback
|
||||
:param int fontsize: Size of the font
|
||||
:param color: Either hex or rgb representation of text color
|
||||
:type color: str or tuple(int, int, int)
|
||||
:param bool drop_shadow: Boolean flag that indicates if text has to drop shadow
|
||||
:param shadowcolor: Either hex or rgb representation of shadowcolor color
|
||||
:type shadowcolor: str or tuple(int, int, int)
|
||||
:param align: Side with respect to which the text will be aligned
|
||||
:type align: 'left' or 'center' or 'right'
|
||||
:param int bottom_padding: Linkback's bottom padding - padding (in pixels) between the bottom of the image and the linkback itself
|
||||
:raises nider.exceptions.InvalidAlignException: if ``align`` is not one of 'left' or 'center' or 'right'
|
||||
:raises nider.exceptions.DefaultFontWarning: if ``fontfullpath`` is ``None``
|
||||
:raises nider.exceptions.FontNotFoundWarning: if ``fontfullpath`` does not exist
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Linkback
|
||||
|
||||
linkback = Linkback(text='foo.com | @username',
|
||||
fontfullpath='/home/me/.local/share/fonts/Roboto/Roboto-Bold.ttf',
|
||||
fontsize=24,
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
*************
|
||||
Image content
|
||||
*************
|
||||
|
||||
In order to aggregate all of the units together you need to create an instance of ``nider.models.Content`` class.
|
||||
|
||||
``nider.models.Content``
|
||||
==========================
|
||||
|
||||
.. class:: Content(paragraph, header=None, linkback=None, padding=45)
|
||||
|
||||
Class that aggregates different units into a sigle object
|
||||
|
||||
:param nider.models.Paragraph paragraph: Paragraph that will be used
|
||||
:param nider.models.Header header: Header that will be used
|
||||
:param nider.models.Linkback linkback: Linkback that will be used
|
||||
:param int padding: Content's padding - padding (in pixels) between the units
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Content
|
||||
from nider.models import Linkback
|
||||
from nider.models import Paragraph
|
||||
|
||||
para = Paragraph(...)
|
||||
|
||||
linkback = Linkback(...)
|
||||
|
||||
content = Content(para, linkback=linkback, padding=60)
|
||||
|
||||
|
||||
*********************
|
||||
Initializing an image
|
||||
*********************
|
||||
|
||||
After the content is prepared it's the right time to initialize an image. In ``nider`` a basic image is represented by ``nider.models.Image``
|
||||
|
||||
``nider.models.Image``
|
||||
========================
|
||||
|
||||
.. class:: Image(content, fullpath, width=1080, height=1080)
|
||||
|
||||
Base class for a text based image
|
||||
|
||||
:param nider.models.Content content: Content object that has units to be rendered
|
||||
:param str fullpath: Path where the image has to be saved
|
||||
:param int width: Width of the image
|
||||
:param int height: Height of the image
|
||||
:raises AttributeError: if it's impossible to create a file at ``fullpath`` path
|
||||
:raises AttributeError: if width <= 0 or height <= 0
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Content
|
||||
from nider.models import Image
|
||||
|
||||
content = Content(...)
|
||||
|
||||
img = Image(content,
|
||||
fullpath='example.png',
|
||||
width=500,
|
||||
height=500
|
||||
)
|
||||
|
||||
Social media images
|
||||
-------------------
|
||||
|
||||
``nider`` comes with some pre-built models that can be used to generate images for some social networks. These are subclasses of ``nider.models.Image`` with changed size
|
||||
|
||||
Instagram
|
||||
^^^^^^^^^
|
||||
|
||||
- ``nider.models.InstagramSquarePost`` - 1080x1080 image
|
||||
- ``nider.models.InstagramPortraitPost`` - 1080x1350 image
|
||||
- ``nider.models.InstagramLandscapePost`` - 1080x566 image
|
||||
|
||||
Facebook
|
||||
^^^^^^^^
|
||||
|
||||
- ``nider.models.FacebookSquarePost`` - 470x470 image
|
||||
- ``nider.models.FacebookLandscapePost`` - 1024x512 image
|
||||
|
||||
Twitter
|
||||
^^^^^^^
|
||||
|
||||
- ``nider.models.TwitterPost`` - 1024x512 image
|
||||
- ``nider.TwitterLargeCard`` - 506x506 image
|
||||
|
||||
============
|
||||
|
||||
I highly recommend reading this `post <https://blog.bufferapp.com/ideal-image-sizes-social-media-posts>`_ if you are curious about what are the right image sizes for social media images.
|
||||
|
||||
********************
|
||||
Drawing on the image
|
||||
********************
|
||||
|
||||
Having an instance of ``nider.models.Image`` we are ready to create a real image.
|
||||
|
||||
``nider`` comes with 3 options of drawing your image:
|
||||
|
||||
- ``Image.draw_on_texture`` - draws preinitialized image and its attributes on a texture. **nider takes care of filling image of any size with textrure you privide. You don't need to create textured images by pasting texture mulpitle times in Photoshop or Gimp.**
|
||||
|
||||
- ``Image.draw_on_bg`` - Draws preinitialized image and its attributes on a colored background. nider uses a color you provide to fill the image and then draws the content.
|
||||
|
||||
- ``Image.draw_on_image`` - Draws preinitialized image and its attributes on an image. Content will be drawn directly on the image you provide.
|
||||
|
||||
|
||||
``Image.draw_on_texture``
|
||||
=========================
|
||||
|
||||
.. method:: draw_on_texture(texture_path=None)
|
||||
|
||||
Draws preinitiated image and its attributes on a texture. If ``texture_path``
|
||||
is set to ``None``, takes random textures from ``textures/``
|
||||
|
||||
:param str texture_path: Path of the texture to use
|
||||
|
||||
:raises FileNotFoundError: if the file at ``texture_path`` cannot be found
|
||||
:raises nider.exceptions.ImageSizeFixedWarning: if the image size has to be adjusted to the provided content's size because the content takes much space
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Content
|
||||
from nider.models import Image
|
||||
|
||||
content = Content(...)
|
||||
|
||||
img = Image(content,
|
||||
fullpath='example.png',
|
||||
width=500,
|
||||
height=500
|
||||
)
|
||||
|
||||
img.draw_on_texture('example_texture.png')
|
||||
|
||||
|
||||
Check the full example `here <https://github.com/pythad/nider/blob/master/examples/draw_on_texture_example/script.py>`_
|
||||
|
||||
============
|
||||
|
||||
``nider`` comes with a `huge bundle of textures <https://github.com/pythad/nider/tree/master/nider/textures>`_. As for now you need to copy them to your machine if you want to use any of them.
|
||||
|
||||
``Image.draw_on_bg``
|
||||
=========================
|
||||
|
||||
.. method:: draw_on_bg(bgcolor=None)
|
||||
|
||||
Draws preinitiated image and its attributes on a colored background. If ``bgcolor``
|
||||
is set to ``None``, random ``nider.colors.colormap.FLAT_UI`` color is generated
|
||||
|
||||
:param bgcolor: Either hex or rgb representation of background color
|
||||
:type bgcolor: str or tuple(int, int, int)
|
||||
|
||||
:raises nider.exceptions.ImageSizeFixedWarning: if the image size has to be adjusted to the provided content's size because the content takes much space
|
||||
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Content
|
||||
from nider.models import Image
|
||||
|
||||
content = Content(...)
|
||||
|
||||
img = Image(content,
|
||||
fullpath='example.png',
|
||||
width=500,
|
||||
height=500
|
||||
)
|
||||
|
||||
img.draw_on_bg('#efefef')
|
||||
|
||||
Check the full example `here <https://github.com/pythad/nider/blob/master/examples/draw_on_bg_example/script.py>`_
|
||||
|
||||
``Image.draw_on_image``
|
||||
=========================
|
||||
|
||||
.. method:: draw_on_image(image_path)
|
||||
|
||||
Draws preinitiated image and its attributes on an image. Image size will be changed to the size of provided image.
|
||||
|
||||
:param str image_path: Path of the image to draw on
|
||||
|
||||
:raises FileNotFoundError: if the file at ``image_path`` cannot be found
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nider.models import Content
|
||||
from nider.models import Image
|
||||
|
||||
content = Content(...)
|
||||
|
||||
img = Image(content,
|
||||
fullpath='example.png',
|
||||
width=500,
|
||||
height=500
|
||||
)
|
||||
|
||||
img.draw_on_image('example_bg.jpg')
|
||||
|
||||
Check the full example `here <https://github.com/pythad/nider/blob/master/examples/draw_on_image_example/script.py>`_
|
||||
|
||||
============
|
||||
|
||||
That's it. After any of draw methods has been called and successfully completed the new image will be saved to ``Image.fullpath``.
|
||||
BIN
examples/draw_on_bg_example/result.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
23
examples/draw_on_bg_example/script.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from nider.models import Content
|
||||
from nider.models import Paragraph
|
||||
from nider.models import InstagramSquarePost
|
||||
|
||||
# TODO: change this fontpath to the fontpath on your machine
|
||||
roboto = '/home/ovd/.local/share/fonts/Roboto/'
|
||||
|
||||
|
||||
para = Paragraph(text='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
|
||||
fontfullpath=roboto + 'Roboto-Medium.ttf',
|
||||
fontsize=41,
|
||||
text_width=49,
|
||||
align='center',
|
||||
color='#121212'
|
||||
)
|
||||
|
||||
content = Content(para, padding=60)
|
||||
|
||||
img = InstagramSquarePost(content,
|
||||
fullpath='result.png',
|
||||
)
|
||||
|
||||
img.draw_on_bg('#efefef')
|
||||
BIN
examples/draw_on_image_example/bg.jpg
Normal file
|
After Width: | Height: | Size: 364 KiB |
BIN
examples/draw_on_image_example/result.png
Normal file
|
After Width: | Height: | Size: 728 KiB |
47
examples/draw_on_image_example/script.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from nider.models import Content
|
||||
from nider.models import Header
|
||||
from nider.models import Linkback
|
||||
from nider.models import Paragraph
|
||||
from nider.models import Image
|
||||
|
||||
# TODO: change this fontpath to the fontpath on your machine
|
||||
roboto = '/home/ovd/.local/share/fonts/Roboto/'
|
||||
|
||||
header = Header(text='Your super interesting title!',
|
||||
fontfullpath=roboto + 'Roboto-Bold.ttf',
|
||||
fontsize=30,
|
||||
text_width=40,
|
||||
align='left',
|
||||
color='#ededed',
|
||||
drop_shadow=True,
|
||||
shadowcolor='#999'
|
||||
)
|
||||
|
||||
para = Paragraph(text='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
|
||||
fontfullpath=roboto + 'Roboto-Medium.ttf',
|
||||
fontsize=29,
|
||||
text_width=65,
|
||||
align='left',
|
||||
color='#ededed',
|
||||
drop_shadow=True,
|
||||
shadowcolor='#999'
|
||||
)
|
||||
|
||||
linkback = Linkback(text='foo.com | @username',
|
||||
fontfullpath=roboto + 'Roboto-Bold.ttf',
|
||||
fontsize=24,
|
||||
color='#ededed',
|
||||
drop_shadow=True,
|
||||
shadowcolor='#999'
|
||||
)
|
||||
|
||||
content = Content(para, header=header, linkback=linkback, padding=60)
|
||||
|
||||
img = Image(content,
|
||||
fullpath='result.png',
|
||||
width=1080,
|
||||
height=720
|
||||
)
|
||||
|
||||
# TODO: change this image path to the image path on your machine
|
||||
img.draw_on_image('bg.jpg')
|
||||
BIN
examples/draw_on_texture_example/result.png
Normal file
|
After Width: | Height: | Size: 243 KiB |
39
examples/draw_on_texture_example/script.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from nider.models import Content
|
||||
from nider.models import Header
|
||||
from nider.models import Linkback
|
||||
from nider.models import Paragraph
|
||||
from nider.models import TwitterPost
|
||||
|
||||
# TODO: change this fontpath to the fontpath on your machine
|
||||
roboto = '/home/ovd/.local/share/fonts/Roboto/'
|
||||
|
||||
header = Header(text='Your super interesting title!',
|
||||
fontfullpath=roboto + 'Roboto-Bold.ttf',
|
||||
fontsize=30,
|
||||
text_width=40,
|
||||
align='left',
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
para = Paragraph(text='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
|
||||
fontfullpath=roboto + 'Roboto-Medium.ttf',
|
||||
fontsize=29,
|
||||
text_width=65,
|
||||
align='left',
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
linkback = Linkback(text='foo.com | @username',
|
||||
fontfullpath=roboto + 'Roboto-Bold.ttf',
|
||||
fontsize=24,
|
||||
color='#ededed'
|
||||
)
|
||||
|
||||
content = Content(para, header=header, linkback=linkback, padding=60)
|
||||
|
||||
img = TwitterPost(content,
|
||||
fullpath='result.png',
|
||||
)
|
||||
|
||||
# TODO: change this texture path to the texture path on your machine
|
||||
img.draw_on_texture('texture.png')
|
||||
BIN
examples/draw_on_texture_example/texture.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
7
nider/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Top-level package for nider."""
|
||||
|
||||
__author__ = """Vladyslav Ovchynnykov"""
|
||||
__email__ = 'ovd4mail@gmail.com'
|
||||
__version__ = '0.1.0'
|
||||
6
nider/colors/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from .colormap import BASIC_COLORS
|
||||
from .colormap import FLAT_UI_COLORS
|
||||
from .colormap import COLORS
|
||||
from .colormap import rgb
|
||||
|
||||
from .utils import color_to_rgb
|
||||
62
nider/colors/colormap.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from collections import namedtuple
|
||||
from collections import ChainMap
|
||||
|
||||
rgb = namedtuple('Color', ['R', 'G', 'B'])
|
||||
|
||||
# RGB : color mappings
|
||||
BASIC_COLORS_RGB_TO_NAME = {
|
||||
rgb(255, 255, 255): ['white'],
|
||||
rgb(0, 0, 0): ['black'],
|
||||
rgb(255, 0, 0): ['red'],
|
||||
rgb(0, 255, 0): ['lime'],
|
||||
rgb(0, 0, 255): ['blue'],
|
||||
rgb(255, 255, 0): ['yellow'],
|
||||
rgb(0, 255, 255): ['cyan', 'aqua'],
|
||||
rgb(255, 0, 255): ['magenta', 'fuchsia'],
|
||||
rgb(192, 192, 192): ['silver'],
|
||||
rgb(128, 128, 128): ['gray'],
|
||||
rgb(128, 0, 0): ['maroon'],
|
||||
rgb(128, 128, 0): ['olive'],
|
||||
rgb(0, 128, 0): ['green'],
|
||||
rgb(128, 0, 128): ['purple'],
|
||||
rgb(0, 128, 128): ['teal'],
|
||||
rgb(0, 0, 128): ['navy'],
|
||||
|
||||
}
|
||||
|
||||
FLAT_UI_COLORS_RGB_TO_NAMES = {
|
||||
rgb(26, 188, 156): ['turquoise'],
|
||||
rgb(46, 204, 113): ['emerland'],
|
||||
rgb(52, 152, 219): ['peterriver'],
|
||||
rgb(155, 89, 182): ['amethyst'],
|
||||
rgb(52, 73, 94): ['wetasphalt'],
|
||||
rgb(22, 160, 133): ['greensea'],
|
||||
rgb(39, 174, 96): ['nephritis'],
|
||||
rgb(41, 128, 185): ['belizehole'],
|
||||
rgb(142, 68, 173): ['wisteria'],
|
||||
rgb(44, 62, 80): ['midnightblue'],
|
||||
rgb(241, 196, 15): ['sunflower'],
|
||||
rgb(230, 126, 34): ['carrot'],
|
||||
rgb(231, 76, 60): ['alizarin'],
|
||||
rgb(236, 240, 241): ['clouds'],
|
||||
rgb(149, 165, 166): ['concrete'],
|
||||
rgb(243, 156, 18): ['orange'],
|
||||
rgb(211, 84, 0): ['pumpkin'],
|
||||
rgb(192, 57, 43): ['pomegranate'],
|
||||
rgb(189, 195, 199): ['silver'],
|
||||
rgb(127, 140, 141): ['asbestos']
|
||||
}
|
||||
|
||||
# color : RGB mappings
|
||||
BASIC_COLORS = dict(
|
||||
(name.lower(), rgb)
|
||||
for rgb, names in BASIC_COLORS_RGB_TO_NAME.items()
|
||||
for name in names)
|
||||
|
||||
FLAT_UI_COLORS = dict(
|
||||
(name.lower(), rgb)
|
||||
for rgb, names in FLAT_UI_COLORS_RGB_TO_NAMES.items()
|
||||
for name in names)
|
||||
|
||||
# dictionary of all availabe colors
|
||||
COLORS = dict(ChainMap(BASIC_COLORS, FLAT_UI_COLORS))
|
||||
10
nider/colors/utils.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import webcolors
|
||||
|
||||
from nider.colors import rgb
|
||||
|
||||
|
||||
def color_to_rgb(color):
|
||||
try:
|
||||
return rgb(*webcolors.hex_to_rgb(color))
|
||||
except TypeError:
|
||||
return rgb(*color)
|
||||
114
nider/core.py
Normal file
@@ -0,0 +1,114 @@
|
||||
import textwrap
|
||||
|
||||
from nider.utils import get_font
|
||||
|
||||
from nider.mixins import MultilineTextMixin
|
||||
from nider.mixins import AlignMixin
|
||||
from nider.colors.utils import color_to_rgb
|
||||
|
||||
|
||||
class Text:
|
||||
'''Base class for the text
|
||||
|
||||
Attributes:
|
||||
text (str): text used in the object.
|
||||
fontfullpath (str): path to the font used in the object.
|
||||
fontsize (int): size of the font.
|
||||
color (str, tuple): either hex or rgb representation of text color.
|
||||
drop_shadow (bool): boolean flag that indicates if text has to drop shadow.
|
||||
shadowcolor (str, tuple): either hex or rgb representation of shadowcolor color.
|
||||
'''
|
||||
|
||||
def __init__(self, text, fontfullpath,
|
||||
fontsize, color, drop_shadow, shadowcolor):
|
||||
self._set_text(text)
|
||||
self.fontfullpath = fontfullpath
|
||||
self.fontsize = fontsize
|
||||
self._set_font()
|
||||
self._set_decoration(color, drop_shadow, shadowcolor)
|
||||
|
||||
def _set_text(self, text):
|
||||
'''Sets object's text data'''
|
||||
self.text = text
|
||||
|
||||
def _set_font(self):
|
||||
'''Sets object's font'''
|
||||
self.font = get_font(self.fontfullpath, self.fontsize)
|
||||
|
||||
def _set_decoration(self, color, drop_shadow, shadowcolor):
|
||||
'''Sets object's color and shadow'''
|
||||
self.color = color_to_rgb(color)
|
||||
if drop_shadow is True:
|
||||
self.drop_shadow = drop_shadow
|
||||
self.shadowcolor = color_to_rgb(shadowcolor)
|
||||
else:
|
||||
self.drop_shadow = False
|
||||
self.shadowcolor = None
|
||||
|
||||
|
||||
class MultilineText(MultilineTextMixin, Text):
|
||||
'''Base class for the multiline text'''
|
||||
|
||||
def __init__(self, text_width, line_padding, *args, **kwargs):
|
||||
MultilineTextMixin.__init__(
|
||||
self, text_width=text_width, line_padding=line_padding)
|
||||
Text.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
class SingleLineTextUnit(AlignMixin, Text):
|
||||
'''Base class for the single line text unit'''
|
||||
|
||||
def __init__(self, text, fontfullpath,
|
||||
fontsize=18, align='right',
|
||||
color='#000', drop_shadow=False, shadowcolor='#646464'
|
||||
):
|
||||
AlignMixin.__init__(self, align=align)
|
||||
Text.__init__(
|
||||
self, text=text, fontfullpath=fontfullpath, fontsize=fontsize,
|
||||
color=color, drop_shadow=drop_shadow,
|
||||
shadowcolor=shadowcolor
|
||||
)
|
||||
self._set_height()
|
||||
|
||||
def _set_height(self):
|
||||
'''Sets unit\'s height'''
|
||||
_, self.height = self.font.getsize(self.text)
|
||||
|
||||
|
||||
class MultilineTextUnit(AlignMixin, MultilineText):
|
||||
'''Base class for the multiline text unit'''
|
||||
|
||||
def __init__(self, text,
|
||||
fontfullpath, fontsize=18,
|
||||
text_width=21, line_padding=6,
|
||||
color='#000', drop_shadow=False, shadowcolor='#646464',
|
||||
align='center'):
|
||||
AlignMixin.__init__(self, align=align)
|
||||
MultilineText.__init__(self, text=text,
|
||||
fontfullpath=fontfullpath, fontsize=fontsize,
|
||||
text_width=text_width, line_padding=line_padding,
|
||||
color=color, drop_shadow=drop_shadow,
|
||||
shadowcolor=shadowcolor
|
||||
)
|
||||
self._set_unit()
|
||||
|
||||
def _set_unit(self):
|
||||
'''Sets a unit used in the image
|
||||
|
||||
Sets textwraped unit's text that will be used in the image and also
|
||||
attachs header height to the obj instance
|
||||
'''
|
||||
self.wrapped_lines = textwrap.wrap(self.text, width=self.text_width)
|
||||
self._set_height()
|
||||
|
||||
def _set_height(self):
|
||||
'''Sets unit's height used in the image
|
||||
|
||||
Calculates unit's height by adding height of each line and its padding
|
||||
'''
|
||||
self.height = 0
|
||||
for line in self.wrapped_lines:
|
||||
_, h = self.font.getsize(line)
|
||||
self.height += h
|
||||
|
||||
self.height += (len(self.wrapped_lines) - 1) * self.line_padding
|
||||
33
nider/exceptions.py
Normal file
@@ -0,0 +1,33 @@
|
||||
class ImageGeneratorException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ImageGeneratorWarning(Warning):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidAlignException(ImageGeneratorException):
|
||||
def __init__(self, align_provided, available_aligns=None):
|
||||
if available_aligns is None:
|
||||
available_aligns = ['center', 'right', 'left']
|
||||
available_aligns_str = ' or '.join(available_aligns)
|
||||
super().__init__(
|
||||
"Align has to be set either to {}. You provided '{}'".format(available_aligns_str, align_provided))
|
||||
|
||||
|
||||
class FontNotFoundWarning(ImageGeneratorWarning):
|
||||
def __init__(self, fontpath_provided):
|
||||
super().__init__(
|
||||
"Font {} hasn't been found. Default font has been set instead".format(fontpath_provided))
|
||||
|
||||
|
||||
class DefaultFontWarning(ImageGeneratorWarning):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
"Font hasn't been provided. Default font has been set instead")
|
||||
|
||||
|
||||
class ImageSizeFixedWarning(ImageGeneratorWarning):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
"Image size has been adjusted to the provided content size because the content took too much space")
|
||||
3
nider/mixins/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .img_components_mixins import AlignMixin
|
||||
|
||||
from .text_mixins import MultilineTextMixin
|
||||
14
nider/mixins/img_components_mixins.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from nider.exceptions import InvalidAlignException
|
||||
|
||||
|
||||
class AlignMixin:
|
||||
|
||||
def __init__(self, align):
|
||||
self._set_align(align)
|
||||
|
||||
def _set_align(self, align):
|
||||
'''Sets align for the child object'''
|
||||
possible_aligns = ['right', 'center', 'left']
|
||||
if align not in possible_aligns:
|
||||
raise InvalidAlignException(align)
|
||||
self.align = align
|
||||
14
nider/mixins/text_mixins.py
Normal file
@@ -0,0 +1,14 @@
|
||||
class MultilineTextMixin:
|
||||
|
||||
def __init__(self, text_width, line_padding):
|
||||
self._set_text_width(text_width)
|
||||
self.line_padding = line_padding
|
||||
|
||||
def _set_text_width(self, text_width):
|
||||
'''Sets text_width used in the child object'''
|
||||
if text_width > 0:
|
||||
self.text_width = text_width
|
||||
else:
|
||||
raise AttributeError(
|
||||
'{} text_width has to be an instance of int and > 0'.format(
|
||||
self.__class__.__name__))
|
||||
339
nider/models.py
Normal file
@@ -0,0 +1,339 @@
|
||||
import math
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from PIL import Image as PILImage
|
||||
from PIL import ImageDraw
|
||||
|
||||
from nider.core import MultilineTextUnit
|
||||
from nider.core import SingleLineTextUnit
|
||||
|
||||
from nider.utils import get_random_bgcolor
|
||||
from nider.utils import get_random_texture
|
||||
from nider.utils import is_path_creatable
|
||||
|
||||
from nider.colors import color_to_rgb
|
||||
|
||||
from nider.exceptions import ImageSizeFixedWarning
|
||||
|
||||
Header = MultilineTextUnit
|
||||
Header.__doc__ = 'Base class for the header unit'
|
||||
Paragraph = MultilineTextUnit
|
||||
Paragraph.__doc__ = 'Base class for the paragraph unit'
|
||||
|
||||
|
||||
class Linkback(SingleLineTextUnit):
|
||||
'''Class that represents a linkback used in images
|
||||
|
||||
Attributes:
|
||||
bottom_padding (int): padding to step back from the bottom of the image.
|
||||
'''
|
||||
|
||||
def __init__(self, bottom_padding=20, *args, **kwargs):
|
||||
self.bottom_padding = bottom_padding
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def _set_height(self):
|
||||
'''Sets linkback\'s height'''
|
||||
super()._set_height()
|
||||
self.height += self.bottom_padding
|
||||
|
||||
|
||||
class Content:
|
||||
'''Class that aggregates different units into a sigle object'''
|
||||
# Variable to check if the content fits into the img. Default is true,
|
||||
# but it may changed by in Img._fix_image_size()
|
||||
fits = True
|
||||
|
||||
def __init__(self, paragraph, header=None, linkback=None, padding=45):
|
||||
self.para = paragraph
|
||||
self.header = header
|
||||
self.linkback = linkback
|
||||
self.padding = padding
|
||||
self._set_content_height()
|
||||
|
||||
def _set_content_height(self):
|
||||
'''Sets content\'s height'''
|
||||
self.height = self.para.height + 2 * self.padding
|
||||
if self.header:
|
||||
self.height += 1 * self.padding + self.header.height
|
||||
if self.linkback:
|
||||
self.height += self.linkback.height
|
||||
|
||||
|
||||
class Image:
|
||||
'''Base class for a text based image
|
||||
|
||||
Attributes:
|
||||
content (nider.models.Content): object that has units to be rendered.
|
||||
fullpath (str): path where the image has to be saved.
|
||||
width (int): width of the image.
|
||||
height (int): height of the image.
|
||||
'''
|
||||
|
||||
def __init__(self, content, fullpath, width=1080, height=1080):
|
||||
self._set_content(content)
|
||||
self._set_fullpath(fullpath)
|
||||
self._set_image_size(width, height)
|
||||
|
||||
def draw_on_texture(self, texture_path=None):
|
||||
'''Draws preinitialized image and its attributes on a texture
|
||||
|
||||
Draws preinitiated image and its attributes on a texture. If texture_path
|
||||
is set to None, takes random textures from textures/
|
||||
|
||||
Attributes:
|
||||
texture_path (str): path of the texture to use.
|
||||
'''
|
||||
if texture_path is None:
|
||||
texture_path = get_random_texture()
|
||||
elif not os.path.isfile(texture_path):
|
||||
raise FileNotFoundError(
|
||||
'Can\'t find texture {}. Please, choose an existing texture'.format(texture_path))
|
||||
self._create_image()
|
||||
self._create_draw_object()
|
||||
self._fill_image_with_texture(texture_path)
|
||||
self._draw_content()
|
||||
self._save()
|
||||
|
||||
def draw_on_bg(self, bgcolor=None):
|
||||
'''Draws preinitialized image and its attributes on a colored background
|
||||
|
||||
Draws preinitiated image and its attributes on a colored background. If bgcolor
|
||||
is set to None, random nider.colors.colormap.FLAT_UI color is generated
|
||||
|
||||
Attributes:
|
||||
bgcolor (str, tuple): either hex or rgb representation of background color.
|
||||
'''
|
||||
self.bgcolor = color_to_rgb(
|
||||
bgcolor) if bgcolor else get_random_bgcolor()
|
||||
self._create_image()
|
||||
self._create_draw_object()
|
||||
self._fill_image_with_color()
|
||||
self._draw_content()
|
||||
self._save()
|
||||
|
||||
def draw_on_image(self, image_path):
|
||||
'''Draws preinitialized image and its attributes on an image
|
||||
|
||||
Attributes:
|
||||
image_path (str): path of the image to draw on.
|
||||
'''
|
||||
if not os.path.isfile(image_path):
|
||||
raise FileNotFoundError(
|
||||
'Can\'t find image {}. Please, choose an existing image'.format(image_path))
|
||||
self.image = PILImage.open(image_path)
|
||||
self._create_draw_object()
|
||||
self.width, self.height = self.image.size
|
||||
self._draw_content()
|
||||
self._save()
|
||||
|
||||
def _save(self):
|
||||
'''Saves the image'''
|
||||
self.image.save(self.fullpath)
|
||||
|
||||
def _set_content(self, content):
|
||||
'''Sets content used in the image'''
|
||||
self.content = content
|
||||
self.header = content.header
|
||||
self.para = content.para
|
||||
self.linkback = content.linkback
|
||||
|
||||
def _set_fullpath(self, fullpath):
|
||||
'''Sets path where to save the image'''
|
||||
if is_path_creatable(fullpath):
|
||||
self.fullpath = fullpath
|
||||
else:
|
||||
raise AttributeError(
|
||||
"Is seems impossible to create a file in path {}".format(fullpath))
|
||||
|
||||
def _set_image_size(self, width, height):
|
||||
'''Sets width and height of the image'''
|
||||
if width <= 0 or height <= 0:
|
||||
raise AttributeError(
|
||||
"Width or height of the image have to be positive integers")
|
||||
self.width = width
|
||||
self.height = height
|
||||
|
||||
def _fix_image_size(self):
|
||||
'''Fixes image's size'''
|
||||
|
||||
if self.content.height >= self.height:
|
||||
warnings.warn(ImageSizeFixedWarning())
|
||||
self.content.fits = False
|
||||
self.height = self.content.height
|
||||
|
||||
def _create_image(self):
|
||||
'''Creates a basic PIL image
|
||||
|
||||
Creates a basic PIL image previously fixing its size
|
||||
'''
|
||||
self._fix_image_size()
|
||||
self.image = PILImage.new("RGBA", (self.width, self.height))
|
||||
|
||||
def _create_draw_object(self):
|
||||
'''Creates a basic PIL Draw object'''
|
||||
self.draw = ImageDraw.Draw(self.image)
|
||||
|
||||
def _fill_image_with_texture(self, texture_path):
|
||||
'''Fills an image with a texture
|
||||
|
||||
Fills an image with a texture by reapiting it necessary number of times
|
||||
|
||||
Attributes:
|
||||
texture_path (str): path of the texture to use
|
||||
'''
|
||||
texture = PILImage.open(texture_path, 'r')
|
||||
texture_w, texture_h = texture.size
|
||||
bg_w, bg_h = self.image.size
|
||||
times_for_Ox = math.ceil(bg_w / texture_w)
|
||||
times_for_Oy = math.ceil(bg_h / texture_h)
|
||||
for y in range(times_for_Oy):
|
||||
for x in range(times_for_Ox):
|
||||
offset = (x * texture_w, y * texture_h)
|
||||
self.image.paste(texture, offset)
|
||||
|
||||
def _fill_image_with_color(self):
|
||||
'''Fills an image with a color
|
||||
|
||||
Fills an image with a color by creating a colored rectangle of the image
|
||||
size
|
||||
'''
|
||||
self.draw.rectangle([(0, 0), self.image.size], fill=self.bgcolor)
|
||||
|
||||
def _draw_content(self):
|
||||
'''Draws each unit of the content on the image'''
|
||||
if self.header:
|
||||
self._draw_header()
|
||||
if self.para:
|
||||
self._draw_para()
|
||||
if self.linkback:
|
||||
self._draw_linkback()
|
||||
|
||||
def _draw_header(self):
|
||||
'''Draws the header on the image'''
|
||||
current_h = self.content.padding
|
||||
self._draw_unit(current_h, self.header)
|
||||
|
||||
def _draw_para(self):
|
||||
'''Draws the paragraph on the image'''
|
||||
if self.content.fits:
|
||||
# Trying to center everything
|
||||
current_h = math.floor(
|
||||
(self.height - self.para.height) / 2)
|
||||
self._draw_unit(current_h, self.para)
|
||||
else:
|
||||
if self.header:
|
||||
header_with_padding_height = 2 * self.content.padding + self.header.height
|
||||
current_h = header_with_padding_height
|
||||
else:
|
||||
current_h = self.content.padding
|
||||
self._draw_unit(current_h, self.para)
|
||||
|
||||
def _draw_linkback(self):
|
||||
'''Draws a linkback on the image'''
|
||||
current_h = self.height - self.linkback.height
|
||||
self._draw_unit(current_h, self.linkback)
|
||||
|
||||
def _draw_unit(self, start_height, unit):
|
||||
'''Draws the text and its pseudo-shadow on the image starting at specific height'''
|
||||
current_h = start_height
|
||||
try:
|
||||
lines = unit.wrapped_lines
|
||||
except AttributeError:
|
||||
# text is a one-liner. Construct a list out of it for later usage
|
||||
lines = [unit.text]
|
||||
line_padding = getattr(unit, 'line_padding', None)
|
||||
for line in lines:
|
||||
w, h = self.draw.textsize(line, font=unit.font)
|
||||
if unit.align == "center":
|
||||
x = (self.width - w) / 2
|
||||
elif unit.align == "left":
|
||||
x = self.width * 0.075
|
||||
elif unit.align == "right":
|
||||
x = 0.925 * self.width - w
|
||||
y = current_h
|
||||
|
||||
if unit.drop_shadow:
|
||||
# thin border
|
||||
self.draw.text((x - 1, y), line, font=unit.font,
|
||||
fill=unit.shadowcolor)
|
||||
self.draw.text((x + 1, y), line, font=unit.font,
|
||||
fill=unit.shadowcolor)
|
||||
self.draw.text((x, y - 1), line, font=unit.font,
|
||||
fill=unit.shadowcolor)
|
||||
self.draw.text((x, y + 1), line, font=unit.font,
|
||||
fill=unit.shadowcolor)
|
||||
|
||||
# thicker border
|
||||
# self.draw.text((x - 1, y - 1), line, font=unit.font,
|
||||
# fill=unit.shadowcolor)
|
||||
# self.draw.text((x + 1, y - 1), line, font=unit.font,
|
||||
# fill=unit.shadowcolor)
|
||||
# self.draw.text((x - 1, y + 1), line, font=unit.font,
|
||||
# fill=unit.shadowcolor)
|
||||
# self.draw.text((x + 1, y + 1), line, font=unit.font,
|
||||
# fill=unit.shadowcolor)
|
||||
# end shadow
|
||||
|
||||
self.draw.text((x, y), line, unit.color, font=unit.font)
|
||||
|
||||
if line_padding:
|
||||
current_h += h + line_padding
|
||||
|
||||
|
||||
class FacebookSquarePost(Image):
|
||||
'''Alias of models.Image with width=470 and height=470'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['width'] = kwargs.get('width', 470)
|
||||
kwargs['height'] = kwargs.get('height', 470)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class FacebookLandscapePost(Image):
|
||||
'''Alias of models.Image with width=1024 and height=512'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['width'] = kwargs.get('width', 1024)
|
||||
kwargs['height'] = kwargs.get('height', 512)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
TwitterPost = FacebookLandscapePost
|
||||
|
||||
|
||||
class TwitterLargeCard(Image):
|
||||
'''Alias of models.Image with width=506 and height=506'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['width'] = kwargs.get('width', 506)
|
||||
kwargs['height'] = kwargs.get('height', 506)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class InstagramSquarePost(Image):
|
||||
'''Alias of models.Image with width=1080 and height=1080'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['width'] = kwargs.get('width', 1080)
|
||||
kwargs['height'] = kwargs.get('height', 1080)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class InstagramPortraitPost(Image):
|
||||
'''Alias of models.Image with width=1080 and height=1350'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['width'] = kwargs.get('width', 1080)
|
||||
kwargs['height'] = kwargs.get('height', 1350)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class InstagramLandscapePost(Image):
|
||||
'''Alias of models.Image with width=1080 and height=566'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['width'] = kwargs.get('width', 1080)
|
||||
kwargs['height'] = kwargs.get('height', 566)
|
||||
super().__init__(*args, **kwargs)
|
||||
BIN
nider/textures/Sports.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
nider/textures/asanoha-400px.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
nider/textures/asfalt.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
nider/textures/binding_dark.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
nider/textures/black_paper.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
nider/textures/black_thread.png
Normal file
|
After Width: | Height: | Size: 783 B |
BIN
nider/textures/blackmamba.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
nider/textures/broken_noise.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
nider/textures/cartographer.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
nider/textures/circles-and-roundabouts.png.png
Normal file
|
After Width: | Height: | Size: 304 KiB |
BIN
nider/textures/congruent_outline.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
nider/textures/congruent_pentagon.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
nider/textures/cream_dust.png
Normal file
|
After Width: | Height: | Size: 661 B |
BIN
nider/textures/crissXcross.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
nider/textures/crossword.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
nider/textures/dark_embroidery.png
Normal file
|
After Width: | Height: | Size: 286 B |
BIN
nider/textures/dark_geometric.png
Normal file
|
After Width: | Height: | Size: 817 B |
BIN
nider/textures/dark_leather.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
nider/textures/dark_mosaic.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
nider/textures/dark_wall.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
nider/textures/dark_wood.png
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
nider/textures/debut_dark.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
nider/textures/denim.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
nider/textures/diagmonds.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
nider/textures/dirty_old_shirt.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
nider/textures/eight_horns.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
nider/textures/elastoplast.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
nider/textures/ep_naturalblack.png
Normal file
|
After Width: | Height: | Size: 256 KiB |
BIN
nider/textures/escheresque_ste.png
Normal file
|
After Width: | Height: | Size: 493 B |
BIN
nider/textures/extra_clean_paper.png
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
nider/textures/foggy_birds.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
nider/textures/footer_lodyas.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
nider/textures/fresh_snow.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
nider/textures/geometry.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
nider/textures/geometry2.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
nider/textures/gplaypattern.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
nider/textures/gray_sand.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
nider/textures/grey.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
nider/textures/handmadepaper.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
nider/textures/ice_age.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
nider/textures/irongrip.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
nider/textures/light_wool.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
nider/textures/lightpaperfibers.png
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
nider/textures/navy_blue.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
nider/textures/old_mathematics.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
nider/textures/paper_fibers.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
nider/textures/photography.png
Normal file
|
After Width: | Height: | Size: 1005 B |
BIN
nider/textures/pink dust.png
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
nider/textures/random_grey_variations.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
nider/textures/redox_01.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
nider/textures/retina_wood.png
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
nider/textures/sakura.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
nider/textures/sayagata-400px.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
nider/textures/school.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
nider/textures/snow.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
nider/textures/stardust.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
nider/textures/subtle_white_feathers.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
nider/textures/swirl_pattern.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
nider/textures/symphony.png
Normal file
|
After Width: | Height: | Size: 19 KiB |