StOneDOes Posted January 22, 2023 Share Posted January 22, 2023 It would be nice to be able to render basic 2D shapes, in a way such that you can easily resize them at any time, as oppose to having static ones that you programmatically draw into a Pixmap. For example I want to render a 2D rectangle on the UI. At the moment I'm restricted to using CreatePanel() and SetShape(). However this does not allow me to have an x2 and y2 value that are lesser than the x1 and y1 unless I write the additional logic to handle this situation; moving the whole panel to suit it. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 22, 2023 Share Posted January 22, 2023 I'm not positive - but you could create a mesh with any number of vertices and assign it to the relative render layer at the correct z depth to display as a 2D widget. You can draw sprites on top of widgets (I have done this to draw 1 pixel width lines) its kinda tempory until Josh adds support for line widgets though. If x2 or y2 are less than x1 or y1 wont that flip the direction of the triangles making up the panel / sprite? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 22, 2023 Share Posted January 22, 2023 I wonder... If a custom widget was able to add a block in its draw method that created a triangle instead of just a rectangle with curved corners. That would be cool. Then we could make any primitive shape we wanted and it would still obey all the widget rules in regards to z depth ordering? vector<Vertex> vertices; vertices.push_back(Vertex(0,0,0)); vertices.push_back(Vertex(0,1,0)); vertices.push_back(Vertex(1,1,0)); AddBlock(vertices); Quote Link to comment Share on other sites More sharing options...
Josh Posted January 22, 2023 Share Posted January 22, 2023 8 hours ago, St0neD0es said: For example I want to render a 2D rectangle on the UI. At the moment I'm restricted to using CreatePanel() and SetShape(). However this does not allow me to have an x2 and y2 value that are lesser than the x1 and y1 unless I write the additional logic to handle this situation; moving the whole panel to suit it. I don't understand this part. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
StOneDOes Posted January 23, 2023 Author Share Posted January 23, 2023 On 1/22/2023 at 12:45 PM, SpiderPig said: If x2 or y2 are less than x1 or y1 wont that flip the direction of the triangles making up the panel / sprite? I wouldn't have thought so. Not sure. 22 hours ago, Josh said: I don't understand this part. Ok so CreatePanel() takes x1, y1, height, width (not actually x2 and y2). So if you are looking at this from the perspective of an RTS where you hold click and drag to select multiple units, the point where you click becomes x1 and y1, and where ever the mouse location is once you start dragging the mouse, becomes x2 and y2. But if x1 and y1 is at 200, 200, and x2 and y2 are 100, 100 then it is problematic because you can't have a negative width and height. I can still achieve what I want using some logic, but I'm just suggesting simplicity. Does this make sense? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 23, 2023 Share Posted January 23, 2023 I see what your trying to do now. I think the best approach is to write a small class that handles this for you. Shouldn't be too hard. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 23, 2023 Share Posted January 23, 2023 I think it would be something like this: panel->SetShape(Min(mouseposition.x, origin.x), Min(mouseposition.y, origin.y), Abs(origin.x - mouseposition.x) + 1, Abs(origin.y - mouseposition.y) + 1); 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.