sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Want to learn "view.draw2d"...is there any basic examples?

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 6 Posters 432 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • renderizaR Offline
      renderiza
      last edited by

      Hi,

      Want to learn using "view.draw2d" and was wondering if there is a very basic example code I can use for learning.

      Thanks,
      Renderiza

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • A Offline
        Anton_S
        last edited by

        Check out the source of ThomThom's Camera Tools. It uses view.draw2d to draw a rolling circle on the screen.

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          Thank you Anton_S I will check that out indeed!

          Here a simple box... 😍

          
          def draw(view)
          			
            pt1 = [15, 100, 0]
            pt2 = [600, 100, 0]
            pt3 = [600, 400, 0]
            pt4 = [15, 400, 0]
            pts = [pt1, pt2, pt3, pt4]
          
            drawColor = Sketchup;;Color.new(100, 100, 100, 80)
            view.drawing_color = drawColor
            view.draw2d(GL_QUADS, pts)
          
          end
          
          

          Important Question!!!!...Can I use image like PNG for example? ❓

          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

          1 Reply Last reply Reply Quote 0
          • jolranJ Offline
            jolran
            last edited by

            @unknownuser said:

            Check out the source of ThomThom's Camera Tools. It uses view.draw2d to draw a rolling circle on the screen.

            That's a good find. How on Earth did I miss that one...
            (Experimenting with draw-tool methods as well at the moment.)

            Theres is also Thomthoms drawingcache:

            https://bitbucket.org/thomthom/tt-library-2/src/tip/TT_Lib2/draw_cache.rb?at=Version%202.8

            It permitts to call draw outside the class.

            And for a beast :

            https://bitbucket.org/Aerilius/onscreen-gui/wiki/Home

            I don't know if thoose two helps for "studying", they are quite advanced πŸ˜„

            @unknownuser said:

            Important Question!!!!...Can I use image like PNG for example? ❓

            As what ? You can use a PNG as cursor in your tool, that's all I know about..

            1 Reply Last reply Reply Quote 0
            • renderizaR Offline
              renderiza
              last edited by

              Thanks for your recommendations jolran! πŸ‘

              @jolran said:

              And for a beast :

              https://bitbucket.org/Aerilius/onscreen-gui/wiki/Home

              I don't know if thoose two helps for "studying", they are quite advanced πŸ˜„

              Very impressive!!!... Will have a look at it, but yeah it seems too advance for me at the moment.

              @jolran said:

              As what ? You can use a PNG as cursor in your tool, that's all I know about..

              Yeah I know about using png as cursor but I was thinking more like making a style watermark type of thing. Take the small code on my previews post where it makes a square, I am wondering if I can use a texture image instead of the rgb color.

              Cheers!

              [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

              1 Reply Last reply Reply Quote 0
              • jolranJ Offline
                jolran
                last edited by

                @unknownuser said:

                Very impressive!!!... Will have a look at it, but yeah it seems too advance for me at the moment.

                Yeah, the code is BIG, so it may take to much effort to digest all that.
                Probably better idea to start experiment on your own a little first..

                Have a look at TT's drawecache class and the especially the "send" method.

                Pretty handy to cary methodneames around as symbols and execute them with send(:methodname)

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  Thom wrote a method to use bitmaps, but I don't think he ever used png's. I think his bmp code might be wrapped up in TTLib?

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • fredo6F Offline
                    fredo6
                    last edited by

                    @chris fullmer said:

                    Thom wrote a method to use bitmaps, but I don't think he ever used png's. I think his bmp code might be wrapped up in TTLib?

                    Chris,
                    I think there is a general request to have a view.draw_picture, which would ease the design of GUI, in particular buttons and marks (instead of drawing them with lines and polygon).
                    Maybe in a next release?

                    Fredo

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      @chris fullmer said:

                      Thom wrote a method to use bitmaps, but I don't think he ever used png's. I think his bmp code might be wrapped up in TTLib?

                      Correct. It only draws BMP because the code to decode PNG files was too complex. But in any case it was really slow and you couldn't draw much before the viewport became slow. I'm replacing Vertex Tools' on-screen-toolbar to use vector symbols instead.

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @renderiza said:

                        Want to learn using "view.draw2d" and was wondering if there is a very basic example code I can use for learning.

                        It has to be used within a Tool. You invalidate the viewport when something needs to be drawn. And the method then simply accept a set of 2d points (defined by Geom::Point3d)

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement