Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
petteramland committed Jul 15, 2024
1 parent 032bf92 commit 3452580
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions otosopp/otosopp.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@
rotate_brush = True
using_painterly_brush = True
prev_brush_tip = -1
set_brush(poke_brush)
set_brush(painterly_brush)
# set_brush(round_brush)
# set_brush_size([64,64])
IMG = new Image()
current_color = [32, 32, 32, 255]
current_color = [32, 128, 128, 255]
# print('----------------', random_int(0,360)/60)
current_color = hsv(random_int(0,360), 1, 1, 1)
drawing = False
smoothing = False
prev_pos = None
Expand Down Expand Up @@ -513,6 +515,7 @@
sampled_color[i] = lerp(canvas_entity.color[i], sampled_color[i], sampled_color[3]/255)

sampled_color[3] = 255

set_color(sampled_color)
return

Expand All @@ -529,6 +532,11 @@
combined_sample[i] = lerp(combined_sample[i], sampled_color[i], sampled_color[3]/255)

combined_sample[3] = 255

if current_brush == painterly_brush: # make the color a bit brighter when using painterly_brush since it paints a bit darker than the selected color
combined_sample[0] += 20
combined_sample[1] += 20
combined_sample[2] += 20
# alphas = [e[3] for e in sampled_colors]
# alpha = min(sum(alphas), 255)
# combined_color = [lerp(canvas_entity.color[i], combined_color[i], alpha/255) for i in range(3)]
Expand Down Expand Up @@ -733,6 +741,13 @@
const img_data = flip_image_data_vertically(layer.ctx.getImageData(0, 0, layer.canvas.width, layer.canvas.height))
layer.ctx.putImageData(img_data, 0, 0)

if held_keys['shift'] and key == 'r':
current_color_as_hsv = rgb_to_hsv(current_color)
# random_color = [random_int(0,360), current_color[1], current_color[2], current_color[3]] # this was a mistake, but creates only a small variation and could be useful to have
random_color = hsv(random_int(0,360), current_color_as_hsv[1], current_color_as_hsv[2], current_color_as_hsv[3])
set_color(random_color)



def flip_image_data_horizontally(img_data):
for (let y = 0; y < img_data.height; y++):
Expand Down

0 comments on commit 3452580

Please sign in to comment.