mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 17:24:44 -04:00
Added basic gradient generation
A new option in the "Image" menu, gradient generation.
This commit is contained in:
parent
826b4da177
commit
29e9579eb6
7 changed files with 172 additions and 4 deletions
|
@ -499,3 +499,24 @@ func adjust_hsv(img: Image, id : int, delta : float) -> void:
|
|||
img.set_pixel(i,j,c)
|
||||
|
||||
img.unlock()
|
||||
|
||||
|
||||
func generate_gradient(image : Image, colors : Array, steps := 2) -> void:
|
||||
if colors.size() < 2:
|
||||
return
|
||||
|
||||
var t = 1.0 / (steps - 1)
|
||||
for i in range(1, steps - 1):
|
||||
var color : Color
|
||||
color = colors[-1].linear_interpolate(colors[0], t * i)
|
||||
colors.insert(1, color)
|
||||
|
||||
image.lock()
|
||||
var size := image.get_size()
|
||||
var gradient_height = size.y / steps
|
||||
for i in steps:
|
||||
for xx in size.x:
|
||||
var start = i * gradient_height
|
||||
var end = (i + 1) * gradient_height
|
||||
for yy in range(start, end):
|
||||
image.set_pixel(xx, yy, colors[i])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue