User:Simon/Trim4/Layout using Flat: Difference between revisions
(Created page with "[https://xxyxyz.org/flat#tutorial Tutorial for Flat ], a Python library that can be used to create layouts and graphics. This is from the website, with commenting above each l...") |
No edit summary |
||
Line 22: | Line 22: | ||
hello.png<br> | hello.png<br> | ||
[[File: | [[File:Flat_Hello.png|100px]] | ||
hello.svg<br> | hello.svg<br> | ||
[[File: | [[File:Flat_Hello.svg|100px]] | ||
hello.pdf<br> | hello.pdf<br> | ||
[[File: | [[File:Flat_Hello.pdf|100px]] |
Revision as of 12:31, 4 October 2019
Tutorial for Flat , a Python library that can be used to create layouts and graphics. This is from the website, with commenting above each line:
from flat import rgb, font, shape, strike, document red = rgb(255, 0, 0) lato = font.open('Lato-Reg.otf') figure = shape().stroke(red).width(2.5) headline = strike(lato).color(red).size(20, 24) d = document(100, 100, 'mm') p = d.addpage() p.place(figure.circle(50, 50, 20)) p.place(headline.text('Hello world!')).frame(10, 10, 80, 80) # create a .png p.image(kind='rgb').png('hello.png') # create an .svg p.svg('hello.svg') # create a .pdf d.pdf('hello.pdf')
Running this scripts produces three files:
hello.svg
File:Flat Hello.svg
hello.pdf
File:Flat Hello.pdf