3 ms·
maybe if(mouseIsAtOrigin()){
by HerpDerpLerp 11y ago
maybe
if(mouseIsAtOrigin()){
- woodman 11y agoThat really only makes sense if you've got a 40 year old code base that supports every platform conceived, some of which have mouse origins that are -42.333f or can only be determined at run time. Take a look at the source for tcsh, this is exactly how it is done there. Unless you're interested in supporting a long dead platform - it makes things unnecessarily complex. I love tcsh, but so many ifdefs in so many static functions...
- DonHopkins 11y agoThe point wasn't to come up with the best api, but to illustrate how to format code that has repetitions and regular variations in it, to make it easy to visually identify which parts repeat and which parts vary. That makes it easier to read the code and spot errors. For example: sqrt((x * x) + (y * y) + (z * z)); You can run your eyes up and down each column to verify it's squaring x, y and z. That reflects the structure and symmetry of the expression better than: sqrt((x * x) + (y * y) + (y * z)); Did you spot the error? sqrt((x * x) + (y * y) + (y * z)); How about now? Here's some code that has a lot of examples of that style, a JavaScript implementation of a weird hybrid Margolis cellular automata neighborhood, which has a lot of two-dimensional patterns: https://github.com/SimHacker/CAM6/blob/master/javascript/CAM6.js#L4282 https://github.com/SimHacker/CAM6/blob/master/javascript/CAM...