I would like to create a little game where user would simply move some images around with their mouse to create some shapes.
I found about this possibility in the Nutts Puzzle Demo by Karl Scherer.
However looking into the source code I can`t figure out which part enable to manipulate the shapes with the mouse.
The very last control statement in the manipulate is
{{pts, {{2, 1.5}, ..., {16.1, 16.1}}}, Locator, Appearance -> None},
This makes an invisible Locator at the center of each polygon.
It is these that are picked up and moved by the mouse.
The preceding controls create the 2 popup menus and the 19 rotation sliders.
Edit: To address the comment, an example using Inset:
g[1]=ExampleData[{"TestImage","Girl"}];
g[2]=ExampleData[{"TestImage","Girl2"}];
g[3]=ExampleData[{"TestImage","Girl3"}];
Manipulate[Plot[Cos[x^n],{x,0,4Pi},
Epilog->Table[Inset[g[i],pos[[i]],{0,0},ImageScaled[{.2,.2}]],{i,3}]],
{{n, 1}, 0, 4},
{{pos,{{0,0},{Pi,0},{2Pi,0}}},Locator,Appearance->None}]
Bonus points: Name the "Girl"s in the "TestImage" example data...
For example, this
Manipulate[Graphics[Disk[p, .2], PlotRange \[Rule] {{0, 10}, {0, 10}}],
{{p, {.2, 1.5}}, Locator, Appearance \[Rule] None}]
displays a circle; when you click somewhere, the circle jumps there. Does this answer the question?
Related
I have a radar/spider chart.
The input to this chart can be in the format as shown:
[23, 34, 54, [4, 3, 67], 45, 5]
When there is a single value, it is shown as a data point, but when it is an array of points, I want the data to be shown in a boxplot instead (as in the image shown below).
My question is which javascript library is suitable for this type of requirement? I tried using 'Highcharts', but I could not get the boxplot.
I think d3js would be a good choice. You could create two separate charts with one overlaying the other.
Box chart
https://beta.observablehq.com/#mbostock/d3-box-plot
Radar Spider chart
http://bl.ocks.org/nbremer/6506614
I'm programming a cocoa app which uses scripting bridge to interact with menus in a specific frontmost application, but I don't want the user to see all the gibberish that scripting bridge is doing.
So I want to freeze the image of all monitors during that phase and I'm trying to use
CGCaptureAllDisplaysWithOptions(kCGCaptureNoFill);
which supposedly do that until i call the
CGReleaseAllDisplays();
But it won't, all the screens turn black.
I have tried the solution here "CGDisplayCaptureWithOptions (kCGDirectMainDisplay, kCGCaptureNoFill) still fills the screen with black" to capture the screen one by one but stills they turn black.
Someone know why? Is there some workaround?
I also tried a more complex approach, taking screenshots of every screen before capture, using CGDisplayCreateImage. But another problem arouse when i try to draw them directly to the screen context. I got the context using CGDisplayGetDrawingContext and call the CGContextDrawImage to draw the images for each one of the screens.
With only one or mirrored screens works fine but with extended screens only works on my main screen, the other show a sub image of the screenshot.
For example:
Main Screen:
CGDisplayBounds returns {{0, 0}, {1280, 800}}
CGRect rect1 = {{0, 0}, {CGImageGetWidth(screenshot1), CGImageGetHeight(screenshot1)}};
CGContextDrawImage(context1, rect1, screenshot1); //<- works fine
Other Screen
CGDisplayBounds returns {{1280, 0}, {1920, 1080}}
CGRect rect2 = {{0, 0}, {CGImageGetWidth(screenshot2), CGImageGetHeight(screenshot2)}};
CGContextDrawImage(context2, rect2, screenshot2); //<-Shows a sub image of my screenshot with origin at (1280, 0) and frame {{1280, 0}, {1280 - 1920, 1080}}
Sub image that appears on the monitor:
http://i.stack.imgur.com/zoUWe.jpg
Original Screenshot:
http://i.stack.imgur.com/KHjN6.jpg
Any suggestions?
When including a 3D plot inside a TabView, in my computer, the entire tab is grayed as if it was a giant button, leaving the Graphics with a white background:
To avoid the contrast between the gray and the white, I would prefer that the tab also had a white color.
Tried BaseStyle -> {Background -> White} but with no success (only the borders get restyled).
How can I change the Background color of the tab?
The default background is not white but transparent for graphics, so there's no harsh contrast. Background -> White makes the background white and leaves the borders, quite the opposite of what you said. BaseStyle doesn't seem to do anything.
This is what I get on Windows XP:
EDIT: An alternative is a custom TabView-implementation along the following lines:
objects = Table[Plot[f[x], {x, 0, 10}], {f, {Sin, Cos, Exp}}];
Column[
{SetterBar[Dynamic[x], Thread[objects -> Range#Length[objects]]],
Dynamic[x]}
]
This is unfinished, but the basics work, and it shows you how to do it yourself.
This seems to be an OS specific problem. On OS X, TabView does have a grey background (albeit very light), even with Background->White. For example
TabView[Table[Plot[Sin[i x], {x, 0, 2 Pi}, Background -> White], {i, 4}],
Background->White]
produces this
I can confirm Heike's assertion for Windows 7.
If you wish to always overwrite the system theme color for TabView boxes, you may evaluate:
SetOptions[$FrontEnd,
TabViewBoxOptions -> {Background -> GrayLevel[1]}
]
Using either the "Windows 7 Basic" or "Windows 7 Aero" theme, I see this:
However, using the "Windows Classic" theme I see this:
If, using the Classic theme, I open Window Color and Appearance and change the 3D Objects Color 1 to white, I see:
When right clicking an Image in the front end, there's the option to display at its actual size (i.e. 1:1 screen to image pixel size).
How can images be forced to be shown like this? When making a Row or Column of Images, how can they be made to display at their actual size?
I was comparing image resampling methods to see which one gives the best result for a sharp edges when this came up. As a workaround I ImageAssembled all the images, so I had to right-click only once to get them to display at actual size.
Here is another method that works on version 7 at least.
img = ExampleData[{"TestImage", "Lena"}];
Row[{ Image[img, Magnification -> 1], Image[img, Magnification -> 1] }]
I only became aware of this context menu item a couple of months ago. It was probably added somewhere in v8.
I noticed Image-like output gets this item in their context menu, but bitmaps from Rasterize don't. You may try Rasterize[Plot[Sin[x], {x, -\[Pi], \[Pi]}], RasterSize -> 500] to test that. Put // Image behind it and you get a different context menu for the result.
I believe the presence of ImageSize in the containing Cell determine the scaling of images (of the second kind). No ImageSize means automatic scaling and ImageSize->Magnification[1] means actual size. So, you would need to manipulate the cell itself to change the behaviour.
Please try:
Show[image, ImageSize -> All]
Likewise:
Row[{ Show[img1, ImageSize -> All], Show[img1, ImageSize -> All] }]
I made 3D graphics, and using the known method of zooming, which is to hold the Ctrl and now slide the mouse up and down to zoom in and out as described here
http://reference.wolfram.com/mathematica/howto/RotateZoomAndPanGraphics.html
This works ok.
But now I issue the command Rotate[g,90 Degree], and try to zoom on the generate plot (in the new output cell). But the zoom no longer works on that new rotated image.
I see it blinking black each time I slide the mouse, but it does not zoom in nor out.
Here is the command
g=Graphics3D[ Cuboid[{-.1,-.1,-.1},{.1,.1,.1}],
AxesOrigin->{0,0,0},
PlotRange->{{-1,1},{-1,1},{-1,1}},
Axes->True,
AxesLabel->{"X","Y","Z"},
ViewPoint->Front,
Ticks->None]
now zoom works ok. Now type
Rotate[g,90 Degree]
Now try zoom on the result of the above command. It does not work.
version 8.0.1, windows 7
thanks
You are right, there is a bug in the interface.
After a few tries, pressing Ctrl and the mouse buttons, I was able to get a weird display:
And the zooming works (although inconsistently), but ... moving the mouse left to right!
I think this is either an abusive or unanticipated use of the Rotate command, depending on your perspective.
Rotate creates a RotationBox wrapper that instructs the FrontEnd (I believe) to rotate it's contents. When you apply this to an object with its own rotation controls, you have conflicting methods.
Generally speaking, Rotate should not be used on dynamic elements. Consider this modified example from the documentation:
DynamicModule[{p1 = {0, 0}, p2 = {1, 0}, p3 = {0, 1}},
{Framed#
Graphics[Polygon[{Dynamic[p1], Dynamic[p2], Dynamic[p3]}],
PlotRange -> 1],
Column[
{Slider2D[Dynamic[p1], {-1, 1}],
Slider2D[Dynamic[p2], {-1, 1}]~Rotate~(Pi/2),
Slider2D[Dynamic[p3], {-1, 1}]}]}]
Notice the strange behavior of the middle slider (try it), and also notice that its appearance is wrong. The latter is further indication that this use is noncanonical.