Skip to content

Commit

Permalink
Create fitz.i
Browse files Browse the repository at this point in the history
This pertains to Page method `get_drawings()`.
The set of keys for "fs" paths already is complete by definition - so only fill and stroke paths require special attention.
Each type should have the complete list of keys as a "fs" path would have, so we generate `None` values where necessary for "f" and "s" paths only.
In view of performance, this is probably faster then subclassing `dict` and giving it the `__missing__()` method to achieve the same thing.
  • Loading branch information
JorjMcKie committed May 10, 2023
1 parent 01878eb commit 59011ef
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions fitz/fitz.i
Original file line number Diff line number Diff line change
Expand Up @@ -6268,10 +6268,8 @@ def get_oc_items(self) -> list:
It also adds default items that are missing in original path types.
"""
allkeys = (
("closePath", False), ("fill", None),
("color", None), ("width", 0), ("lineCap", [0]),
("lineJoin", 0), ("dashes", "[] 0"), ("stroke_opacity", 1),
("fill_opacity", 1), ("even_odd", True),
"closePath", "fill", "color", "width", "lineCap",
"lineJoin", "dashes", "stroke_opacity", "fill_opacity", "even_odd",
)
val = self.get_cdrawings(extended=extended)
for i in range(len(val)):
Expand All @@ -6294,9 +6292,9 @@ def get_oc_items(self) -> list:
item = tuple([cmd] + [Point(i) for i in rest])
newitems.append(item)
npath["items"] = newitems
if npath["type"] in ("f", "s", "fs"):
for k, v in allkeys:
npath[k] = npath.get(k, v)
if npath["type"] in ("f", "s"):
for k in allkeys:
npath[k] = npath.get(k)
val[i] = npath
return val

Expand Down

0 comments on commit 59011ef

Please sign in to comment.