Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ceb591

Browse files
Sorting image examples.
1 parent df077a1 commit 3ceb591

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

Basics/E01_Basics/E00_HelloWorld.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
def draw(contextName):
3636
context = getContext(contextName)
37+
exportPath = '%s/%s-%s.pdf' % (EXPORT, FILENAME, doc.context.name)
3738
doc = Document(w=W, h=H, context=context)
3839
# Gets the first page from te document.
3940
page = doc[1]
@@ -55,9 +56,6 @@ def draw(contextName):
5556
textBox = newText('Hello World', parent=page, font=FONTNAME, fontSize=96,
5657
x=W/4, y=W/4, w=W/2, h=H/2, fill=f, **options)
5758

58-
# Export in _export folder that does not commit in Git. Force to export
59-
# PDF.
60-
exportPath = '%s/%s-%s.pdf' % (EXPORT, FILENAME, doc.context.name)
6159
doc.export(exportPath)
6260

6361
for contextName in ('DrawBot', 'Flat'):

Basics/E01_Basics/E06_BasicElements.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ def draw(contextName):
116116

117117
newBezierCurve(closed=False, points=points, fill=getColor(5), **options)
118118
newGlyphPath(font['Q'], fill=getColor(6), **options)
119-
page.solve()
119+
#newImage()
120+
120121

121-
# Export in _export folder that does not commit in Git. Force to export PDF.
122+
123+
# Sets alignmetns and saves the results as a PDF.
124+
page.solve()
122125
doc.export(exportPath)
123126

124127

Basics/E06_Images/E00_ImagePosition.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
#
1414
# E00_ImagePosition.py
1515
#
16-
# Position an image element in the page.
17-
#
18-
import os # Import module that communicates with the file system.
19-
import sys
16+
# Position an image element on the page.
2017

18+
import os
19+
import sys
20+
from pagebot import getContext
21+
from pagebot.conditions import *
22+
from pagebot.constants import A4, LEFT, RIGHT, BOTTOM, TOP, EXPORT
2123
from pagebot.document import Document
24+
from pagebot.elements import *
2225
from pagebot.filepaths import getResourcesPath
26+
from pagebot.toolbox.transformer import path2FileName
2327
from pagebot.toolbox.units import pt, mm
24-
from pagebot import getContext
25-
from pagebot.constants import A4, LEFT, RIGHT, BOTTOM, TOP
26-
from pagebot.elements import *
27-
from pagebot.conditions import *
2828

29-
def imagePosition(contextName):
30-
context = getContext(contextName)
31-
W, H = pt(400, 400)
32-
33-
P = pt(30) # Padding of the page
29+
FILENAME = path2FileName(__file__)
30+
W, H = pt(400, 400)
31+
P = pt(30) # Page padding.
3432

35-
EXPORT_PATH = '_export/00_ImagePosition-%s.pdf' % contextName
33+
def draw(contextName):
34+
context = getContext(contextName)
35+
exportPath = '%s/%s-%s.pdf' % (EXPORT, FILENAME, contextName)
3636

3737
# Define the path where to find the example image.
3838
path = getResourcesPath() + "/images/cookbot1.jpg"
@@ -57,10 +57,7 @@ def imagePosition(contextName):
5757
newImage(path, x=page.w-P, y=page.h-P, h=page.ph/2, parent=page,
5858
xAlign=RIGHT, yAlign=TOP, fill=(1, 1, 0, 0.5), rotate=90)
5959

60-
doc.export(EXPORT_PATH)
60+
doc.export(exportPath)
6161

62-
for contextName in (
63-
'DrawBot',
64-
'Flat',
65-
):
66-
imagePosition(contextName)
62+
for contextName in ('DrawBot', 'Flat'):
63+
draw(contextName)
File renamed without changes.

Basics/E06_Images/11_UseImageObjectFilters.md renamed to Basics/E06_Images/E11_UseImageObjectFilters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,4 @@ Transitions from one image to another by creating a circular wave that expands f
489489
##swipeTransition(targetImage=None, extent=None, color=None, time=None, angle=None, width=None, opacity=None)
490490
Transitions from one image to another by simulating a swiping action.
491491
*Attributes: targetImage an Image object, extent a tuple (x, y, w, h), color RGBA tuple Color (r, g, b, a), time a float, angle a float in degrees, width a float, opacity a float.*
492+
*

0 commit comments

Comments
 (0)