Knight Posted May 18, 2017 Share Posted May 18, 2017 I want the player to draw a free-form line on the screen. I've managed it by using Lines2D. Now I want to put some textures on the line. How should I do that? Quote Link to comment Share on other sites More sharing options...
JohnK Posted May 19, 2017 Share Posted May 19, 2017 Hi and welcome to the forum and apologies that it has taken so long to get a reply, and one that will not be all that helpful sorry to say. Lines2D is part of Canvas2D which I not very familiar with however the documentation states that Lines2D inherits from Shape2D which uses a Brush for its fill and only uses a solid color or a gradient color, so unless a Canvas2D expert says otherwise I would say no textures. There is an alternative, using a tube to draw the line Check the PG that goes with the above post. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 19, 2017 Share Posted May 19, 2017 Hi guys. I was thinking of one other way. Use a standard BJS plane (.isPickable = false), parented to camera (in a way where plane area == renderCanvas area)... then apply empty BJS dynamicTexture onto plane. (Like a piece of clear glass... placed precisely atop the renderCanvas. Similar to a ScreenSpaceCanvas2D, but not one.) Then use .getContext() to get the context2d of that dynamicTexture, and start making "strokes" on it. Remember to update your dynamicTexture after each change. https://www.w3.org/TR/2014/CR-2dcontext-20140821/#fill-and-stroke-styles "Pattern" is a type of fill, there. pattern = context.createPattern(image, repetition) "image". Yay! Could be possible. Wear your hard hat... things might blow up. (probably won't) Some crazy playground-maker was doing something weird... here. Looks pretty fancy. I found that PG ... while I was searching-for a simple playground that showed .update()... like this playground... line 32. Party on, guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.