Want to learn "view.draw2d"...is there any basic examples?
-
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 -
Check out the source of ThomThom's Camera Tools. It uses view.draw2d to draw a rolling circle on the screen.
-
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?
-
@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..
-
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!
-
@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)
-
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 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
-
@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.
-
@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)
Advertisement