-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are Image[] and Image[]= undocumented? #285
Comments
Are you talking about those ? https://github.com/Shoes3/shoes3/blob/master/shoes/ruby.c#L4766 |
@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.
The text was updated successfully, but these errors were encountered: