B05-232 / plug-standard

0 stars 1 forks source link

`Canvas::setSize` doesn't make any sense #53

Open Sigmarik opened 7 months ago

Sigmarik commented 7 months ago

Canvas can not and should not be able to resize itself.

The only implementation of this method I can think of just copies current canvas to the new one and makes it look like the canvas has changed its size. It would be more convenient to define this transformation as a copy constructor instead hiding it under this pseudo-setter rmethod.

In addition, I don't think whis method will ever be used. So far there is not a single case when the canvas itself should be resized.

MeerkatBoss commented 7 months ago

Actually, canvas is resizable in Microsoft Paint, which we take as a baseline reference. In Paint, you can drag lower right corner of canvas to either grow it, filling pixels with background color, or shrink it, discarding pixels outside new boundary.

Sigmarik commented 7 months ago

Actually actually, whenever you resize the canvas in this would-be-an-image-editor program called ms paint, the canvas gets completely recreated. This is simply because there is no way to resize already allocated buffer used as a canvas, be it on CPU or GPU.

Sure, you can reattach the same header to completely different image, wrap it in 100 methods, rewrite the header to fit new data and call it a basic action with the class, but I would better leave such methods to people who convinced themselves into thinking they are necessay.

P.S. If you still want to push the line, then at least accept renaming this method to something like resize and change its signature to return the resized canvas. Naming signature of a setter really doesn't fit the method which makes such radical and computationally expensive action as rebuilding the canvas on top of the already existing one.

MeerkatBoss commented 7 months ago

Yeah, resize seems like a better name for this method. But setSize will do fine for the time being, we can rename (or rather, for backwards compatibility's sake, alias) this method is Version 2.