Use mouse draw line in the 2D,how to do?

It might be only me but the service you use for hosting those video asks me to install additional software and it’s not in English so I can either not watch it or risk installing something dodgy. It works on my phone, though. If you make these examples easier to access, chances are you’ll attract more attention.

The solution with the nested array I posted above should work fine for drawing multiple lines. I saw you post multiple questions, I’ll just answer some of them here:

  • To loop through an array of lines containing points:

looplines.PNG

[HR][/HR]

  • To display text, you’ll need to create widgets, something very simple will do:

widget.PNG

Set the text_label’s *isVariable *to True (upper-right corner of the details panel) so you can access it later and set its text (distance)
text_label is centred horizontally and vertically, the rest is on default

[HR][/HR]

  • To add distance labels, create a widget every time the user clicks:

The widgets that have already been placed are stored in the DistWidgets array
The widget that is still being dragged around has its own variable DistWidget, and is added to the DistWidgets array as soon as the point has been placed; a new widget is created for the next line fragment

[HR][/HR]

  • To find coordinates, you’ll need a bit of math:

Position between two Points is (A+B)/2
Distance is length of (A-B)
Those two values are sent to the Widget

[HR][/HR]

  • To make a straight line, constrain either X or Y of the mouse input

[HR][/HR]
313578ddad5571564720631d69dc7609.gif

2 Likes