brianinnes / vPiP

A python library with accompanying Arduino code to drive a vertical plotter from a Raspberry Pi. This project is targeted to drive the driver board created by makeBournemouth, but will work with any system capable of running Python and connecting to an Arduino/Genuino to drive the stepper motors
https://github.com/brianinnes/vPiP/wiki
Apache License 2.0
16 stars 11 forks source link

Auto centre images #9

Open MarkJB opened 8 years ago

MarkJB commented 8 years ago

This is an Enhancement request. Might be irrelevant in light of the pending work, but raising it anyway as it is worth some consideration.

Software needs to be able to auto centre an image.

brianinnes commented 8 years ago

Need to clarify the requirement as the current renderer implementation allows you to specify where to place the top left corner of the image and the required width to draw the image which scales the image accordingly. Easy to calculate these values when you want to position an image at the centre of the page at the scale you want as you have the image size and can get the paper size from config.

MarkJB commented 8 years ago

I would suggest if x & y are not given (or maybe set to -1) that x & y are calculated automatically given the supplied image dimension (i.e. width).

I guess x would be (p.width - image.width)/2 and y would be (p.height - image.height)/2

brianinnes commented 8 years ago

yes. There are a number of other 'helper' functions that could be part of the library, such as 'scale image to fit on page and centre 1 axis if required'

The constrainDrawingRectangle can also be classified as a helper function.

We should define required helper functions and work out how to get them to be applied to a renderer without making the API too complex.

We could come up with a system where we say 'within these constraints render an image using this renderer and this pixel', where the helper functions form a set of constraints.