Obligatory "ignore this space" : https://sacoronavirus.co.za

Keep that engine turning!

A monkey might pedal a bicycle, and then we might connect the chain to anything that can be operated by a motor. This provides inspiration for a very entertaining computer game, but in terms of solving the energy crisis just about everyone would agree that cruelty to animals is not a way out, no matter how much cruelty to non-animals this imposes.

Moving back in time I note that I made a mistake in highlighting patents as being something not catered for by copyleft. Ownership is an idea, and patents are the idea of owning ideas. Ideas might prefer to be free, but copyleft itself belongs to a man; that is, to come up with one's own copyleft licence is plain theft.

On the other hand, to hunt around to see if someone else has written something which you think you're capable of, is to forget about the total failure of the education system to cater for computers: placing my research into a thesis will require the use of proprietary software.

Thus I cast my pearls before swine; unless those reading this while stroking a pot-belly pig do me the favour of going somewhere else.

To look at scaling a raster, we must look at four parameters. Referring to something that predates blissful ignorance, we find that it was generally accepted that while a rectangle has a width, height and length apply to things that may be done with rectangles.

I'm not one to put words into other people's mouths. If you so happen to stumble upon my code, don't tell me that I use archaic words. No-one has yet claimed credit for the idea that inventors aught to make a lot of money, nor for the excessive use of plastic.

In scaling a raster we have the old and the new dimensions. It is, in some circumstances, useful to resort to the archaic selection of variables, in which we describe what they are without trying to make them abbreviations. I'm not about to suggest that the education system failure has to do with teachers not being willing to listen to their betters, for this problem is no doubt as old as the idea of universal education.

Let a and b represent the width and breadth of the old raster, and A and B represent the width and breadth of the new one. We consider an arbitrary pixel, (x,h) of the new. There are four cases to consider in terms of the relative sizes of the dimensions. We start with the assumption that a > A and b > B. The pixel (x,h) is then mapped to nine segments (at most) on the old raster. We create a three by three matrix, w, for the the weighting of a pixel in each segment. Note that w00 contains the weighting for the old pixel ( floor(x * a / A), floor(h * b / B) )--the functions floor and ceil have recognized symbols which apply to Real numbers.

To determine the color of (x,h) we must add up the color elements and divide by a total (weight is another word for coefficient).

One pixel of the new raster maps to the exact area (a * b) / (A * B). To determine w00 we start by looking at the remainder x * a % A (the percent operator is a remainder operator, not a modulus). This remainder divided by A is obviously the fractional part of x * a / A, which is part of the input pixel that must be excluded, so that this fraction must be subtracted from one.

Thus w00 = ( A - x * a % A ) * ( B - h * b % B ) / ( A * B ).

Next we might consider ceil(x * a / A) and ceil(h * b / B), but it is easier to consider the fact that the part of an input pixel that is excluded from one output pixel must be assigned to an adjacent output pixel. Thus we look at (x + 1) * a / A and (h + 1) * b / B, and conclude that w22 = ( ( x + 1 ) * a % A ) * ( ( h + 1 ) * b % B ) / ( A * B ).

The implementation of this requires a number of conditional subcases, and is by no means the quickest, and is certainly not going to impress anyone who loves to make a V with their fingers.

Those who made a V for no reason at all may, if we are prepare to unearth the last century, give us a clue as to why we're not ready to tackle the plastic waste problem head on. The making of a V with the fingers on the screen does mean that people are supporting the side of might being right.

The preceding description applies for all values of a, b, A, and B, with a caveat for scrolling.

••
Feedback