Print

Print


MASON's 2D drawing is designed to be scalable in size and properly handle scrolling.  You need to keep this in consideration.  Some hints.  When you're drawing an object in a field, the DrawInfo2D means this:

info.draw.x
info.draw.y	These define the location (in pixels) of the object's center.

info.draw.width
info.draw.height  These define the width and height (in pixels) of 1 unit in the simulation.  Generally speaking, objects are assumed to fill a 1 unit square.

info.clip	This defines the rectangle which is currently being displayed.  If the info.draw rectangle doesn't intersect with the info.clip rectangle, there's often no reason to bother drawing the object. 

See section 9.3.7 of the manual.


When you're drawing the field as a whole, info.clip once again means the region which is being displayed, but info.draw.x and info.draw.y means the location of the origin of the field.  The scale of the field can be found with getScale().  See section 9.2.9 of the manual.



On Nov 3, 2017, at 4:22 PM, Brant Horio <[log in to unmask]> wrote:

> Well, I seem to have made it work, though not exactly sure what I did... I adjusting the code for the drawLine from:
> 
> graphics.drawLine(x1, y1, x2, y2);
> 
> to:
> 
> graphics.drawLine((int) info.clip.x + (x1 * 5), (int) info.clip.y + (y1 * 5), (int) info.clip.x + (x2 * 5), (int) info.clip.y + (y2 * 5));
> 
> and, voila?
> 
> I wish I could upload screenshots to this post. But this adjustment seems to have bridged the scaling difference between the agent location and the line draws.
> 
> Any thoughts on the matter are still appreciated (especially a more technical reason for why it worked), but thank you for your time!!
> Brant