Commit Graph

37 Commits

Author SHA1 Message Date
Jeff Epler
621953c960
Additional missing-prototypes fixes
I think this correctly enables missing-prototypes in atmel-samd
and raspberrypi ports.
2021-11-10 10:55:53 -06:00
James Carr
145836e7e5
Make the x and y bounds checking functions static 2021-09-11 17:10:21 +01:00
James Carr
2bc260a102
Rework of changes to bounds checking of location in VectorShape, moving most of the code into shared-module. 2021-09-10 21:48:01 +01:00
James Carr
c6f2dae591
Remove unused varg part of Error calls. 2021-09-10 09:39:20 +01:00
James Carr
1f446916c3
Improve the bounds checking on the location (the x, y co-ordinates) of a
VectorShape object so that it is consistent no matter where it is set from:
 * the constructor
 * the x and y setters
 * the location setter
2021-09-10 09:39:12 +01:00
Kenny
cf2712d23f transposing and mirroring work
* fix absolute_transform dirtying early instead of after the change, missing the draw
* fix transpose and mirror. (0,0) -> location in all vector shapes now in all rotations.
2021-08-08 17:01:36 -07:00
Kenny
7eece7d959 dirty area computed for non-transposed but at least d-1 2021-08-08 15:35:36 -07:00
Kenny
9897ac6b5c yet more failures of local pre-commit to find that which github pre-commit does 2021-08-08 00:25:17 -07:00
Kenny
a1fff320fb add location property to vectorshape and all composed shapes 2021-08-08 00:14:53 -07:00
Kenny
bb25aeee51 fix code formatting that pre-commit --all-files did not locally report 2021-08-07 19:40:07 -07:00
Kenny
051d7a970e fix rotation and mirroring
now works with all vector shapes, even those with internal reference locations
that are negative. All shape locations are anchored to their 0,0 but they can
display pixels from negative coordinates if the shape's location on the screen
would have room for it.
2021-08-07 19:32:02 -07:00
Kenny
b5837b157d improve transpose and mirror
* add heuristic to avoid drawing area unnecessarily
* fix Polygon.points
* fix transpose
* fix mirror x and y

Known broken:
Polygon with negative Y coordinates does not work right.
2021-08-07 19:31:22 -07:00
Kenny
8c22993e28 fix linter 2021-08-02 20:38:37 -07:00
Kenny
8607cdd783 vectorio: add draw protocol
* Removes VectorShape from user python interactions
* Re-integrates vectorio with displayio behind draw protocol implementations
* Implements draw protocol with VectorShape
* Composes VectorShape behaviors into Rectangle, Circle and Polygon
* Fixes terrible pixel garbage being left behind
* Improves redraw performance (heuristically) by tracking dirty area separately from current area.

Known Issues:
It does not work with transposed views.
2021-08-02 20:19:54 -07:00
Kenny
1b67b91edd fix inverted logic 2021-07-31 16:59:44 -07:00
Kenny
0afd863224 vectorio: palettes don't color dirty rectangles
This is a breaking change with previous palette semantic with respect to python code that uses vectorio.
Displayio has breaking changes in cpy 7 for Group's removal of max_size parameter so this is as good a
time as any to break everything.

Currently:
To color vectorio shapes correctly you have to pass in a palette with length 2. Palette[0] must be set transparent and palette[1] must be the color you want.

New:
To color vectorio shapes correctly you pass in a palette with length >= 1. Palette[0] will be the color of the shape.

