Q Quillok Member Licensed User Longtime User Dec 7, 2012 #1 Hi, got a little problem with the Rect in Canvasdrawing. SampleCode: Code: dim a,b,c,d as float a = 18.75 b = 22.75 c = 100 d = 120 dim HelpRect as Rect Helprect.initialize(a,b,c,d) When in debugging mode and I hover with the mouse over the HelpRect, I can see that the Values are (18,22,100,120) what gives me some problems in drawing because it causes gaps. Is the rect only able to save the values as int? Is there another solution for it or did I have do change all my float-vars into int-vars? If so I had to change most of my current code :/ Can anybody give me a solution for my problem?
Hi, got a little problem with the Rect in Canvasdrawing. SampleCode: Code: dim a,b,c,d as float a = 18.75 b = 22.75 c = 100 d = 120 dim HelpRect as Rect Helprect.initialize(a,b,c,d) When in debugging mode and I hover with the mouse over the HelpRect, I can see that the Values are (18,22,100,120) what gives me some problems in drawing because it causes gaps. Is the rect only able to save the values as int? Is there another solution for it or did I have do change all my float-vars into int-vars? If so I had to change most of my current code :/ Can anybody give me a solution for my problem?
klaus Expert Licensed User Longtime User Dec 7, 2012 #2 The Rect object uses Int values which are pixel numbers. What do you expect beeing drawn with 18.75 pixels ? If you use Float numbers they are converted to integers. Best regards. Upvote 0
The Rect object uses Int values which are pixel numbers. What do you expect beeing drawn with 18.75 pixels ? If you use Float numbers they are converted to integers. Best regards.
Q Quillok Member Licensed User Longtime User Dec 7, 2012 #3 Ok, thanks, so I have to change my code :/ I wanted to use as much of the screen as possible, I want to draw a lot of squares. At the beginning of the text I calculate the cellsize with the help of the activity.width and the cellnumbers: Code: dim CellSize as float Cellsize = activity.width / 64 In most cases there comes out a float. If I use integer, there will be space that isnt used, because 64 * 18 = 1152, but 64 * 18.75 = 1200 It is not so much, but that makes everything a little bit smaller and not every space is used... but ok, thanks for helping Upvote 0
Ok, thanks, so I have to change my code :/ I wanted to use as much of the screen as possible, I want to draw a lot of squares. At the beginning of the text I calculate the cellsize with the help of the activity.width and the cellnumbers: Code: dim CellSize as float Cellsize = activity.width / 64 In most cases there comes out a float. If I use integer, there will be space that isnt used, because 64 * 18 = 1152, but 64 * 18.75 = 1200 It is not so much, but that makes everything a little bit smaller and not every space is used... but ok, thanks for helping
S sorex Expert Licensed User Longtime User Dec 7, 2012 #4 you'll have more luck with floor(64*18.75) than with the 64*floor(18.75) you were using now Upvote 0
klaus Expert Licensed User Longtime User Dec 7, 2012 #5 As the cell width can only be an integer you cannot cover the whole space. I suppose that you don't want to have cells with different widths. So you can introduce a LeftMargin value to center the cells on the screen. I would suggest you the following: Code: CellWidth = Floor(100%x / 64) LeftMargin = (100%x - 64 * CellWidth) / 2 And when you fill the screen begin with LeftMargin instead of 0. Best regards. Upvote 0
As the cell width can only be an integer you cannot cover the whole space. I suppose that you don't want to have cells with different widths. So you can introduce a LeftMargin value to center the cells on the screen. I would suggest you the following: Code: CellWidth = Floor(100%x / 64) LeftMargin = (100%x - 64 * CellWidth) / 2 And when you fill the screen begin with LeftMargin instead of 0. Best regards.