Support

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?

For general discussion related FlowStone

How do you draw precise borders around a rectangle?

Postby Nowhk » Thu Jan 14, 2016 12:02 pm

This is my basic code for draw a rectlangle with a small border around it:

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:

Immagine.png
Immagine.png (3.71 KiB) Viewed 17185 times

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:

# Border.fsm
(454 Bytes) Downloaded 791 times
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How do you draw precise borders around a rectangle?

Postby Nowhk » Thu Jan 14, 2016 1:02 pm

I've tried this suggestion: viewtopic.php?f=2&t=1074

but when I render the plug, the border bottom seems incorrect anyway:

Immagine.png
Immagine.png (5.43 KiB) Viewed 17181 times


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?

Postby rocknrollkat » Mon Jan 18, 2016 2:03 pm

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
Attachments
screenshot-borders.png
Better late than never, does this help anyone ?
screenshot-borders.png (676.62 KiB) Viewed 17145 times
User avatar
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?

Postby Nowhk » Mon Jan 18, 2016 2:19 pm

I don't know? 3.0.8 (FL) and 3.0.7 (standalone, demo) does it :shock:
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?

Postby Loopeytunes » Mon Jan 18, 2016 4:57 pm

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?
User avatar
Loopeytunes
 
Posts: 57
Joined: Tue Jul 13, 2010 11:07 am
Location: Yorkshire, UK

Re: How do you draw precise borders around a rectangle?

Postby Spogg » Mon Jan 18, 2016 6:04 pm

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
User avatar
Spogg
 
Posts: 3358
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: How do you draw precise borders around a rectangle?

Postby tulamide » Mon Jan 18, 2016 6:58 pm

What's so difficult in using the search function/Google?

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?

Postby Nowhk » Mon Jan 18, 2016 7:17 pm

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. :shock:
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How do you draw precise borders around a rectangle?

Postby tulamide » Mon Jan 18, 2016 7:34 pm

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. :shock:

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?

Postby Nowhk » Tue Jan 19, 2016 10:05 am

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. :shock:

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 :roll:
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):

001.png
001.png (3.44 KiB) Viewed 17110 times

When I switch to Focus Mode (i.e. the result when I'll render the plugin) the difference is even more noticeable:

002.png
002.png (10.58 KiB) Viewed 17110 times

Do you see the same?

Rectangle Border.fsm
(484 Bytes) Downloaded 833 times
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 85 guests