Skip to content

Commit ce5b588

Browse files
Merge pull request #239 from fontra/reformat-with-black
Reformat with black, and replace ... with pass
2 parents 31c7587 + 6007157 commit ce5b588

14 files changed

Lines changed: 65 additions & 53 deletions

Lib/blackrenderer/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from .render import renderText
66
from .backends import listBackends
77

8-
98
backendsAndSuffixes = listBackends()
109
backendNames = [backendName for backendName, _ in backendsAndSuffixes]
1110

Lib/blackrenderer/backends/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections import defaultdict
22
import importlib
33

4-
54
_surfaces = {
65
None: {
76
"cairo": "blackrenderer.backends.cairo.CairoPixelSurface",

Lib/blackrenderer/backends/base.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
class Canvas(ABC):
66
@abstractmethod
77
def newPath(self):
8-
...
8+
pass
99

1010
@abstractmethod
1111
@contextmanager
1212
def savedState(self):
13-
...
13+
pass
1414

1515
@abstractmethod
1616
@contextmanager
1717
def compositeMode(self, compositeMode):
18-
...
18+
pass
1919

2020
@abstractmethod
2121
def transform(self, transform):
22-
...
22+
pass
2323

2424
@abstractmethod
2525
def clipPath(self, path):
26-
...
26+
pass
2727

2828
@abstractmethod
2929
def drawPathSolid(self, path, color):
30-
...
30+
pass
3131

3232
@abstractmethod
3333
def drawPathLinearGradient(
3434
self, path, colorLine, pt1, pt2, extendMode, gradientTransform
3535
):
36-
...
36+
pass
3737

3838
@abstractmethod
3939
def drawPathRadialGradient(
@@ -47,7 +47,7 @@ def drawPathRadialGradient(
4747
extendMode,
4848
gradientTransform,
4949
):
50-
...
50+
pass
5151

5252
@abstractmethod
5353
def drawPathSweepGradient(
@@ -60,7 +60,7 @@ def drawPathSweepGradient(
6060
extendMode,
6161
gradientTransform,
6262
):
63-
...
63+
pass
6464

6565
# Generic convenience methods
6666

@@ -100,14 +100,14 @@ class Surface(ABC):
100100

101101
@abstractmethod
102102
def __init__(self):
103-
...
103+
pass
104104

105105
@abstractmethod
106106
@contextmanager
107107
def canvas(self, boundingBox):
108108
# boundingBox = (xMin, yMin, xMax, yMax)
109-
...
109+
pass
110110

111111
@abstractmethod
112112
def saveImage(self, path):
113-
...
113+
pass

Lib/blackrenderer/backends/cairo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from .base import Canvas, Surface
99
from .sweepGradient import buildSweepGradientPatches
1010

11-
1211
_compositeModeMap = {
1312
CompositeMode.CLEAR: cairo.OPERATOR_CLEAR,
1413
CompositeMode.SRC: cairo.OPERATOR_SOURCE,
@@ -167,7 +166,12 @@ def drawPathSweepGradient(
167166
maxY = max(d * d for d in (y1 - center[1], y2 - center[1]))
168167
R = sqrt(maxX + maxY)
169168
patches = buildSweepGradientPatches(
170-
colorLine, center, R, startAngle, endAngle, useGouraudShading=False,
169+
colorLine,
170+
center,
171+
R,
172+
startAngle,
173+
endAngle,
174+
useGouraudShading=False,
171175
extendMode=extendMode,
172176
)
173177
for (P0, color0), C0, C1, (P1, color1) in patches:

Lib/blackrenderer/backends/coregraphics.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from .base import Canvas, Surface
99
from .sweepGradient import buildSweepGradientPatches
1010

11-
1211
_compositeModeMap = {
1312
CompositeMode.CLEAR: CG.kCGBlendModeClear,
1413
CompositeMode.SRC: CG.kCGBlendModeCopy,
@@ -177,8 +176,12 @@ def drawPathRadialGradient(
177176
if extendMode in (ExtendMode.REPEAT, ExtendMode.REFLECT):
178177
colorLine, startCenter, startRadius, endCenter, endRadius = (
179178
_expandRadialGradient(
180-
self.context, colorLine,
181-
startCenter, startRadius, endCenter, endRadius,
179+
self.context,
180+
colorLine,
181+
startCenter,
182+
startRadius,
183+
endCenter,
184+
endRadius,
182185
extendMode,
183186
)
184187
)
@@ -222,8 +225,13 @@ def drawPathSweepGradient(
222225
R = sqrt(maxX + maxY)
223226
# compute the triangle fan approximating the sweep gradient
224227
patches = buildSweepGradientPatches(
225-
colorLine, center, R, startAngle, endAngle,
226-
useGouraudShading=True, extendMode=extendMode,
228+
colorLine,
229+
center,
230+
R,
231+
startAngle,
232+
endAngle,
233+
useGouraudShading=True,
234+
extendMode=extendMode,
227235
)
228236
CG.CGContextBeginTransparencyLayer(self.context, None)
229237
CG.CGContextSetAllowsAntialiasing(self.context, False)
@@ -260,9 +268,7 @@ def _expandLinearGradient(context, colorLine, pt1, pt2, extendMode):
260268
"""
261269
# Get clip bounds in gradient space (after gradientTransform was applied)
262270
(bx, by), (bw, bh) = CG.CGContextGetClipBoundingBox(context)
263-
corners = [
264-
(bx, by), (bx + bw, by), (bx, by + bh), (bx + bw, by + bh)
265-
]
271+
corners = [(bx, by), (bx + bw, by), (bx, by + bh), (bx + bw, by + bh)]
266272

267273
# Compute gradient direction vector
268274
dx = pt2[0] - pt1[0]
@@ -323,9 +329,7 @@ def _expandRadialGradient(
323329
Extends both inward (t < 0) and outward (t > 1) to cover the visible area.
324330
"""
325331
(bx, by), (bw, bh) = CG.CGContextGetClipBoundingBox(context)
326-
corners = [
327-
(bx, by), (bx + bw, by), (bx, by + bh), (bx + bw, by + bh)
328-
]
332+
corners = [(bx, by), (bx + bw, by), (bx, by + bh), (bx + bw, by + bh)]
329333

330334
radiusDiff = endRadius - startRadius
331335
centerDx = endCenter[0] - startCenter[0]

Lib/blackrenderer/backends/skia.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .base import Canvas, Surface
77
from .sweepGradient import normalizeSweepColorLineAndAngles
88

9-
109
_compositeModeMap = {
1110
CompositeMode.CLEAR: skia.BlendMode.kClear,
1211
CompositeMode.SRC: skia.BlendMode.kSrc,

Lib/blackrenderer/backends/svg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from fontTools.ttLib.tables.otTables import ExtendMode
88
from .base import Canvas, Surface
99

10-
1110
logger = logging.getLogger(__name__)
1211

1312

Lib/blackrenderer/backends/sweepGradient.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ def buildSweepGradientPatches(
4646
)
4747

4848
return _buildPatches(
49-
colorLine, center, radius, startAngle, endAngle,
50-
useGouraudShading, maxAngle,
49+
colorLine,
50+
center,
51+
radius,
52+
startAngle,
53+
endAngle,
54+
useGouraudShading,
55+
maxAngle,
5156
)
5257

5358

@@ -140,20 +145,20 @@ def _extendedSegmentSamples(colorLine, t0, t1, extendMode):
140145
samples = []
141146
for stop in sorted(stop for stop in stops if t0 <= stop <= t1):
142147
if stop == t0:
143-
samples.append((stop, _sampleExtendedColorLine(
144-
colorLine, stop, extendMode, side=1
145-
)))
148+
samples.append(
149+
(stop, _sampleExtendedColorLine(colorLine, stop, extendMode, side=1))
150+
)
146151
elif stop == t1:
147-
samples.append((stop, _sampleExtendedColorLine(
148-
colorLine, stop, extendMode, side=-1
149-
)))
152+
samples.append(
153+
(stop, _sampleExtendedColorLine(colorLine, stop, extendMode, side=-1))
154+
)
150155
else:
151-
samples.append((stop, _sampleExtendedColorLine(
152-
colorLine, stop, extendMode, side=-1
153-
)))
154-
samples.append((stop, _sampleExtendedColorLine(
155-
colorLine, stop, extendMode, side=1
156-
)))
156+
samples.append(
157+
(stop, _sampleExtendedColorLine(colorLine, stop, extendMode, side=-1))
158+
)
159+
samples.append(
160+
(stop, _sampleExtendedColorLine(colorLine, stop, extendMode, side=1))
161+
)
157162
return samples
158163

159164

@@ -188,8 +193,13 @@ def _sampleColorLine(colorLine, t):
188193

189194

190195
def _buildPatches(
191-
colorLine, center, radius, startAngle, endAngle,
192-
useGouraudShading, maxAngle,
196+
colorLine,
197+
center,
198+
radius,
199+
startAngle,
200+
endAngle,
201+
useGouraudShading,
202+
maxAngle,
193203
):
194204
"""Build triangle/Coons patches for the given color line and angle range."""
195205
patches = []

Lib/blackrenderer/font.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from fontTools.varLib.varStore import VarStoreInstancer
2020
import uharfbuzz as hb
2121

22-
2322
logger = logging.getLogger(__name__)
2423

2524

Tests/test_canvas_api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from blackrenderer.backends import getSurfaceClass
66
from compareImages import compareImages
77

8-
98
testDir = pathlib.Path(__file__).resolve().parent
109
dataDir = testDir / "data"
1110
expectedOutputDir = testDir / "expectedOutput"
@@ -62,7 +61,9 @@ def test_colorStops(backendName, surfaceClass, stopOffsets, extend):
6261
@pytest.mark.parametrize("angleSuffix, startAngle, endAngle", test_sweepAngles)
6362
@pytest.mark.parametrize("extend", test_extendModes)
6463
@pytest.mark.parametrize("backendName, surfaceClass", backends)
65-
def test_sweepGradient(backendName, surfaceClass, extend, angleSuffix, startAngle, endAngle):
64+
def test_sweepGradient(
65+
backendName, surfaceClass, extend, angleSuffix, startAngle, endAngle
66+
):
6667
H, W = 400, 400
6768
center = (H / 2, W / 2)
6869
colors = [
@@ -83,7 +84,9 @@ def test_sweepGradient(backendName, surfaceClass, extend, angleSuffix, startAngl
8384

8485
ext = surface.fileExtension
8586
stopsString = "_".join(str(s) for s in stopOffsets)
86-
fileName = f"sweepGradient{angleSuffix}_{extend.name}_{stopsString}_{backendName}{ext}"
87+
fileName = (
88+
f"sweepGradient{angleSuffix}_{extend.name}_{stopsString}_{backendName}{ext}"
89+
)
8790
expectedPath = expectedOutputDir / fileName
8891
outputPath = tmpOutputDir / fileName
8992
surface.saveImage(outputPath)

0 commit comments

Comments
 (0)