[docs]@final@add_slots@dataclass(frozen=True,init=False)classRule(Block):"""A :class:`Block` that draws a horizontal line"""color:RGBmargin:Sidesdef__init__(self,color:RGB|HexColor=black,margin:SidesLike=Sides(6,0,6,0),)->None:setattr_frozen(self,"color",RGB.parse(color))setattr_frozen(self,"margin",Sides.parse(margin))definto_columns(self,_:Resources,__:StyleFull,cs:Iterator[ColumnFill])->Iterator[ColumnFill]:col=next(cs)top,right,bottom,left=self.marginif(height:=top+bottom)>col.height_free:# There is not enough room for the rule in the current column.# Yield the column and start a new one.yieldcoly=col.box.origin.y+col.height_free-topx=col.box.origin.x+leftyieldcol.add(ShapedRule(XY(x,y),XY(col.box.origin.x+col.box.width-right,y),self.color,height,),)
@add_slots@dataclass(frozen=True)classShapedRule(Shaped):start:XYend:XYcolor:RGBheight:Ptdefrender(self,_:XY,__:Pt)->Streamable:yieldb"%g%g m %g%g l %g%g%g RG S\n"%(*self.start,*self.end,*self.color,)