Also improves pixels per second when skipping areas that aren't covered by the shape.
2021-07-31 16:32:01 -07:00
Scott Shawcroft
76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
Dan Halbert
a13da2ad57
Merge pull request #4486 from kmatch98/displayio_area_expand
`displayio` and `vectorio`: move to displayio_area_union and away from _expand
2021-03-26 23:00:05 -04:00
Kevin Matocha
56362a9806 remove duplicated code, replace with displayio_area_canon 2021-03-25 11:31:07 -05:00
Kevin Matocha
9485805b6a move to displayio_area_union and away from _expand 2021-03-25 11:21:39 -05:00
Kevin Matocha
3785eb7779 correct rectangle size dimensions 2021-03-25 09:36:40 -05:00
microDev
a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Dan Halbert
d1184e7e94 Be cognizant of null transform for .transpose_xy 2021-03-04 14:40:50 -05:00
Kenny
4c2d0c3dc5 use top-left heuristic for vectorio.Polygon
this flips the bottom-right style to top-left which is at least
kind of normal.  A 2x2 square at (0,0) would be defined like
(0,0), (3,0), (3,3), (0,3)
Which seems kind of surprising but at least less bonkers than
that square being defined at (1,1), which is the current behavior.
2020-07-28 23:10:59 -07:00
Kenny
e977b427aa vectorio: fix VectorShape non-transposed pixel placement
Fixes https://github.com/adafruit/circuitpython/issues/3170

The absolute transform needs to be subtracted in all cases, not
only when the coordinate system is transposed.
2020-07-20 20:25:31 -07:00
Kenny
e2d252a6d5 pre-allocate list of known size 2020-07-20 10:12:29 -07:00
Kenny
efeae0d84f fix 3169: Polygon.points property
The getter for vectorio.Polygon#points was not updated with the data type change of the stored points list.

This moves the implementation to shared_module and updates the data type to reflect the actual state.
2020-07-19 12:27:35 -07:00
Diego Elio Pettenò
dd5d7c86d2 Fix up end of file and trailing whitespace.
This can be enforced by pre-commit, but correct it separately to make it easier to review.
2020-06-03 10:56:35 +01:00
warriorofwire
dde66cadde remove a duplication in polygon.c 2020-05-18 13:32:06 -07:00
warriorofwire
4bbb80e31a vectorio: speed up polygon
This change takes polygon from 126k pixels per second fill to 240k pps fill
  on a reference 5 point star 50x66px polygon, updating both location and shape
  at 10hz.  Tested on an m4 express feather.

As a curiosity, the flat-out fill rate of a shape whose get_pixel is `return 0;`
  fills just shy of 375k pixels per second.
2020-05-18 13:32:06 -07:00
warriorofwire
fd94c08cf4 add performance measurement to VectorShape 2020-05-12 11:49:15 -07:00
warriorofwire
6aa9709d98 make Circle return explicit 2020-05-12 11:47:19 -07:00
warriorofwire
32f85f7a44 vectorio: fix up Rectangle
* Fix drawing 1 pixel too large
* Need to pad dirty area to ensure removed shapes are fully removed
2020-05-10 16:21:07 -07:00
warriorofwire
58c8e00745 vectorio: clean up after group removal
VectorShape tells the Group to redraw whatever it left behind when it is removed now.
2020-05-10 15:36:23 -07:00
warriorofwire
6660311a96 vectorio: respect display transpose and mirror.
VectorShape now just uses the Group's and Display's absolute transforms.
2020-05-10 14:18:13 -07:00
warriorofwire
4086600b61 vectorio: switch per-shape transform to Display
Rather than maintain a transform per-shape, we'll just use whatever
  settings are on the Display.  Currently only transpose is done.
2020-05-09 22:15:51 -07:00
warriorofwire
206d0e598a Add vectorio: for drawing shapes
vectorio builds on m4 express feather

Concrete shapes are composed into a VectorShape which is put into a displayio Group for display.

VectorShape provides transpose and x/y positioning for shape implementations.

Included Shapes:

* Circle
  - A radius; Circle is positioned at its axis in the VectorShape.
  - You can freely modify the radius to grow and shrink the circle in-place.

* Polygon
  - An ordered list of points.
  - Beteween each successive point an edge is inferred.  A final edge closing the shape is inferred between the last
    point and the first point.
  - You can modify the points in a Polygon.  The points' coordinate system is relative to (0, 0) so if you'd like a
      top-center justified 10x20 rectangle you can do points [(-5, 0), (5, 0), (5, 20), (0, 20)] and your VectorShape
      x and y properties will position the rectangle relative to its top center point

* Rectangle
  A width and a height.
2020-05-09 15:38:22 -07:00