none
How do I hide "graphicswindow.draw_________" shapes without covering them up? RRS feed

  • Question

  •  Hello, I was wondering how I would hide/remove any "GraphicsWindow.draw______" shape without covering it up with another shape? For example: when I click a button, I want a certain shape and/or text to be removed/hidden. Please help me.       Or is it possible to add text onto a "Shape.add______" shape and be able to remove both the "Shape.add_____" shape and the text on it?

                                                                                                                                                         Thanks in advance :)

    Monday, July 7, 2014 5:28 PM

Answers

  • Anything created with GraphicsWIndow.Draw... or GraphicsWIndow.Fil... cannot easily be moved hidden etc - they are fixed drawings on the background.  To hide or move something use Shapes.Add...

    For movable, hidable Text, try Shapes.AddText, for other shapes with text will need extensions.

    Also see here for more details.


    Monday, July 7, 2014 5:53 PM
    Moderator
  • If I read your question correctly, you want to cover up text by performing an event without using any shapes. Like what LitDiv said, you could use Shapes.AddText (text) as text then set its opacity (which would be set outside the event subroutine) with Shapes.SetOpacity(shapeName,level). The level ranges from 0 to 100: 0 being transparent and 100 being opaque (or visible). Inside the event subroutine you would set another " Shapes.SetOpacity(shapeName,level) so when you perform an action the opacity will be set to zero and it will become transparent. Below is an example of my explanation. In the example, there's a purple rectangle and some red text that says "Press the arrow keys!". When the user presses one of the arrow keys the text will change opacity and will appear transparent as if it disappeared from the program. I encourage you to copy and paste this code so you could better understand my explanation. Please, let me know if I answered your question and the program I posted works. Good luck.

    GraphicsWindow.Width = 1500
    GraphicsWindow.Height = 800
    GraphicsWindow.Top = 0
    GraphicsWindow.Left = 0
    
    GraphicsWindow.BrushColor = "Red"
    GraphicsWindow.FontSize = 20 
    directions = Shapes.AddText("Press the arrow keys!")
    Shapes.Move(directions,550,50)
    Shapes.SetOpacity(directions,100)
    
    x = 200
    y = 150
    GraphicsWindow.BrushColor = "Purple"
    rect = Shapes.AddRectangle(175,100)
    Shapes.Move(rect,x,y)
    GraphicsWindow.KeyDown = rectControls
    
    Sub rectControls
      GraphicsWindow.BrushColor = "White"
      GraphicsWindow.FontSize = 20 
      GraphicsWindow.DrawText(550,50,directions) 
      
      If (GraphicsWindow.LastKey = "Right" And x < 1195) Then
        hide = 1 
        Shapes.Rotate(rect,0)
        Shapes.Move(rect,x+10,y)
        x = x + 10
      ElseIf (GraphicsWindow.LastKey = "Left" And x > -5) Then 
        hide = 1
        Shapes.Rotate(rect,0)
        Shapes.Move(rect,x-10,y)
        x = x - 10
      ElseIf (GraphicsWindow.LastKey = "Up" And y > 25) Then 
        hide = 1
        Shapes.Rotate(rect,90)
        Shapes.Move(rect,x,y-10)
        y = y - 10
      ElseIf (GraphicsWindow.LastKey = "Down" And y < 610) Then 
        hide = 1
        Shapes.Rotate(rect,90)
        Shapes.Move(rect,x,y+10)
        y = y + 10
      EndIf 
      
      If (hide = 1) Then 
        Shapes.SetOpacity(directions,0)
      EndIf 
    EndSub 

    Wednesday, July 9, 2014 11:08 PM

All replies

  • Anything created with GraphicsWIndow.Draw... or GraphicsWIndow.Fil... cannot easily be moved hidden etc - they are fixed drawings on the background.  To hide or move something use Shapes.Add...

    For movable, hidable Text, try Shapes.AddText, for other shapes with text will need extensions.

    Also see here for more details.


    Monday, July 7, 2014 5:53 PM
    Moderator
  • If I read your question correctly, you want to cover up text by performing an event without using any shapes. Like what LitDiv said, you could use Shapes.AddText (text) as text then set its opacity (which would be set outside the event subroutine) with Shapes.SetOpacity(shapeName,level). The level ranges from 0 to 100: 0 being transparent and 100 being opaque (or visible). Inside the event subroutine you would set another " Shapes.SetOpacity(shapeName,level) so when you perform an action the opacity will be set to zero and it will become transparent. Below is an example of my explanation. In the example, there's a purple rectangle and some red text that says "Press the arrow keys!". When the user presses one of the arrow keys the text will change opacity and will appear transparent as if it disappeared from the program. I encourage you to copy and paste this code so you could better understand my explanation. Please, let me know if I answered your question and the program I posted works. Good luck.

    GraphicsWindow.Width = 1500
    GraphicsWindow.Height = 800
    GraphicsWindow.Top = 0
    GraphicsWindow.Left = 0
    
    GraphicsWindow.BrushColor = "Red"
    GraphicsWindow.FontSize = 20 
    directions = Shapes.AddText("Press the arrow keys!")
    Shapes.Move(directions,550,50)
    Shapes.SetOpacity(directions,100)
    
    x = 200
    y = 150
    GraphicsWindow.BrushColor = "Purple"
    rect = Shapes.AddRectangle(175,100)
    Shapes.Move(rect,x,y)
    GraphicsWindow.KeyDown = rectControls
    
    Sub rectControls
      GraphicsWindow.BrushColor = "White"
      GraphicsWindow.FontSize = 20 
      GraphicsWindow.DrawText(550,50,directions) 
      
      If (GraphicsWindow.LastKey = "Right" And x < 1195) Then
        hide = 1 
        Shapes.Rotate(rect,0)
        Shapes.Move(rect,x+10,y)
        x = x + 10
      ElseIf (GraphicsWindow.LastKey = "Left" And x > -5) Then 
        hide = 1
        Shapes.Rotate(rect,0)
        Shapes.Move(rect,x-10,y)
        x = x - 10
      ElseIf (GraphicsWindow.LastKey = "Up" And y > 25) Then 
        hide = 1
        Shapes.Rotate(rect,90)
        Shapes.Move(rect,x,y-10)
        y = y - 10
      ElseIf (GraphicsWindow.LastKey = "Down" And y < 610) Then 
        hide = 1
        Shapes.Rotate(rect,90)
        Shapes.Move(rect,x,y+10)
        y = y + 10
      EndIf 
      
      If (hide = 1) Then 
        Shapes.SetOpacity(directions,0)
      EndIf 
    EndSub 

    Wednesday, July 9, 2014 11:08 PM