<div dir="ltr">The problem with making those settable is the ambiguity of it.<div><br></div><div>Say you increase the value at maxY, should the length or origin.y be increased? should they share the modification and increase both buy half?</div><div><br></div><div>It is not clear the intention here.</div><div><br></div><div>And then, as David said, this is CoreGraphics API which has to be suggested through Radars and we all know how likely our chances are there.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 13, 2015 at 10:55 PM, Jacob Bandes-Storch <span dir="ltr"><<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I still think it might be valuable to pursue setters for all of the currently-read-only convenience properties (minX, midX, maxX, minY, midY, maxY).<div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all"><div><div><div dir="ltr"><div>Jacob<br></div></div></div></div></font></span><div><div class="h5">
<br><div class="gmail_quote">On Fri, Dec 11, 2015 at 1:17 PM, D. Felipe Torres <span dir="ltr"><<a href="mailto:warorface@gmail.com" target="_blank">warorface@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Using the mid properties wouldn't help much as they are the middle of the bounds (origin + length/2) and because it's a derived value from two different structures, its not clear which structure you want to modify.<div><br></div><div>Either way, after thinking more about it, there is too much ambiguity to the details of this. The intent is not always clear and looking into the other functions, they all stand on their own. A CGRect doesn't have any sense of hierarchy.</div><div><br></div><div>It only appears when you have layers/views (and those do have a way of setting the center because the relationship/hierarchy is well defined).</div><div><br></div><div>I don't see any more reason to pursue this proposal.<br></div><div> </div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Fri, Dec 11, 2015 at 7:29 AM, Jacob Bandes-Storch <span dir="ltr"><<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Would it make sense to achieve the same thing by giving midX and midY setters (they currently only have getters)?</div><div><br></div><div>I'm don't think I like the idea of tying down any CGRect extensions to a "parent" rect, but saying "rect.midX = parent.midX" is pretty simple & clear.</div><span><font color="#888888"><div class="gmail_extra"><br></div><div class="gmail_extra">
Jacob</div></font></span><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Dec 10, 2015 at 6:17 AM, D. Felipe Torres via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><span style="font-size:13px">One of the task that is performed often is center a frame with respect to it's parent.</span><div style="font-size:13px">The code for this is short and simple:</div><div style="font-size:13px"><br></div><div style="font-size:13px">rect.origin.x = (rect.width-parent.width)/2 // or... </div><div style="font-size:13px">rect.origin.y = (rect.height-parent.height)/2</div><div style="font-size:13px"><br></div><div style="font-size:13px">## Current Problems</div><div style="font-size:13px"><br></div><div style="font-size:13px">- It is very easy to get it wrong and confuse X or Y and their length associations.</div><div style="font-size:13px">- Because this code is often found in a layout method, several other rect variables may be defined in the scope which makes it easier to mistake one variable with another if their names are close (and you are used to autocomplete)</div><div style="font-size:13px">- And finally but most importantly, while the equation here is simple, one must parse it and understand it and is not a very swifty approach.</div><div style="font-size:13px"><br></div><div style="font-size:13px">##Proposed Additions </div><div style="font-size:13px"><br></div><div style="font-size:13px">2 (actually 4) extensions in CGGeometry to CGRect:</div><div style="font-size:13px"><br></div><div style="font-size:13px">extension CGRect {</div><div style="font-size:13px"> public func centerX(parentRect: CGRect) -> CGRect</div><div style="font-size:13px"> public mutating func centerXInPlace(parentRect: CGRect)</div><div style="font-size:13px"><div> public fun centerY(parentRect: CGRect) -> CGRect</div><div> public mutating func centerYInPlace(parentRect: CGRect)</div></div><div style="font-size:13px">}</div><div style="font-size:13px"><br></div><div style="font-size:13px">This extension allows very easily (and verbally) center a rect in respect to a parent.</div><div style="font-size:13px"><br></div><div style="font-size:13px">I'm pretty sure there are other pretty useful extensions that can be added to CGGeometry as well but this one I think is basic and pretty important.</div><span><font color="#888888"><div><br></div>-- <br><div><div style="color:rgb(34,34,34)">++++++++++++++++++++++++++</div><div style="color:rgb(34,34,34)">Diego Torres.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Web: <a href="http://dtorres.me/" target="_blank">dtorres.me</a></div></div>
</font></span></div></div></div><span><span><font color="#888888">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qxI5LM3vsJ0SXACGqem8cD1pS9R2b2vsjP7kseNPr2tDTtL9WDPZ9aN9TBBkTjtUeWQIF8HH3WgYlQi-2B8b2-2FBx6cABQlJDzhWN6RIzqSo56C6IvnvvaFbyTTkJ-2FOeibh4VOIQFjguJR6rhUHX5oHgBpmqUryCxnRvsA1LPWNDeF0Sxi-2FLsKq1LxKy-2FSbY-2FZTj8-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</font></span><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></span></blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><div><div style="color:rgb(34,34,34)">++++++++++++++++++++++++++</div><div style="color:rgb(34,34,34)">Diego Torres.</div><div style="color:rgb(34,34,34)">Phone (Mobile Germany): <a href="tel:%2B49%20157%2030070985" value="+4915730070985" target="_blank">+49 157 30070985</a></div><div style="color:rgb(34,34,34)">Phone (Landline Chile): <a href="tel:%2B56%202%2029790978" value="+56229790978" target="_blank">+56 2 29790978</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Web: <a href="http://dtorres.me/" target="_blank">dtorres.me</a></div></div>
</font></span></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div style="color:rgb(34,34,34)">++++++++++++++++++++++++++</div><div style="color:rgb(34,34,34)">Diego Torres.</div><div style="color:rgb(34,34,34)">Phone (Mobile Germany): +49 157 30070985</div><div style="color:rgb(34,34,34)">Phone (Landline Chile): +56 2 29790978</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Web: <a href="http://dtorres.me/" target="_blank">dtorres.me</a></div></div>
</div>