MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / _le_square

Method _le_square

src/__init__.py:25080–25099  ·  view source on GitHub ↗

Make stream commands for square line end symbol. "lr" denotes left (False) or right point.

(annot, p1, p2, lr, fill_color)

Source from the content-addressed store, hash-verified

25078
25079 @staticmethod
25080 def _le_square(annot, p1, p2, lr, fill_color):
25081 """Make stream commands for square line end symbol. "lr" denotes left (False) or right point.
25082 """
25083 m, im, L, R, w, scol, fcol, opacity = TOOLS._le_annot_parms(annot, p1, p2, fill_color)
25084 shift = 2.5 # 2*shift*width = length of square edge
25085 d = shift * max(1, w)
25086 M = R - (d/2., 0) if lr else L + (d/2., 0)
25087 r = Rect(M, M) + (-d, -d, d, d) # the square
25088 # the square makes line longer by (2*shift - 1)*width
25089 p = r.tl * im
25090 ap = f"q\n{opacity}{p.x:f} {p.y:f} m\n"
25091 p = r.tr * im
25092 ap += f"{p.x:f} {p.y:f} l\n"
25093 p = r.br * im
25094 ap += f"{p.x:f} {p.y:f} l\n"
25095 p = r.bl * im
25096 ap += f"{p.x:f} {p.y:f} l\n"
25097 ap += _format_g(w) + " w\n"
25098 ap += scol + fcol + "b\nQ\n"
25099 return ap
25100
25101 @staticmethod
25102 def _oval_string(p1, p2, p3, p4):

Callers

nothing calls this directly

Calls 3

RectClass · 0.85
_format_gFunction · 0.85
_le_annot_parmsMethod · 0.80

Tested by

no test coverage detected