Skip to content

Commit

Permalink
Fix lint (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishtr authored Oct 25, 2024
1 parent 256f36b commit 081c629
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
18 changes: 12 additions & 6 deletions book/visual-effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,10 @@ documentation for more on the Skia API.
``` {.python replace=%2c%20scroll/,%20-%20scroll/}
class DrawLine:
def execute(self, canvas, scroll):
path = skia.Path().moveTo(self.rect.left - scroll, self.rect.top) \
.lineTo(self.rect.right - scroll, self.rect.bottom)
path = skia.Path().moveTo(
self.rect.left(), self.rect.top() - scroll) \
.lineTo(self.rect.right(),
self.rect.bottom() - scroll)
paint = skia.Paint(
Color=parse_color(self.color),
StrokeWidth=self.thickness,
Expand Down Expand Up @@ -472,9 +474,10 @@ class DrawText:
AntiAlias=True,
Color=parse_color(self.color),
)
baseline = self.rect.top - scroll - self.font.getMetrics().fAscent
canvas.drawString(self.text, float(self.rect.left), baseline,
self.font, paint)
baseline = self.rect.top() - scroll \
- self.font.getMetrics().fAscent
canvas.drawString(self.text, float(self.rect.left()),
baseline, self.font, paint)
```

Note again that we create a `Paint` object identifying the color and
Expand Down Expand Up @@ -512,7 +515,10 @@ calls to `containsPoint` with Skia's `contains`.
class DrawText:
def __init__(self, x1, y1, text, font, color):
self.rect = skia.Rect.MakeLTRB(
x1, y1, x1 + font.measure(text), y1 + font.metrics("linespace"))
x1, y1,
x1 + font.measureText(text),
y1 - font.getMetrics().fAscent \
+ font.getMetrics().fDescent)
# ...
class DrawLine:
Expand Down
16 changes: 10 additions & 6 deletions src/lab11.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def __init__(self, x1, y1, text, font, color):
self.rect = skia.Rect.MakeLTRB(
x1, y1,
x1 + font.measureText(text),
y1 - font.getMetrics().fAscent + font.getMetrics().fDescent)
y1 - font.getMetrics().fAscent \
+ font.getMetrics().fDescent)
self.font = font
self.text = text
self.color = color
Expand All @@ -150,9 +151,10 @@ def execute(self, canvas):
AntiAlias=True,
Color=parse_color(self.color),
)
baseline = self.rect.top() - self.font.getMetrics().fAscent
canvas.drawString(self.text, float(self.rect.left()), baseline,
self.font, paint)
baseline = self.rect.top() \
- self.font.getMetrics().fAscent
canvas.drawString(self.text, float(self.rect.left()),
baseline, self.font, paint)

@wbetools.patch(DrawOutline)
class DrawOutline:
Expand All @@ -177,8 +179,10 @@ def __init__(self, x1, y1, x2, y2, color, thickness):
self.thickness = thickness

def execute(self, canvas):
path = skia.Path().moveTo(self.rect.left(), self.rect.top()) \
.lineTo(self.rect.right(), self.rect.bottom())
path = skia.Path().moveTo(
self.rect.left(), self.rect.top()) \
.lineTo(self.rect.right(),
self.rect.bottom())
paint = skia.Paint(
Color=parse_color(self.color),
StrokeWidth=self.thickness,
Expand Down

0 comments on commit 081c629

Please sign in to comment.