0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-28 17:56:50 -05:00

Merge pull request #5950 from penpot/alotor-fix-gradient-strokes

🐛 Fix problem with gradient in strokes
This commit is contained in:
Alejandro 2025-02-25 11:43:49 +01:00 committed by GitHub
commit 17e9e836f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 12 deletions

View file

@ -347,7 +347,7 @@
offset (:offset stop)]
[r g b a (* 100 offset)]))
stops)))))
(h/call internal-module "_add_shape_stroke_stops" stops-ptr n-stops))
(h/call internal-module "_add_shape_stroke_stops"))
(some? image)
(let [id (dm/get-prop image :id)

View file

@ -546,20 +546,22 @@ pub extern "C" fn add_shape_stroke_radial_fill(
}
#[no_mangle]
pub extern "C" fn add_shape_stroke_stops(ptr: *mut shapes::RawStopData, n_stops: u32) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
pub extern "C" fn add_shape_stroke_stops() {
let bytes = mem::bytes();
let entries: Vec<_> = bytes
.chunks(size_of::<shapes::RawStopData>())
.map(|data| shapes::RawStopData::from_bytes(data.try_into().unwrap()))
.collect();
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
if let Some(shape) = state.current_shape() {
let len = n_stops as usize;
unsafe {
let buffer = Vec::<shapes::RawStopData>::from_raw_parts(ptr, len, len);
shape
.add_stroke_gradient_stops(buffer)
.add_stroke_gradient_stops(entries)
.expect("could not add gradient stops");
}
mem::free_bytes();
}
}
}
// Extracts a string from the bytes slice until the next null byte (0) and returns the result as a `String`.