mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 02:16:14 +02:00
♻️ Refactor adding gradient stops
This commit is contained in:
parent
5e9f533624
commit
7105e49ac2
3 changed files with 32 additions and 26 deletions
|
@ -92,14 +92,16 @@ impl Shape {
|
|||
self.fills.clear();
|
||||
}
|
||||
|
||||
pub fn add_gradient_stop(&mut self, color: skia::Color, offset: f32) -> Result<(), String> {
|
||||
pub fn add_gradient_stops(&mut self, buffer: Vec<RawStopData>) -> Result<(), String> {
|
||||
let fill = self.fills.last_mut().ok_or("Shape has no fills")?;
|
||||
let gradient = match fill {
|
||||
Fill::LinearGradient(g) => Ok(g),
|
||||
_ => Err("Active fill is not a gradient"),
|
||||
}?;
|
||||
|
||||
gradient.add_stop(color, offset);
|
||||
for stop in buffer.into_iter() {
|
||||
gradient.add_stop(stop.color(), stop.offset());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue