More graphical elements in custom widgets

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

User avatar
juvete
Posts: 13
Joined: 29 Mar 2013 22:01

More graphical elements in custom widgets

Post by juvete » 13 Oct 2017 21:00

It would be great if we can have more graphical elements in custom widgets, like polygons, polylines, spline curves, points, grids, etc.
Currently we are limited to rectangles and ellipses.

yanoosh
Posts: 4
Joined: 24 May 2016 14:05

Re: More graphical elements in custom widgets

Post by yanoosh » 27 Dec 2017 12:08

As workaround you can use image element and create picture with any shape you want.

User avatar
juvete
Posts: 13
Joined: 29 Mar 2013 22:01

Re: More graphical elements in custom widgets

Post by juvete » 27 Dec 2017 15:08

Yanoosh, thank you for the suggestion, but it won't work in many cases where you have dynamic data that changes unpredictably over time. For example, I would like to implement a weather widget similar to AIX Weather, with a 24h temperature graph. I tried to use rectangles to draw graph's grid, but the scale changes in time and the logic to redraw the grid becomes really ugly.

xdauser
Posts: 35
Joined: 05 Aug 2015 17:55

Re: More graphical elements in custom widgets

Post by xdauser » 28 Dec 2017 18:22

Would be nice to have ability to set opacity to images as well...

User avatar
TheBrain1984
Posts: 137
Joined: 07 Aug 2013 08:17
Location: Germany

Re: More graphical elements in custom widgets

Post by TheBrain1984 » 12 Jan 2018 22:53

A good start would be to add a triangle. With a triangle (and the possibiltiy to make just one or two lines visible) it would be possible to create any polygon and grids and lot more

User avatar
juvete
Posts: 13
Joined: 29 Mar 2013 22:01

Re: More graphical elements in custom widgets

Post by juvete » 13 Jan 2018 00:14

Using triangle as a 2D primitive to build polygons, grids, etc. does not make it any simpler or cleaner than using rectangles. Your suggestion is fine if you intend to build complicated geometry that is static, but if your resulting shape has to change in size/position/form based on variables, then you will have a very hard time coding the transformations required for each of the triangles that make up your resulting shape.
What I would suggest is something similar to the way AutoCAD draws 2D primitives. I understand that Automagic is not a CAD software, but I think AutoCAD can be used as source of inspiration.
I am not an Android developer by any means, but I can see that Android SDK offers 2D graphics capabilities: https://developer.android.com/guide/top ... #drawables, so I'm assuming that 2D primitives can theoretically be possible in Automagic.
For starters, the basic primitives that could be implemented might be similar to these:
ELLIPSE (https://knowledge.autodesk.com/support/ ... 3-htm.html)
POLYLINE (https://knowledge.autodesk.com/support/ ... 4-htm.html)
GRID could be implemented for example by specifying the number of horizontal/vertical lines along with the distances between them. Drawing a grid with polylines would be possible, but again, you end up with many lines to adjust in the case of a dynamic grid.
An ellipse object can be made to draw ellipses, circles or arcs of ellipses/circles. A polyline object can be used to draw any other polygonal shape. If variables can be passed to the input parameters defining these objects, then you end up with dynamic 2D geometry with very little code.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: More graphical elements in custom widgets

Post by digitalstone » 13 Mar 2018 12:07

What about folder-structured boolean subtraction?
You could have 2 rectangles, add a boolean function on them, they'll end up in a folder... to form an L-shape/corner.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
juvete
Posts: 13
Joined: 29 Mar 2013 22:01

Re: More graphical elements in custom widgets

Post by juvete » 15 Mar 2018 17:25

digitalstone wrote:What about folder-structured boolean subtraction?
You could have 2 rectangles, add a boolean function on them, they'll end up in a folder... to form an L-shape/corner.
I would be happy enough if 2D primitives in Android SDK are exposed to Automagic scripting. What you suggest might be a nice operator on 2D primitives, but I think it would be very difficult to implement with other primitives like ellipse or arc.
As a user, I don't care much about how it's implemented, as long as I have more options to draw in a widget ;)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: More graphical elements in custom widgets

Post by Desmanto » 16 Mar 2018 13:18

Having more element choices would be nice. I have to struggled to create a graph for my next flow. But It is very nice to know that we can do it already using currently what Automagic has. I created graph from the rectangles.
graph.png
graph.png (72.83 KiB) Viewed 29955 times
This is a widget consist of 4 graphs, to show 4 signal properties from my wifi modem. I am going to use it to check the best position for the modem, to get the maximum achievable speed. It consists of 4 x 100 loops to update the whole data and several texts there. The widget itself is about 800 Kb!!! Consists of 400+ elements (while my total flows.xml only just above 1 MB). The graphs shown above still use dummy data I generated from random number, thus still sporadic (not smooth). Single loop execution require about 600-800 ms to finish, and I use a sleep about 200-400 ms to make it update per second.

If we can have "Graph" element, which feed on input with list type, I don't need to loop for those 400 loops anymore, which will make the execution faster. The graph can be adjusted with how many elements it has (in my case it is 100), so the input must be 100 elements too (or autofill blank elements to 100). There will be max and min value and the length of the x y axis to plot the graph.

This is not critical, because I only find one or two usage from this kind of widget.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: More graphical elements in custom widgets

Post by digitalstone » 16 Mar 2018 13:27

Desmanto wrote:Having more element choices would be nice. I have to struggled to create a graph for my next flow. But It is very nice to know that we can do it already using currently what Automagic has. I created graph from the rectangles.
graph.png
This is a widget consist of 4 graphs, to show 4 signal properties from my wifi modem. I am going to use it to check the best position for the modem, to get the maximum achievable speed. It consists of 4 x 100 loops to update the whole data and several texts there. The widget itself is about 800 Kb!!! Consists of 400+ elements (while my total flows.xml only just above 1 MB). The graphs shown above still use dummy data I generated from random number, thus still sporadic (not smooth). Single loop execution require about 600-800 ms to finish, and I use a sleep about 200-400 ms to make it update per second.

If we can have "Graph" element, which feed on input with list type, I don't need to loop for those 400 loops anymore, which will make the execution faster. The graph can be adjusted with how many elements it has (in my case it is 100), so the input must be 100 elements too (or autofill blank elements to 100). There will be max and min value and the length of the x y axis to plot the graph.

This is not critical, because I only find one or two usage from this kind of widget.
I have similar plans for these kind of graphs, yet i'm not starting on that kind of widget building since i can already see the unbelievable amount of clutter hanging about.
Rectangles (shapes in general) can't be dynamically created, and i think there is something "unclean" about that.

About the boolean thing: I think a single boolean function could, for now potentially, exponentially increase the amount of possibilities of shapes you can create.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

Locked