Grid of buttons over image with inset?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I'm in-setting a grid of buttons over an image, and I think it's probably a very simple thing that I'm missing. In the example below Scaled
doesn't work to stretch the Button
's properly:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Automatic], Scaled[0, 1], Scaled[0, 1],
Scaled[1, 1/2]],
Inset[Button["test", Print[1], Background -> RGBColor[0, 1, 0.3],
ImageSize -> Automatic], Scaled[0, 1/2], Scaled[0, 1/2],
Scaled[1, 1/2]]
, PlotRange -> 0, 1, 0, 1]
It should look like this:
The above I made with this:
Overlay[ExampleData["TestImage", "Lena"],
TextGrid[Button["test", Print[1],
Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> 512, 256], Button["test", Print[2],
Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> 512, 256], Spacings -> 0, 0]]
Which would be a solution except that:
- I don't want to give explicit
ImageSize
s Overlay
kills the buttons
button
add a comment |Â
up vote
3
down vote
favorite
I'm in-setting a grid of buttons over an image, and I think it's probably a very simple thing that I'm missing. In the example below Scaled
doesn't work to stretch the Button
's properly:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Automatic], Scaled[0, 1], Scaled[0, 1],
Scaled[1, 1/2]],
Inset[Button["test", Print[1], Background -> RGBColor[0, 1, 0.3],
ImageSize -> Automatic], Scaled[0, 1/2], Scaled[0, 1/2],
Scaled[1, 1/2]]
, PlotRange -> 0, 1, 0, 1]
It should look like this:
The above I made with this:
Overlay[ExampleData["TestImage", "Lena"],
TextGrid[Button["test", Print[1],
Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> 512, 256], Button["test", Print[2],
Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> 512, 256], Spacings -> 0, 0]]
Which would be a solution except that:
- I don't want to give explicit
ImageSize
s Overlay
kills the buttons
button
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm in-setting a grid of buttons over an image, and I think it's probably a very simple thing that I'm missing. In the example below Scaled
doesn't work to stretch the Button
's properly:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Automatic], Scaled[0, 1], Scaled[0, 1],
Scaled[1, 1/2]],
Inset[Button["test", Print[1], Background -> RGBColor[0, 1, 0.3],
ImageSize -> Automatic], Scaled[0, 1/2], Scaled[0, 1/2],
Scaled[1, 1/2]]
, PlotRange -> 0, 1, 0, 1]
It should look like this:
The above I made with this:
Overlay[ExampleData["TestImage", "Lena"],
TextGrid[Button["test", Print[1],
Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> 512, 256], Button["test", Print[2],
Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> 512, 256], Spacings -> 0, 0]]
Which would be a solution except that:
- I don't want to give explicit
ImageSize
s Overlay
kills the buttons
button
I'm in-setting a grid of buttons over an image, and I think it's probably a very simple thing that I'm missing. In the example below Scaled
doesn't work to stretch the Button
's properly:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Automatic], Scaled[0, 1], Scaled[0, 1],
Scaled[1, 1/2]],
Inset[Button["test", Print[1], Background -> RGBColor[0, 1, 0.3],
ImageSize -> Automatic], Scaled[0, 1/2], Scaled[0, 1/2],
Scaled[1, 1/2]]
, PlotRange -> 0, 1, 0, 1]
It should look like this:
The above I made with this:
Overlay[ExampleData["TestImage", "Lena"],
TextGrid[Button["test", Print[1],
Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> 512, 256], Button["test", Print[2],
Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> 512, 256], Spacings -> 0, 0]]
Which would be a solution except that:
- I don't want to give explicit
ImageSize
s Overlay
kills the buttons
button
button
asked 2 hours ago
M.R.
15.3k552180
15.3k552180
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can use the second and third arguments of Overlay
:
image = ExampleData["TestImage", "Lena"];
Overlay[image,
TextGrid[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Spacings -> 0, 0], All, 2]
Alternatively, use ImageSize -> Scaled[1], Scaled[1/2]
with Button
and use Scaled[1]
as the size argument in Inset
:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1], Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1/2], Scaled[0, 1], Scaled[1]],
PlotRange -> 0, 1, 0, 1]
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can use the second and third arguments of Overlay
:
image = ExampleData["TestImage", "Lena"];
Overlay[image,
TextGrid[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Spacings -> 0, 0], All, 2]
Alternatively, use ImageSize -> Scaled[1], Scaled[1/2]
with Button
and use Scaled[1]
as the size argument in Inset
:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1], Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1/2], Scaled[0, 1], Scaled[1]],
PlotRange -> 0, 1, 0, 1]
add a comment |Â
up vote
3
down vote
accepted
You can use the second and third arguments of Overlay
:
image = ExampleData["TestImage", "Lena"];
Overlay[image,
TextGrid[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Spacings -> 0, 0], All, 2]
Alternatively, use ImageSize -> Scaled[1], Scaled[1/2]
with Button
and use Scaled[1]
as the size argument in Inset
:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1], Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1/2], Scaled[0, 1], Scaled[1]],
PlotRange -> 0, 1, 0, 1]
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can use the second and third arguments of Overlay
:
image = ExampleData["TestImage", "Lena"];
Overlay[image,
TextGrid[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Spacings -> 0, 0], All, 2]
Alternatively, use ImageSize -> Scaled[1], Scaled[1/2]
with Button
and use Scaled[1]
as the size argument in Inset
:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1], Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1/2], Scaled[0, 1], Scaled[1]],
PlotRange -> 0, 1, 0, 1]
You can use the second and third arguments of Overlay
:
image = ExampleData["TestImage", "Lena"];
Overlay[image,
TextGrid[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> ImageDimensions[image]/1, 2],
Spacings -> 0, 0], All, 2]
Alternatively, use ImageSize -> Scaled[1], Scaled[1/2]
with Button
and use Scaled[1]
as the size argument in Inset
:
Graphics[Inset[ExampleData["TestImage", "Lena"], Scaled[0, 1],
Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[1], Background -> RGBColor[1, 0, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1], Scaled[0, 1], Scaled[1]],
Inset[Button["test", Print[2], Background -> RGBColor[0, 1, 0, 0.3],
ImageSize -> Scaled[1], Scaled[1/2]],
Scaled[0, 1/2], Scaled[0, 1], Scaled[1]],
PlotRange -> 0, 1, 0, 1]
edited 2 hours ago
answered 2 hours ago
kglr
169k8193396
169k8193396
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185404%2fgrid-of-buttons-over-image-with-inset%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password