Skip to content

proposal: image: add Rectangle.TLBR() iter.Seq[Point] #76710

@earthboundkid

Description

@earthboundkid

Proposal Details

It is very common to process an image from top left to bottom right. I propose adding this method to Rectangle:

func (r Rectangle) TLBR() iter.Seq[Point] {
	r = r.Canon()
	return func(yield func(Point) bool) {
		for y := r.Min.Y; y < r.Max.Y; y++ {
			for x := r.Min.X; x < r.Max.X; x++ {
				if !yield(Pt(x, y)) {
					return
				}
			}
		}
	}
}

We may also want to add iterators for other directions, such as BRTL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions