none
draw text and image RRS feed

  • Question

  • i have a question. im making a button that draws text on screen. but can't get it to work. what's wrong in this sample part of code? i still see background image when i click, but no text around.

    '//variables'

    path = Program.Directory
    background_image = path + "\img\background.png"

    '//main loop'
    main()
    Controls.ButtonClicked = OnButton

    '//button id'
    button_earth = Controls.AddButton("World", 185, 218)

    '//button sizes'
    Controls.SetSize(button_earth, 61, 29)

    '//main sub'
    Sub main
    GraphicsWindow.Title = "Planetarium"  
    GraphicsWindow.CanResize = "false"
    GraphicsWindow.Width = 1200
    GraphicsWindow.Height = 757
    GraphicsWindow.DrawImage(background_image, 0, 0)
    endsub

    '//planets sub'
    Sub OnButton
      If (Controls.LastClickedButton = button_earth) Then 
        main()
        GraphicsWindow.FontSize = 13
        GraphicsWindow.BrushColor = "white"
        GraphicsWindow.DrawText(726,925,"About world")
        Endif
    Endsub


    • Edited by cerestos Sunday, January 26, 2014 8:46 PM
    Sunday, January 26, 2014 8:40 PM

Answers

  • HI,

    I don't have you image, so not sure exactly how it should look, but:

    I changed the text output colour to black (to see on a white background) and changed the Y coordinate (925) to be less than the GraphicsWindow height (757);

        GraphicsWindow.BrushColor = "Black"
        GraphicsWindow.DrawText(726,625,"About world")
    
    I can see the text then, so perhaps these are the issue.

    • Marked as answer by cerestos Monday, January 27, 2014 9:46 PM
    Sunday, January 26, 2014 8:59 PM
    Moderator

All replies

  • HI,

    I don't have you image, so not sure exactly how it should look, but:

    I changed the text output colour to black (to see on a white background) and changed the Y coordinate (925) to be less than the GraphicsWindow height (757);

        GraphicsWindow.BrushColor = "Black"
        GraphicsWindow.DrawText(726,625,"About world")
    
    I can see the text then, so perhaps these are the issue.

    • Marked as answer by cerestos Monday, January 27, 2014 9:46 PM
    Sunday, January 26, 2014 8:59 PM
    Moderator
  • this is image. simply, when i click earth button, there will be a text at that coordinates.

    http://i.hizliresim.com/wO7ORZ.jpg

    i figured it out once, but thanks to SB crashing, all have gone. and my bad i didnt save frequently. so i try to build again.

    • Edited by cerestos Sunday, January 26, 2014 9:07 PM
    Sunday, January 26, 2014 9:05 PM
  • OK, so the image is quite dark, so White is a good color, but the Y coordinate is below the bottom of the GraphicsWindow.

    Change this from 925 to say 625 and it works:

    GraphicsWindow.DrawText(726,625,"About world")

    Sunday, January 26, 2014 9:35 PM
    Moderator
  • Hi cerestos

    An alternative method using a Main Loop that just infinitely loops and responds when a button is clicked.

    NBK756

    Monday, January 27, 2014 5:01 AM
    Moderator