Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 685471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:55:33+00:00 2026-05-14T01:55:33+00:00

This topic has been scratched once or twice, but I am still puzzled. And

  • 0

This topic has been scratched once or twice, but I am still puzzled. And Google was not friendly either.

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.

So basically, for the sake of an example, I want to scale the view so that when I draw a 10×10 rectangle (think a 10-inch box for example), I get a 60×60 pixels rectangle.

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:

I set my coordinate system in my awakeFromNib custom view method:

- (void) awakeFromNib {
    CGAffineTransform scale = CGAffineTransformMakeScale(6.0, 6.0);
    self.transform = scale;
}

And here is my draw routine:

- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGRect r = CGRectMake(10., 10., 10., 10.);
    CGFloat lineWidth = 1.0;
    CGContextStrokeRectWithWidth(context, r, lineWidth);
}

The square I get is scaled just fine, but totally fuzzy. Playing with lineWidth doesn’t help: when lineWidth is set smaller, it gets lighter, but not crisper.

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?

Note that this issue doesn’t occur for translation or rotation.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:55:34+00:00Added an answer on May 14, 2026 at 1:55 am

    Well, as often, explaining the issue lead me to a solution.

    The problem is that the view transform property is applied to it after it has been drawn into a bit buffer. The scaling transform has to be applied before drawing, ie. in the drawRect method. So scratch the awakeFromNib I gave, and here is a correct drawRect:

    - (void)drawRect:(CGRect)rect {
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGAffineTransform scale = CGAffineTransformMakeScale(6.0, 6.0);
        CGContextConcatCTM(context, scale);
        CGRect r = CGRectMake(10., 10., 10., 10.);
        CGFloat lineWidth = 0.1;
        CGContextStrokeRectWithWidth(context, r, lineWidth);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok so I know this topic has many questions, but I still haven't been
I know this topic has been discussed, but not by me yet. As I
this topic has been touched multiple times on Stack Overflow, but my search still
I know that this topic has been already beaten enough, but I still don't
I can see this topic has been brought up before but not answered successfully.
i know this topic has been discussed here before but i still can't get
This topic has been covered on this forums, but I haven't found a working
I know this topic has been discussed but I think it has some differences.
I know this topic has been discussed to death, but there is one thing
I know this topic has been asked, but the posts are all out of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.