change shape properties during runtime

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
AmazingCircuitPythonFR35
 
Posts: 99
Joined: Thu Feb 05, 2015 10:18 am

change shape properties during runtime

Post by AmazingCircuitPythonFR35 »

Hello,

In circuitpython, when we draw a shape (line, circle, rectangle) on an LCD screen for example with the "adafruit_display_shapes" library, is it possible to modify the coordinates of this shape during the code execution?

If I write the following line:

Code: Select all

Line1 = adafruit_display_shapes.line.Line(0, 0, 120, 120, 0xFF0000)

My line is displayed correctly, but it seems impossible to modify the properties of this line like for example :

Code: Select all

Line1.x1 = 150
Line1.y1 = 150
Is this true? Why not? Is there any other way to modify a form at runtime?

Kind regards,

Mike

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: change shape properties during runtime

Post by mikeysklar »

Are you also modifying the x0 and y0 parameters? Implementation notes
classadafruit_display_shapes.line.Line(*args: Any, **kwargs: Any)
A line.

Parameters
:
x0 (int) – The x-position of the first vertex.

y0 (int) – The y-position of the first vertex.

x1 (int) – The x-position of the second vertex.

y1 (int) – The y-position of the second vertex.

color (int) – The color of the line.

User avatar
AmazingCircuitPythonFR35
 
Posts: 99
Joined: Thu Feb 05, 2015 10:18 am

Re: change shape properties during runtime

Post by AmazingCircuitPythonFR35 »

mikeysklar wrote: Wed May 24, 2023 3:43 pm Are you also modifying the x0 and y0 parameters? Implementation notes
classadafruit_display_shapes.line.Line(*args: Any, **kwargs: Any)
A line.

Parameters
:
x0 (int) – The x-position of the first vertex.

y0 (int) – The y-position of the first vertex.

x1 (int) – The x-position of the second vertex.

y1 (int) – The y-position of the second vertex.

color (int) – The color of the line.
No, actually I have a speedometer with a needle. This one is materialized by the line. Its x0,y0 coordinates are fixed and correspond to the center of the speedometer. However, the other end, x1,y1, changes according to the speed.
And I can't change them on the fly. I have to create a new line each time and then delete it between updates.

Mike

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: change shape properties during runtime

Post by mikeysklar »

Having a way to update the position without re-creating the line constructor seems like a reasonable feature request.

Are you comfortable opening an issue requesting this?

User avatar
AmazingCircuitPythonFR35
 
Posts: 99
Joined: Thu Feb 05, 2015 10:18 am

Re: change shape properties during runtime

Post by AmazingCircuitPythonFR35 »

mikeysklar wrote: Thu May 25, 2023 5:23 pm Having a way to update the position without re-creating the line constructor seems like a reasonable feature request.

Are you comfortable opening an issue requesting this?
I've never done that, but I'll give it a try ;-)

Mike

User avatar
AmazingCircuitPythonFR35
 
Posts: 99
Joined: Thu Feb 05, 2015 10:18 am

Re: change shape properties during runtime

Post by AmazingCircuitPythonFR35 »

it's done, I've filed an issue :

https://github.com/adafruit/Adafruit_Ci ... /issues/61

Mike

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: change shape properties during runtime

Post by mikeysklar »

Nice. I see it got tagged as an enhancement so that is a good thing (better than be rejected).

One thought. If you want to consider doing a PR (Pull Request to tell others about changes you have made) take a look at the multisparkline.py—>update_line() function which is quite similiar to what you are looking for with line.py.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”