none
This code has several odd behaviours RRS feed

  • General discussion

  • GraphicsWindow.KeyUp = OnKeyUp 
    GraphicsWindow.MouseUp = OnKeyUp 
     
     
    GraphicsWindow.Show() 
     
    GraphicsWindow.Width = 297 * 3 
    GraphicsWindow.Height = 210 * 3 
     
     
    loop: 
        GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor() 
     
        x = Math.GetRandomNumber( GraphicsWindow.Width ) 
        y = Math.GetRandomNumber( GraphicsWindow.Height ) 
     
        w = Math.GetRandomNumber( GraphicsWindow.Width / 100 ) 
        h = w 
     
        GraphicsWindow.FillEllipse( x , y , w , h ) 
    Goto loop 
     
     
    Sub OnKeyUp 
        Program.End() 
    EndSub  


    1, when the program exits it always crashes
    2, the gwindow is not allways set to the size specified, sometime the height does not get set  try running several times
    3, pattern it creates is not random, i know 'random' numbers behave.....

    All these issue are out of the bounds of the language to fix




    Wanabie mdx ninja
    Friday, October 31, 2008 5:06 PM

All replies

  • Hi Adrian,

    Thanks for your feedback.

    #1: is a known issue and will be fixed for the next release.
    #2: could you please elaborate on your observation?  When I run the program, the window's height and width are being set all the time.
    #3: could you describe what you are expecting the program to do?  For me, the GraphicsWindow gets filled with ellipses that are randomly sized between 1 and 6, and that looks like the correct behavior.
    Saturday, November 1, 2008 5:32 AM
    Moderator
  • Vijaye,

    #2 When I was building the code,  i kept running it, sometime the window did not set the height, like 1 time in 4 the height was not being set. I've had another go, an i wonder if tidying the code for post hid the issue. The following  code seems exhit the same behabiour though:

    'GraphicsWindow.Show()
    GraphicsWindow.Width = 100
    GraphicsWindow.Height = 100
    GraphicsWindow.Show()


    GraphicsWindow.Title = GraphicsWindow.Width +":"+ GraphicsWindow.Width



    Try the show in different positions and run.

    Also, if you set the size and then query the size, they are not equal, they should be the same, give the user scope of Small Basic?.....




    #3

    the colour distribution is not random, though. This may be more to do with the Random implementation, seeds etc, but on my machine the random colours always distrubute like this:

    Top left Blue
    Top right Magenta
    Bottom right Cyan
    Botton left Yellow

    BM
    CY

    Wanabie mdx ninja
    Monday, November 3, 2008 12:06 PM
  • #2: Good catch, Adrian.  Thanks for the repro - I've filed a bug and will be fixed for our next release.

    #3: The library code looks like this:

            public static Primitive GetRandomColor()
            {
                if (_random == null)
                    _random = new Random((int)DateTime.Now.Ticks);
                return string.Format("#{0:X2}{1:X2}{2:X2}", 
                                        _random.Next(256), 
                                        _random.Next(256), 
                                        _random.Next(256));
            }

    And I'm not noticing the color distribution that you described.  Could you please post a screenshot that describes your observation?
    Tuesday, November 4, 2008 5:47 PM
    Moderator
  • Whats the best way to post pictures here? Place it on flickr and link?
    Wanabie mdx ninja
    Wednesday, November 5, 2008 9:25 AM
  • Unfortunately there's no picture storage provided by the forums.  You'll have to host it somewhere and point it from here :(
    Wednesday, November 5, 2008 10:48 AM
    Moderator
  • Again it seem itermitent, between ide starts or between running the code several times.   sometimes get the random distribution on the left , but mainly i get the not so random distrubution on the right Free Image Hosting at www.ImageShack.us $0 
    Wanabie mdx ninja
    Wednesday, November 5, 2008 3:52 PM
  • Thanks for the screenshot, Adrian.  The second shot definitely seems odd.  I'm not sure what's wrong and I'm unable to repro this on my Vista machine.  However, now that I understand the result, I'll keep a lookout for something that might trigger such a pattern.
    Wednesday, November 5, 2008 5:36 PM
    Moderator
  • I get a nearly identical colour distribution - although there are two things that are different - 1) random blue dots appear all over the window 2) after some time running the program in the background I switched (alt-tab) to it, and it crashed.
    Sunday, November 9, 2008 11:57 AM