<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I have been working on and off on this graphical editor, and i seem to come across a recurring problem that my initial ideas for the program design weren’t sound, and i have to go back one or two things. This affects the rest of the system and forces me to modify a lot other functions. One example is inside (define (open-file … ) where i now use search-list instead of struct-list (this is a quick hack to get the program working, which i will go back and change eventually) because i realized i need to scale the values. </div><div class=""><br class=""></div><div class="">Another thing is how to break up my code. I have read the style documentation <a href="http://docs.racket-lang.org/style/Units_of_Code.html" class="">here</a> and forgive me but i am new to software development, and i still don’t know what constitutes good modularity in a program. I do have defined sections in this one big script though, namely txt parsing, auxilliary functions, geometric functions, intersection query functions, but i am afraid they are blurring the lines and it is getting harder for me to tell which functions go where.</div><div class=""><br class=""></div><div class="">Finally, i wish to say thanks for making Racket such an enjoyable programming environment. DrRacket made it very easy for me to started and the ease of creating a GUI environment quickly was what drew me to start my project here.</div><div class=""><br class=""></div><div class="">P.S. no global variables in caps now :)</div><div class=""><br class=""></div><div class=""><a href="http://pasterack.org/pastes/70507" class="">http://pasterack.org/pastes/70507</a></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 22 Dec 2014, at 6:42 pm, Neil Van Dyke <<a href="mailto:neil@neilvandyke.org" class="">neil@neilvandyke.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">I think you have some of the right ideas.<br class=""><br class="">Two additional ideas to consider...<br class=""><br class="">* Usually you will have some data representation of objects that will be drawn and manipulated. This might be as simple as a list of structs or Racket objects, and (in an OOPL way). If you're making a simple graphical editor, these might have objects like `editor-circle`, which knows its position, size, and color, as well as has methods like "draw this object on given graphic context" and "does this object intersect with given selection rectangle?". The coordinates for these objects will probably be in a "world" coordinate system, which stays the same regardless of whatever scaling, scrolling, rotating, etc. is going on in your editor. One of the many implications of the methods, to answer one of your questions, is that, when you are dragging out your selection rectangle, you can just traverse this list, asking each object whether it intersects with the rectangle. (If your editor gets more sophisticated, or has to deal with , or you can get fancier with your data structures, which would include making the selection more efficient than O(n).)<br class=""><br class="">* When you are looking at doing drawing that is expensive, such as highlighting objects as you drag the selection rectangle over them, consider how using off-screen buffers can make that computationally easier. You might have heard of "double-buffering" as a technique for avoiding flicker in animations, but you can use similar techniques for things like capturing a baseline drawing state and then doing fast incremental changes atop that (say, for highlighting objects during a select rectangle drag, or for dragging selected objects).<br class=""><br class="">Also, I beg people not to use all-caps for constants. All-caps are too useful for syntax transformer variables (which is also a use more consistent with the original reason that people started using all-caps for constants, which wasn't because they were constants but because they were involved in... syntax transformation). And, anyway, more descriptive than `WIDTH` is `editor-frame-width`.<br class=""><br class="">Neil V.<br class=""><br class=""></div></blockquote></div><br class=""></body></html>