The comment in add_item said a new fill or stroke is a copy of the top one. The code takes only the top item's paint, and for a stroke its weight. The comment now says so, as the params text does.