Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.stack-work/
_cache/
_site/
.DS_Store

# Emacs backups
*~
1 change: 1 addition & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ supportedLanguages :: [String]
supportedLanguages = [ -- Name here the directories of the programming languages to be supported
"haskell"
, "functional-full-stack" -- Haskell backend + PureScript frontend
, "python"
]

markdownPattern :: Pattern
Expand Down
3 changes: 3 additions & 0 deletions templates/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h2>
</div>
</div>

$if(lts)$
<p>
Tested with:
<ul>
Expand Down Expand Up @@ -76,6 +77,8 @@ <h2>
$endif$
</ul>
</p>
$endif$

<div>
<div class="social-links-inline">
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.6.5
16 changes: 16 additions & 0 deletions tutorials/python/python-video-generation/code/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
flake8 = "*"
pylint = "*"
autopep8 = "*"

[packages]
moviepy = "==1.0.0"
gizeh = "==0.1.11"

[requires]
python_version = "3.6"
336 changes: 336 additions & 0 deletions tutorials/python/python-video-generation/code/Pipfile.lock

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions tutorials/python/python-video-generation/code/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Local environment set up
---

## Install Python 3

### Linux and OSX
Using version manager [asdf-vm](https://asdf-vm.com/#/core-manage-asdf-vm?id=install-asdf-vm):

##### Install [Python Plugin](https://github.com/danhper/asdf-python):
``` bash
$ asdf plugin-add python https://github.com/danhper/asdf-python.git
```

##### Install Python:
Python version is specified in `.tools-versions` file.
``` bash
$ asdf install
```

**Note:** This can be installed using package managers as well, the instruction
may vary according to your package manager:
- In Ubuntu:
```bash
sudo apt-get install python3
```
- In OSx:
```bash
brew install python3
```

### Windows
Using package manager [Chocolatey](https://chocolatey.org/)

``` bash
C:\> choco install python3
```

#### Install dependencies

From root project directory run:
``` bash
$ pipenv install
```

#### Enable your virtual environment

From root project folder, enable virtual env typing
``` bash
pipenv shell
```

#### To generate the video

With pipenv virtualenv enabled and from the root project folder run
``` bash
python python_video.py
```

**Note:** It's possible to execute the script directly with `pipenv` using:
``` bash
pipenv run python python_video.py
```

#### Disable Virtual Environment
To Disable it type `exit`

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions tutorials/python/python-video-generation/code/python_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import moviepy.editor as mpy
import gizeh as gz
from math import pi


VIDEO_SIZE = (640, 480)
BLUE = (59/255, 89/255, 152/255)
GREEN = (176/255, 210/255, 63/255)
WHITE = (255, 255, 255)
WHITE_GIZEH = (1, 1, 1)
SB_LOGO_PATH = './assets/StackBuildersLogo.jpg'
DURATION = 10


def render_text(t):
surface = gz.Surface(640, 60, bg_color=WHITE_GIZEH)
text = gz.text(
"Let's build together", fontfamily="Charter",
fontsize=30, fontweight='bold', fill=BLUE, xy=(320, 40))
text.draw(surface)
return surface.get_npimage()


def draw_stars(t):
surface = gz.Surface(640, 120, bg_color=WHITE_GIZEH)
for i in range(5):
star = gz.star(
nbranches=5, radius=120*0.2, ratio=0.5,
xy=[100*(i+1), 50], fill=GREEN, angle=t * pi)
star.draw(surface)
return surface.get_npimage()


if __name__ == '__main__':
sb_logo = mpy.ImageClip(SB_LOGO_PATH). \
set_position(('center', 0)).resize(width=200)
text = mpy.VideoClip(render_text, duration=DURATION)
stars = mpy.VideoClip(draw_stars, duration=DURATION)

video = mpy.CompositeVideoClip(
[
sb_logo,
text.set_position(
('center', sb_logo.size[1])),
stars.set_position(
('center', sb_logo.size[1] + text.size[1])
)
],
size=VIDEO_SIZE).\
on_color(
color=WHITE,
col_opacity=1).set_duration(DURATION)

video.write_videofile('video_with_python.mp4', fps=10)
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading