If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
How do you draw precise borders around a rectangle?
17 posts
• Page 1 of 2 • 1, 2
How do you draw precise borders around a rectangle?
This is my basic code for draw a rectlangle with a small border around it:
but as you can see, the borders in the bottom and right is tiny than top/left:
I don't know the reason. I've also tried to draw a rectangle within a rectangle (on the same (V)iew), but the problem is the same.
Maybe the conversion between points and pixels?
How can I do precise draw? Can I specify sizes in pixels?
I don't see any in the manual about this
Here if you want to try the example:
- Code: Select all
def draw i,v
# Background
rc = [0,0,v.width,v.height]
brushBackground = Brush.new Color.new(69,75,79)
v.drawRectangle brushBackground,rc
# Border
pb = Pen.new Color.new(255,255,255),0.5
v.drawRoundRect pb,rc,0
end
def event i,v
redraw 0
end
but as you can see, the borders in the bottom and right is tiny than top/left:
I don't know the reason. I've also tried to draw a rectangle within a rectangle (on the same (V)iew), but the problem is the same.
Maybe the conversion between points and pixels?
How can I do precise draw? Can I specify sizes in pixels?
I don't see any in the manual about this
Here if you want to try the example:
- Nowhk
- Posts: 275
- Joined: Mon Oct 27, 2014 6:45 pm
Re: How do you draw precise borders around a rectangle?
I've tried this suggestion: viewtopic.php?f=2&t=1074
but when I render the plug, the border bottom seems incorrect anyway:
even thought right side is still tiny than left, even if less tiny than before...
but when I render the plug, the border bottom seems incorrect anyway:
- Code: Select all
def init
@borderWidth = 0.4
end
def draw i,v
# Background
rc = [@borderWidth/2,@borderWidth/2,v.width-@borderWidth,v.height-@borderWidth]
brushBackground = Brush.new Color.new(69,75,79)
v.drawRectangle brushBackground,rc
# Border
pb = Pen.new Color.new(255,0,0),@borderWidth
v.drawRoundRect pb,rc,0
end
def event i,v
redraw 0
end
even thought right side is still tiny than left, even if less tiny than before...
- Nowhk
- Posts: 275
- Joined: Mon Oct 27, 2014 6:45 pm
Re: How do you draw precise borders around a rectangle?
Oh dear, a year and a half late, but anyway, here's a screenshot from the world of v.3.0.0
I don't see a problem here, could the later versions be the cause ?
ROXY
I don't see a problem here, could the later versions be the cause ?
ROXY
- Attachments
-
- Better late than never, does this help anyone ?
- screenshot-borders.png (676.62 KiB) Viewed 17142 times
-
rocknrollkat - Posts: 213
- Joined: Mon Jan 04, 2016 7:04 pm
- Location: Oakland Gardens, New York City, U.S.A.
Re: How do you draw precise borders around a rectangle?
I don't know? 3.0.8 (FL) and 3.0.7 (standalone, demo) does it
Did you try with my code?
Did you try with my code?
- Nowhk
- Posts: 275
- Joined: Mon Oct 27, 2014 6:45 pm
Re: How do you draw precise borders around a rectangle?
The only work around for now that I can see is setting the "rc = [0,0,v.width,v.height]" to "rc = [-0.08,-0.08,v.width,v.height]".
It's not precise but it's a possible work around until they fix it if it is an issue with the later versions?
It's not precise but it's a possible work around until they fix it if it is an issue with the later versions?
-
Loopeytunes - Posts: 57
- Joined: Tue Jul 13, 2010 11:07 am
- Location: Yorkshire, UK
Re: How do you draw precise borders around a rectangle?
Loopeytunes wrote:The only work around for now that I can see is setting the "rc = [0,0,v.width,v.height]" to "rc = [-0.08,-0.08,v.width,v.height]".
It's not precise but it's a possible work around until they fix it if it is an issue with the later versions?
Ruby isn't my thing but I have noticed when messing with old Synthmaker non-Ruby stuff that a border may not fit correctly to the view area (FS 3.08.1). I remember fiddling around for ages trying to get a dropbox menu selector to have the right border. The right-hand and bottom edges were reduced in thickness.
It might be to do with the co-ordinates system which, I believe, start at the upper left corner. In this case if the drawing starts at a specified width and height then the right and lower lines will be created outside of the view area. If this is the case it would mean the co-ordinates for the start positions of the right and lower edges would have to depend on the thickness specified; change the thickness and you'd have to change the co-ordinates.
I bet someone knows about this...?
Cheers
Spogg
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: How do you draw precise borders around a rectangle?
What's so difficult in using the search function/Google?
http://www.dsprobotics.com/support/viewtopic.php?f=2&t=3246&p=17305#p17295
http://www.dsprobotics.com/support/viewtopic.php?f=2&t=3246&p=17305#p17295
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: How do you draw precise borders around a rectangle?
tulamide wrote:What's so difficult in using the search function/Google?
http://www.dsprobotics.com/support/viewtopic.php?f=2&t=3246&p=17305#p17295
But this does not address to my problem with border. Ive already set middle of the pen on the angles, but borders are still differents.
- Nowhk
- Posts: 275
- Joined: Mon Oct 27, 2014 6:45 pm
Re: How do you draw precise borders around a rectangle?
Nowhk wrote:tulamide wrote:What's so difficult in using the search function/Google?
http://www.dsprobotics.com/support/viewtopic.php?f=2&t=3246&p=17305#p17295
But this does not address to my problem with border. Ive already set middle of the pen on the angles, but borders are still differents.
They look different because it is drawn partly outside the view. If you want to make sure that there is no interpolation going on, try the same with pixel accurate values. If you didn't change the grid settings, 1 grid unit refers to 8 pixels. Then 0.4 means 3.2 pixels. Instead try it with multiples of 0.125 (which is 1 pixel) and see if the issue stays.
If not, then the interpolation because of subpixels were the cause and you should avoid using them.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: How do you draw precise borders around a rectangle?
tulamide wrote:Nowhk wrote:tulamide wrote:What's so difficult in using the search function/Google?
http://www.dsprobotics.com/support/viewtopic.php?f=2&t=3246&p=17305#p17295
But this does not address to my problem with border. Ive already set middle of the pen on the angles, but borders are still differents.
They look different because it is drawn partly outside the view. If you want to make sure that there is no interpolation going on, try the same with pixel accurate values. If you didn't change the grid settings, 1 grid unit refers to 8 pixels. Then 0.4 means 3.2 pixels. Instead try it with multiples of 0.125 (which is 1 pixel) and see if the issue stays.
If not, then the interpolation because of subpixels were the cause and you should avoid using them.
Thanks for the help, even if you tell me you will never help to me anymore
However, the problem happens the same. My grid is 1. I've set borderWidth 0.5 (which is a multiple of 0.125):
- Code: Select all
def init
@borderWidth = 0.5
end
def draw i,v
# Background
rc = [@borderWidth/2,@borderWidth/2,v.width-@borderWidth,v.height-@borderWidth]
brushBackground = Brush.new Color.new(69,75,79)
v.drawRectangle brushBackground,rc
# Border
pb = Pen.new Color.new(255,0,0),@borderWidth
v.drawRoundRect pb,rc,0
end
def event i,v
redraw 0
end
but I see the same. Or better: inside the schematic "maybe" it's a bit better (even if not precise at 100%; border top is slightly bigger than bottom):
When I switch to Focus Mode (i.e. the result when I'll render the plugin) the difference is even more noticeable:
Do you see the same?
- Nowhk
- Posts: 275
- Joined: Mon Oct 27, 2014 6:45 pm
17 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 84 guests