locked
Change the color of shapes after creating them RRS feed

  • Question

  • If I create a shape with a certain color, can I change the color after that? To avoid this I used GraphicsWindow commands to draw anything with a certain color, clear the window, and then draw the shape again with another brush color. The problem is that the flashing screen is disturbing.
    Monday, August 22, 2016 10:06 PM

Answers

  • Instead of clear the window, i would try to

    1)draw a shape in red for ex.

    2) remove the shape

    3) redraw the shape in blue

     i think here will be no flashing screen here.

    try this prggram, draw a red rectangle, chnage color to blue, and red, and blue, indefinitely

    ______________________________________________________________________________

    while 1=1
     
    GraphicsWindow.BrushColor="red"
    rectangle = Shapes.AddRectangle(400, 300)
    Shapes.Move(rectangle, 100, 50)
     
    Shapes.ShowShape(rectangle)
    Program.Delay(1000)      
    Shapes.remove(rectangle)
       
    GraphicsWindow.BrushColor="blue"
    rectangle = Shapes.AddRectangle(400, 300)
    Shapes.Move(rectangle, 100, 50)
    Shapes.ShowShape(rectangle)
    Program.Delay(1000)      
    Shapes.remove(rectangle)
    EndWhile

    ________________________________________________________________________________

    • Edited by YLedEditor Monday, August 22, 2016 11:12 PM
    • Proposed as answer by Nonki Takahashi Wednesday, August 24, 2016 2:35 AM
    • Marked as answer by litdev Sunday, August 28, 2016 9:19 AM
    Monday, August 22, 2016 10:50 PM
    Answerer
  • Or you can use LitDev extension.

    points[1] = "1=100;2=100;"
    points[2] = "1=150;2=50;"
    points[3] = "1=200;2=100;"
    points[4] = "1=200;2=200;"
    points[5] = "1=100;2=200;"
    p = LDShapes.AddPolygon(points)
    Program.Delay(1000)
    LDShapes.BrushColour(p, "Yellow")


    Nonki Takahashi

    • Marked as answer by litdev Sunday, August 28, 2016 9:19 AM
    Wednesday, August 24, 2016 2:36 AM

All replies

  • Instead of clear the window, i would try to

    1)draw a shape in red for ex.

    2) remove the shape

    3) redraw the shape in blue

     i think here will be no flashing screen here.

    try this prggram, draw a red rectangle, chnage color to blue, and red, and blue, indefinitely

    ______________________________________________________________________________

    while 1=1
     
    GraphicsWindow.BrushColor="red"
    rectangle = Shapes.AddRectangle(400, 300)
    Shapes.Move(rectangle, 100, 50)
     
    Shapes.ShowShape(rectangle)
    Program.Delay(1000)      
    Shapes.remove(rectangle)
       
    GraphicsWindow.BrushColor="blue"
    rectangle = Shapes.AddRectangle(400, 300)
    Shapes.Move(rectangle, 100, 50)
    Shapes.ShowShape(rectangle)
    Program.Delay(1000)      
    Shapes.remove(rectangle)
    EndWhile

    ________________________________________________________________________________

    • Edited by YLedEditor Monday, August 22, 2016 11:12 PM
    • Proposed as answer by Nonki Takahashi Wednesday, August 24, 2016 2:35 AM
    • Marked as answer by litdev Sunday, August 28, 2016 9:19 AM
    Monday, August 22, 2016 10:50 PM
    Answerer
  • Wow, never thought it would actually work! At first i guessed it would happen the same as in the GraphicsWindow commands: white flashes between the color switch. Well, thank you, learned something new today! :P
    Monday, August 22, 2016 11:33 PM
  • Or you can use LitDev extension.

    points[1] = "1=100;2=100;"
    points[2] = "1=150;2=50;"
    points[3] = "1=200;2=100;"
    points[4] = "1=200;2=200;"
    points[5] = "1=100;2=200;"
    p = LDShapes.AddPolygon(points)
    Program.Delay(1000)
    LDShapes.BrushColour(p, "Yellow")


    Nonki Takahashi

    • Marked as answer by litdev Sunday, August 28, 2016 9:19 AM
    Wednesday, August 24, 2016 2:36 AM