From: Jan E. <ch...@in...> - 2000-09-18 08:35:48
|
On Sun, 17 Sep 2000, Pete Shinners wrote: >--- should rects return nonzero if only one of width or >height is 0? with a zero width or height, SDL isn't going >to do anything during blits or fills. on the other hand, >there is some size info still in there, this may be helpful >in some cases. ><<rect will return nonzero only if both width and height >are nonzero>> IMO a rect with 0 height or width is valid. I could think of situations where a rect needs to shrink for some reason until is is just a line with no width/height. No blits would be done, of course. >--- operator math? i've been trying to think of clean and >useful cases to add operator math to the rectangle. (+-*%). >it could be useful for "rect += (10, 40)" to move a >rectangle. but there is effort needed to define all >the cases with clean and consistent usage ><<not planning for this (at least in first release). if >someone really wants this stuff, please compile a list >of all the operators you'd like to use, as well as what >types of arguments they can take and what the results >should be>> Personally I think I'd so far like plain methods for doing these kind of things, such as resize(), move() etc. But I'm not too experieced with Python yet, but in C++ I'd do it with methods. >--- when changing rectangle attributes, should the rect >automatically try to maintain non-negative values? ><<i'm currently planning to have the rect automatically fix >negative sizes. yes, there's potential for confusion, but i >can't think of a good case where one would actually want to >keep the negative value. plus all of the rects method results >become undefined when fed rects with negative sizes. so best >to take the extra step to avoid them>> Either automatically or then throw an exception. I'd maybe prefer to have an exception, as "flipping" a rect indicates an error from the programmer. >--- what should the return values/modification behavior be >for all of the rectangle methods. in the standard python >modules, the usual rule is, if a method changes the values >of "self", then it returns none. otherwise the method returns >a new object with the result of the changes, the original goes >unchanged. (a potential third option is to change the original >and return a reference to the original). ok, since this is >the most important one i want to make sure everyone understands >the full effects of this. for the method rect.clip, we have >three main strategies. >rect.clip can just change the rectangle it is working on ("self") > and return nothing. >rect.clip can create a new rectangle with the results and return > that. >rect.clip can modify "self" and return a reference to itself. >ok, the three options may not sound to different, here are the >CONS for each approach >"Only Change Self": with this approach, everytime you want > to change something about a rect, it takes a separate > line. some things can require a couple steps, and it > makes it impossible to send values to functions with > 'on the fly' changes'. think of the list methods, like > list.sort(), etc. I'd like to use this way of doing things. I look forward to be able to test your new class, as it can make gui-making a lot easier. --------------------+-------------------------------------------------------- Jan 'Chakie' Ekholm | Balrog New Media http://www.balrog.fi/ Linux Inside | I'm the blue screen of death, nobody hears your screams |