ScenicFramework / scenic

Core Scenic library
Apache License 2.0
1.99k stars 137 forks source link

Fix error in the bounds/1 documentation #277

Closed JediLuke closed 2 years ago

JediLuke commented 2 years ago

Description

There's an error in the documentation for bounds/1, the docs say the format is {left, right, top, bottom}, but that's not correct, it's actually {left, top, right, bottom}

It's a tiny error but pretty misleading for anyone trying to use this function, hahaha!

Just to prove this completely, I made a test app & created this graph:

init_graph =
      Graph.build()
      |> Scenic.Primitives.rectangle({100, 200}, t: {25, 75}, fill: :red)

which renders like this:

image

In the handle_event/3 I checked the bounds:

  def handle_input(event, _context, state) do
    Logger.info("Received event: #{inspect(event)}")
    bounds = Scenic.Graph.bounds(state.assigns.graph)
    IO.inspect bounds, label: "Bounds"
    {:noreply, state}
  end

I see: Bounds: {25.0, 75.0, 125.0, 275.0}

Also the typespec in Scenic.Graph shows the order left, top, right, bottom so I'm pretty certain now it was just a documentation error https://github.com/boydm/scenic/blob/master/lib/scenic/graph.ex#L175

Motivation and Context

When using bounds/1 I was getting some very strange behaviour due to how it was documented vs how it works.

Types of changes