Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set up a user Quartz2D coordinate system with scaling that avoids fuzzy drawing?
    primarykey
    data
    text
    <p>This topic has been scratched once or twice, but I am still puzzled. And Google was not friendly either.</p> <p>Since Quartz allows for arbitrary coordinate systems using affine transforms, I want to be able to draw things such as floorplans using real-life coordinate, e.g. feet.</p> <p>So basically, for the sake of an example, I want to scale the view so that when I draw a 10x10 rectangle (think a 10-inch box for example), I get a 60x60 pixels rectangle.</p> <p>It works, except the rectangle I get is quite fuzzy. Another question here got an answer that explains why. However, I'm not sure I understood that reason why, and moreover, I don't know how to fix it. Here is my code:</p> <p>I set my coordinate system in my <code>awakeFromNib</code> custom view method:</p> <pre><code>- (void) awakeFromNib { CGAffineTransform scale = CGAffineTransformMakeScale(6.0, 6.0); self.transform = scale; } </code></pre> <p>And here is my draw routine:</p> <pre><code>- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGRect r = CGRectMake(10., 10., 10., 10.); CGFloat lineWidth = 1.0; CGContextStrokeRectWithWidth(context, r, lineWidth); } </code></pre> <p>The square I get is scaled just fine, but totally fuzzy. Playing with <code>lineWidth</code> doesn't help: when <code>lineWidth</code> is set smaller, it gets lighter, but not crisper.</p> <p>So is there a way to set up a view to have a scaled coordinate system, so that I can use my domain coordinates? Or should I go back and implementing scaling in my drawing routines?</p> <p>Note that this issue doesn't occur for translation or rotation.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload