shoes4 icon indicating copy to clipboard operation
shoes4 copied to clipboard

Image with a block

Open PragTob opened this issue 12 years ago • 7 comments

I took this TODO from the source code and now make it an issue:

Shoes 3 also has image width, height that takes a block with drawing instructions.

I don't have any example of this though and it doesn't seem to be in the manual?! Does anyone know this better?

edit: So this can basically be used to use the shoes drawing function, which you already know and love, and make their result into a single object instead of creating a gazillion of objects.

PragTob avatar Jun 24 '13 17:06 PragTob

I remember this old _why's post.

ashbb avatar Jun 24 '13 22:06 ashbb

Ah okay thanks @ashbb that looks reasonable then - you can just use normal shoes methods there and it then just represents them as one object instead of creating so many single objects, which _why especially imagined for making games.

e.g. we're talking something like this:

  zr = image do
    rect 0, 0, 20, 10
    rect 10, 10, 20, 10
  end

PragTob avatar Jul 01 '13 15:07 PragTob

Hey all,

I just came across this while working on Image#style and wonder what y'all think. Right now image just sets its block to be clickable. Do we want to change that back? I feel like Shape serves the purpose of grouping a bunch of drawn objects together and making them clickable (#779).

KCErb avatar Jul 30 '14 03:07 KCErb

If shoes 3 supported that on image we probably should roll back the clickable block. Not clear to me exactly the difference between image and shape in that usage... Is image with block just an alias to shape?

jasonrclark avatar Jul 31 '14 00:07 jasonrclark

Maybe. I don't know what it does on shoes3.

We /could/ keep both. As image only behaves that way without any additional arguments we can do some argument switching so I think it's alright to keep click. It is a bit confusing though.

PragTob avatar Jul 31 '14 11:07 PragTob

So you can try this on 4 and 3: (except on 4 shape doesn't take rect right now so you can throw the shape part away on 4)

Shoes.app do
  image File.expand_path("../static/shoes-icon.png") do
    rect 0, 0, 20, 10
    rect 10, 10, 20, 10
  end
end

The result is that Shoes 4 and 3 do the same thing right now. If you give the image a file path and a block, then it draws the image, and only executes the block when clicked (draws the rects).

If you don't give it an image path, 4 doesn't know what to do (wrong number of arguments), but 3 just executes the block.

I think that should be easy enough to implement.

KCErb avatar Jul 31 '14 13:07 KCErb

That's kind of bizarre--if it's got a file + a block, the block is a click event; if no file path then just invokes the block immediately?

But definitely appears to be what's happening in Shoes3 with it, and Shoes 4 does indeed not like that number of arguments.

This is currently marked as 4.1... should it be pulled back to 4.0 as a compatibility item?

jasonrclark avatar Aug 08 '14 06:08 jasonrclark