locked
Dynamic Shapes using small basic RRS feed

  • Question

  • Hi Team,

    I am developing a simple Paint editor for my learning purpose. I could able to draw fixed circle,triangle and square using the Small basic API like AddEllipse,AddTriangle in Shapes . Program code is XSB308

    My question is how to draw the dynamic shapes .For example, I should able to change the size of the circle similar to Paint application. Kindly provide your recommendation.

    Thanks,

    Wednesday, August 2, 2017 4:26 PM

Answers

  • RoshanPriyaKumar,

    The below snippet shows a couple of ways of increasing size. Both use the Shapes Object. One is using the Zoom method the other just keeps adding shapes of increasing size and removing the ones that were previously created. From this you should be able to make your shapes what ever size that's needed.

    'Sets graphics window size and centers display

    w=600
    h=400

    GraphicsWindow.width=w
    GraphicsWindow.height=h

    graphicswindow.left=(Desktop.width-GraphicsWindow.width)/2
    GraphicsWindow.top=(Desktop.height-graphicswindow.height)/2

    'Using Zoom Method  of Shapes Object
    GraphicsWindow.brushcolor="Blue"
    MyCircle=Shapes.AddEllipse(50,50)
    Shapes.Move(MyCircle,w/2-(50/2),h/2-(50/2))
    For x=.1 To 5 Step .1
      Shapes.Zoom(mycircle,x,x)
      Program.Delay(100)
    endfor
    Shapes.Remove(mycircle)
    Program.Delay(500)

    'Keeps Adding and Removing Shapes to increase size
    For x = 50 To 200
      MyCircle = Shapes.AddEllipse(x,x)
      Shapes.Move(MyCircle,w/2-(x/2),h/2-(x/2))
      Program.Delay(50)
      Shapes.Remove(MyCircle)
      EndFor


    JR


    Thursday, August 3, 2017 11:35 AM
    Answerer
  • See below site.  and download Lesson 3.4: Events and Interactivity Jump (PowerPoint Web Jump)

    https://social.technet.microsoft.com/wiki/contents/articles/16300.download-the-small-basic-curriculum.aspx

     this program is like a shape editor.

    If you want a more Paint like shapes editor, you can get Nonki's "Shapes.Editor" from here. 

    https://blogs.msdn.microsoft.com/smallbasic/2013/02/17/small-basic-program-gallery-listed-by-category/

       TLW744-3

    • Marked as answer by [Roshan_Kumar] Thursday, August 3, 2017 12:31 PM
    • Unmarked as answer by [Roshan_Kumar] Thursday, August 3, 2017 12:32 PM
    • Marked as answer by [Roshan_Kumar] Thursday, August 3, 2017 12:33 PM
    Thursday, August 3, 2017 12:27 PM
    Answerer
  • Hi Team,

    Controls.SetSize() is a simple way for changing height and width of a shape

    Thanks,


    Roshan - 7th Grade Student (Age 11) - Learning Small Basic and Visual Basic

    • Marked as answer by [Roshan_Kumar] Sunday, December 17, 2017 3:26 AM
    Sunday, December 17, 2017 3:26 AM

All replies

  • RoshanPriyaKumar,

    The below snippet shows a couple of ways of increasing size. Both use the Shapes Object. One is using the Zoom method the other just keeps adding shapes of increasing size and removing the ones that were previously created. From this you should be able to make your shapes what ever size that's needed.

    'Sets graphics window size and centers display

    w=600
    h=400

    GraphicsWindow.width=w
    GraphicsWindow.height=h

    graphicswindow.left=(Desktop.width-GraphicsWindow.width)/2
    GraphicsWindow.top=(Desktop.height-graphicswindow.height)/2

    'Using Zoom Method  of Shapes Object
    GraphicsWindow.brushcolor="Blue"
    MyCircle=Shapes.AddEllipse(50,50)
    Shapes.Move(MyCircle,w/2-(50/2),h/2-(50/2))
    For x=.1 To 5 Step .1
      Shapes.Zoom(mycircle,x,x)
      Program.Delay(100)
    endfor
    Shapes.Remove(mycircle)
    Program.Delay(500)

    'Keeps Adding and Removing Shapes to increase size
    For x = 50 To 200
      MyCircle = Shapes.AddEllipse(x,x)
      Shapes.Move(MyCircle,w/2-(x/2),h/2-(x/2))
      Program.Delay(50)
      Shapes.Remove(MyCircle)
      EndFor


    JR


    Thursday, August 3, 2017 11:35 AM
    Answerer
  • See below site.  and download Lesson 3.4: Events and Interactivity Jump (PowerPoint Web Jump)

    https://social.technet.microsoft.com/wiki/contents/articles/16300.download-the-small-basic-curriculum.aspx

     this program is like a shape editor.

    If you want a more Paint like shapes editor, you can get Nonki's "Shapes.Editor" from here. 

    https://blogs.msdn.microsoft.com/smallbasic/2013/02/17/small-basic-program-gallery-listed-by-category/

       TLW744-3

    • Marked as answer by [Roshan_Kumar] Thursday, August 3, 2017 12:31 PM
    • Unmarked as answer by [Roshan_Kumar] Thursday, August 3, 2017 12:32 PM
    • Marked as answer by [Roshan_Kumar] Thursday, August 3, 2017 12:33 PM
    Thursday, August 3, 2017 12:27 PM
    Answerer
  • Hi ,

    The program is nice its working good, thanks for your program

    Thanks,

    Thursday, August 3, 2017 12:33 PM
  • Hi Team,

    Controls.SetSize() is a simple way for changing height and width of a shape

    Thanks,


    Roshan - 7th Grade Student (Age 11) - Learning Small Basic and Visual Basic

    • Marked as answer by [Roshan_Kumar] Sunday, December 17, 2017 3:26 AM
    Sunday, December 17, 2017 3:26 AM