Open ccoupe opened 8 years ago
Are you talking about those ? https://github.com/Shoes3/shoes3/blob/master/shoes/ruby.c#L4766 getter and setter for a pixel in image (in Shoes, an_image[x,y]). In theory could be used if you want to tweak images at the pixel level in Shoes/Ruby, might work for creating your own image effect like blur etc ... but would be slow, harmless, i'd say ! One can grab a part of an image and do stuff on/with it, lots of possibilities ... I remember vaguely someone blogging about it, might be the Creator himself :-)
@passenger94 could also be useful as when someone wants their own colorpicker on an image or something.
Indeed ! Let's leave the door open ...
We need some kind of demo for the manual. I made a small colour picker for your entertainment but it seems a bug has been uncovered. The colour picked is not relative, i.e. if you hover over "Color picked" you will actually get the colour of the top of the image, as if it was positioned on top.
Please, also take note that img[left, top] and img.image[left, top] give the same results. They are synonymous.
Shoes.app do
flow do
@r = rect 0, 0, self.width - 1, 25
@p = para
end
img = image "#{DIR}/static/shoes-manual-apps.png"
motion do |left, top|
color = img.image[left, top]
info [left, top, color, img[left, top]]
@r.fill = color
@p.text = strong("Color picked: #{color}\n")
end
end
Interesting development on Image[]=. The code below uses direct access and can handle the 24 frames per second. However, if you use @img.image[x, y], it will freeze or only works at low animate FPS such as 5 or so.
Shoes.app(:width => 200, :height => 200) do
s = stack do
@img = image "#{DIR}/static/shoes-icon-red.png"
end
w, h = [@img.full_width, @img.full_height]
table = []
(0..w).each do |x|
(0..h).each do |y|
unless @img[x, y].nil?
r, g, b, a = [:red, :green, :blue, :alpha].collect { |n| @img[x, y].send(n) }
table << [x, y] if (r > 20 and 2 >= g and 2 >= b) # catch any red looking colors
end
end
end
animate(24) do |frame|
color = rgb(rand(0..255), rand(0..255), rand(0..255), rand(0..255))
table.each do |n|
@img[*n] = color
end
s.refresh_slot
end
end
They are image methods and the C functions are called by other functions in ruby.c at the C level but I can't find a Shoes/Ruby level use or description. I'm inclined to delete the Ruby.c method defs.