Simon Hausmann
bf84bb2ab6
Make floating point operations compile with no_std
...
Use num_traits and libm instead, also for euclid.
2021-11-30 15:33:50 +01:00
Olivier Goffart
844c5cf7ec
Gate the Path item behind the 'std' feature
2021-11-25 16:53:07 +01:00
Olivier Goffart
80c0602277
WIP: start making the corelib crate a no_std crate
...
Does not compile yet with no_std because of the lack of
alternative for thread_local
2021-11-25 12:02:16 +01:00
Olivier Goffart
d1cae710df
preprocess the images at compile time
...
For the MCU port, we need to proccess the image to save them in the binary
in a convenient format.
This patch start this work by trying to anaylyze what format should an image
be using, and saving it as a texture in the binary.
The current graphical backend and the C++ frontend are not yet supported
2021-11-19 15:54:45 +01:00
Simon Hausmann
fc491b167f
Add a doctest for sixtyfps::Image::path()
2021-09-28 08:52:27 +02:00
Simon Hausmann
4eef8c7688
Add API to sixtyfps::Image in Rust and C++ to access the optional path
2021-09-28 08:52:27 +02:00
Olivier Goffart
76ca2eed6b
Fix intra-doc links
...
It should be ``[`...`]``, not `` `[...]` ``
2021-08-19 09:17:30 +02:00
Simon Hausmann
e23dcc336f
Fix doc build
...
Amends commit 0852a7661b
2021-08-10 16:53:37 +02:00
Simon Hausmann
0852a7661b
Fix mutable slice API
...
* Change SharedVector::as_mut_slice() to SharedVector::make_mut_slice()
* SharedPixelBuffer::as_mut_slice and SharedPixelBuffer::make_mut_slice()
* SharedPixelBuffer::as_bytes_mut() to SharedPixelBuffer::make_mut_bytes()
This is consistent with Rc::make_mut() and is supposed to emphasize
that, unlike the usual as_* operations, it is not a free operation but
may involve work (detaching the data by cloning it).
Amends commit 7384ebdc32
2021-08-10 16:37:34 +02:00
Simon Hausmann
1fca971fa8
Rename RGB(A)8Pixel to Rgb(a)8Pixel
...
That's consistent casing with RgbaColor.
2021-08-10 15:56:01 +02:00
Simon Hausmann
4e9b2725a7
doc fix: Remove mention of SharedVector in SharedPixelBuffer
...
It's an implementation detail
2021-08-10 15:56:01 +02:00
Simon Hausmann
a0f06e35d7
Fix rustdoc link
...
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-08-10 15:56:01 +02:00
Simon Hausmann
0d3c38899f
minor doc fix: capitalize Rust
2021-08-10 15:56:01 +02:00
Simon Hausmann
d023475f1c
Rename Image::new_rgb*()
to Image::from_rgb*
2021-08-10 15:56:01 +02:00
Simon Hausmann
76041684c0
Simplify scenario description in Image docs
...
It doesn't have to be an external crate that renders images, just Rust code generally.
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-08-10 15:56:01 +02:00
Simon Hausmann
2a420d7a86
Remove imgref dependency from the public Image API
...
There's only one place where we need this ourselves and that's also
easily done by hand. Otherwise the `as_bytes(_mut)()` accessor provides the
functionality along with `width()` and `height()`.
Other than that the API is mostly consuming, given that `sixtyfps::Image`
has no way of extracting the data again.
2021-08-10 15:56:01 +02:00
Simon Hausmann
cfb6caca01
Fix calling Image::size()
on default or pixel-buffer constructed images
...
For such images we do not need a backend and can avoid the panic.
2021-08-10 15:56:01 +02:00
Simon Hausmann
6016007c6f
Avoid the need for SharedPixelBuffer
users to depend on rgb
...
Re-export the two typical pixel types, for convenience. Of course other
types can be used, too, if the user depends on rgb directly.
2021-08-10 15:56:01 +02:00
Simon Hausmann
c18b289e62
Provide convenience as_bytes(_mut)
for SharedPixelBuffer
...
This avoids the need for users of the API to import the ComponentBytes trait from rgb.
2021-08-10 15:56:01 +02:00
Simon Hausmann
8b62564a4b
Fix incorrect self parameter in SharedPixelBuffer
...
We don't need a mutable reference for `as_slice()`
2021-08-10 15:56:01 +02:00
Simon Hausmann
f25f85844d
Remove SharedImageBuffer from the public Rust API
...
and instead fold the constructor functions into Image as `new_rgb8`/`new_rgba8` and `new_rgba8_premultiplied`.
2021-08-10 15:56:01 +02:00
Simon Hausmann
12916e7488
Fix C++ build after Image API changes
...
Export missing types
2021-08-10 15:56:01 +02:00
Simon Hausmann
2e9e818691
Mark SharedPixelBuffer as repr(C)
...
For use in the ffi later
2021-08-10 15:56:01 +02:00
Simon Hausmann
8a3a68a4fa
Add API to Rust sixtyfps::Image to enable creation from user supplied image buffers
...
This adds an ImageBuffer and PixelBuffer type for SharedVector
backed images. The documentation explains how to use this
with low-level rendering functions and the popular image crate.
Fixes #387
2021-08-10 15:56:01 +02:00
Simon Hausmann
7384ebdc32
Deprecated SharedVector::as_slice_mut() in favor of SharedVector::as_mut_slice()
...
The standard library uses the latter name.
2021-08-09 14:51:09 +02:00
Olivier Goffart
1dab4c35d9
For embedded data, store the extension in the binary
...
This is usefull for the detection of SVG
2021-08-03 16:15:31 +02:00
Tobias Hunger
3e0534afea
Janitor: Fix clippy::needless_lifetimes
2021-07-23 13:48:52 +02:00
Tobias Hunger
ad98137c17
Janitor: Mark up float comparisons where we want bitwise identity
...
Mark up test cases where we want bitwise identity of float values and
use `assert_eq!` since that produces better output in the error case.
2021-07-09 17:00:46 +02:00
Tobias Hunger
2fdfbae33e
Janitor: Remove unnecessary lifetimes
2021-07-08 20:43:38 +02:00
Tobias Hunger
35dd3ed282
Janitor: Remove redundant clone() calls
2021-07-08 20:43:38 +02:00
Tobias Hunger
e5bdeaa804
Janitor: Remove unnecessary &
2021-07-07 08:42:28 +02:00
Tobias Hunger
23708a4a12
Janitor: Disable clippy error about f32 comparison
2021-07-06 22:54:05 +02:00
Tobias Hunger
0aea249f1a
Janitor: Fix spelling in docs and rename local variables
2021-07-03 18:22:01 +02:00
Olivier Goffart
13bd828b96
Update license date
2021-07-02 15:55:54 +02:00
Tobias Hunger
13d7f5e7bd
Janitor: Fix typos in comments and user-facing strings
...
Also adapt tests for error messages containing the fixed strings.
No behavior change is intended!
2021-06-28 08:32:25 +02:00
Simon Hausmann
85474f7670
Add support for sixtyfps::Image::size() in C++
...
Also added a unit test for the C++ implementation.
2021-06-20 11:18:28 +02:00
Simon Hausmann
0fdb87cc69
Add Image::size()
...
This requires the image size query to be window independent and go
through the backend instead.
This implies minor changes for the Qt backend and bigger ones for the GL
backend:
* There exists now a thread-local IMAGE_CACHE, which is used by the
backend's image_size() function as well as by the renderer for
loading CPU side images.
* The image remain as decoded images in there (including SVG tree)
and the window now has a texture_cache, which holds CachedImage
with ImageData::Texture.
* Rendering an image item therefore fetches the CPU side image,
calls upload_to_gpu() on it, which creates a new Rc<CachedImage>
and that's stored in the texture_cache.
* The texture cache continues to be pruned when hiding the window.
2021-06-20 11:18:28 +02:00
Olivier Goffart
142a8dc185
Rename ImageReference to ImageInner and make Immage.0 private
2021-05-28 17:05:16 +02:00
Olivier Goffart
8e44ac2351
Image type: some more docs
2021-05-28 17:05:16 +02:00
Olivier Goffart
0b3fecf300
WIP: API to expose image loading from C++ and Rust
2021-05-28 17:05:16 +02:00
Simon Hausmann
e7bc91c804
Add support for specifying the viewbox of path elements
2021-05-21 19:51:00 +02:00
Simon Hausmann
9a4dc4a8dc
Clean up femtovg crate dependencies
...
Let only the GL backend depend on femtovg, by moving the color functions.
This way it's easier to change the femtovg version in one place.
2021-05-20 08:56:11 +02:00
Olivier Goffart
f3da9532d7
Remove left over debug output
2021-04-12 13:05:00 +02:00
Olivier Goffart
af8be46019
Interpolation between gradients for the animations
2021-04-12 12:33:15 +02:00
Olivier Goffart
fb4f955302
Fix angle within gradients
...
line_for_angle takes a value in degrees, but the sin and cos are expected to be in radians
2021-04-07 18:31:13 +02:00
Simon Hausmann
477729da52
Improve brush property test coverage
...
Test that assigning colors works:
* Test the implicit `Brush(const Color &)` C++ constructor
* Add derive_more::From to allow convenient conversion in Rust
* When assigning to brush properties in JavaScript, try at least to see if it's a color string (could be extended in the future)
2021-04-01 08:27:10 +02:00
Olivier Goffart
41c6c79bc1
Better name for the femtovg feature
...
Just use the name of the crate, i believe this is the convension
2021-03-19 09:48:19 +01:00
Olivier Goffart
35cce45cbc
Add a fii feature so that we don't compile in the ffi code if not required
2021-03-16 18:09:57 +01:00
Olivier Goffart
89bbdce88e
Polish a bit the Brush API
2021-03-10 16:54:33 +01:00
Simon Hausmann
f087cc18bc
Remove extern "C" functions from wasm module
...
We don't need these functions and their export. They account for ~20kb in
the optimized .wasm - plus JS glue code.
2021-02-26 17:04:49 +01:00