matt-dray / pixeltrix

:space_invader::computer_mouse: R package: make pixel art interactively in a plot window, get a matrix, make a gif
Other
21 stars 0 forks source link

`n_states` not generated in `draw_pixels()` when matrix has no `colours` attribute #24

Closed matt-dray closed 1 year ago

matt-dray commented 1 year ago

This occurs if you use a matrix in draw_pixels() without a colours attribute:

> matrix(1:9,3) |> draw_pixels()
# Error in get_greys(n_states) : object 'n_states' not found

I think n_states is derived from the colours attribute, but there isn't any derivation of n_states if the attribute is not there. So just need to infer n_states from the values in the input matrix.

This is already handled in edit_pixels(), so might need to copy from there.