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 3220502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:46:07+00:00 2026-05-17T15:46:07+00:00

I am having trouble drawing one pixel wide lines. All lines are perfectly horizontal

  • 0

I am having trouble drawing one pixel wide lines. All lines are perfectly horizontal or vertical (I am not drawing diagonal lines) but they do not draw cleanly. It looks like it is drawing across two pixels at a reduced alpha. No doubt due to antialiasing. I’ve searched the docs and forums and have come across a statement saying that there’s “…no problem drawing horizontal and vertical lines one pixel wide…” but I don’t know how exactly. Any pointers would be welcome.

The drawing code is simple:

else if ([[value entity].name isEqualToString:@"RTLine"]) {

CGContextSetRGBStrokeColor(ctx, 0, 0, 0, 1);
CGContextSetLineWidth(ctx, [[value valueForKey:@"thickness"] doubleValue]);
CGContextMoveToPoint(ctx, [[value valueForKey:@"beginDrawLocationX"] doubleValue],
                             [[value valueForKey:@"beginDrawLocationY"] doubleValue]);
CGContextAddLineToPoint(ctx, [[value valueForKey:@"endDrawLocationX"] doubleValue],
                                [[value valueForKey:@"endDrawLocationY"] doubleValue]);
CGContextStrokePath(ctx);

}

In the above, ‘thickness’ is equal to 1. I used doubleValue instead of floatValue for conversion from int in case float was mushing the value to something not quite 1 – it wasn’t.

  • 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-17T15:46:08+00:00Added an answer on May 17, 2026 at 3:46 pm

    My bad. As soon as I posted this I found the answer in the CGContext reference guide. all I had to do is add the line:

    CGContextSetShouldAnitalias(ctx, 0); 
    

    and bingo! All is at peace…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hell-o all, Im new to qt and I am having trouble drawing one single
I'm trying to make a simple drawing app in c++, but i'm having trouble
I am having trouble drawing a line within a group box in a simple
Having trouble with an .htaccess file on WAMP. Works on the live server, but
I'm having trouble with a gradient drawing call. I have a Form that looks
I'm having some trouble drawing out a sphere. std::vector<GLfloat> ballVerts; for(int i = 0;
I'm having trouble in mouse coordinates when drawing at canvas of HTML5. I'm using
I'm having trouble with my bingo application,I tried drawing a circle programmatically whenever a
I am having trouble with the Graphics that I am drawing on a Panel
I am trying to create a drawing area with canvas. I am having trouble

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.