New answers tagged

3

Here's my preferred way to do this. First we'll make some template: Options[createPreviewNotebookTemplate] = { "Styles" -> { "Title", "Subtitle", "Chapter", "Section", "Subsection", "Subsubsection", "Text", "Code", "Input", "Output", "Item", "ItemNumbered", "ItemParagraph", "...


11

Preview Notebooks / Extra Paclet Features I decided it was worth it to add some extra features to this thing as it's a good example of what paclets can do for you. First off, I added a little CreateStylesheetPreview function that'll take stylesheets and rasterize them to make a preview. e.g.: CreateStylesheetPreview[ {"Default.nb", "ReverseColor.nb" -&...


13

1 + 4 We can discretize the rounded Polygon objects and then add the negative of the mesh through Prolog. rm = DiscretizeGraphics[roundedPolygon[#, 0.3] & /@ MeshPrimitives[mesh, 2]] Now there's some floating point differences in the results from roundedPolygon that seem to effect subsequent Boolean operations. We can fix this crudely merging nearby ...


8

fill the gaps between cells Graphics[{PointSize[1 / L2 / 3], Red, MeshPrimitives[mesh, {0, "Interior"}], {Directive[LightBlue, EdgeForm[Gray], EdgeThickness -> .001], roundedPolygon[#, 0.3]} & /@ MeshPrimitives[mesh, 2]}]


2

Your command works in Mathematica 12.0. If it does not work in an older version, you can try Plot[Labeled[x, Style["G", Bold], .3], {x, 0, 1}]


3

You could use ToBoundaryMesh to extract the points and edges like so: Needs["NDSolve`FEM`"] L1 = 6; L2 = 10; relaxed = Nest[PropertyValue[{VoronoiMesh[#, {{-1, L2 + 2}, {-1, L1 + 2}}], {2, All}}, MeshCellCentroid] &, {RandomReal[L2 + 2, (L1 + 2) (L2 + 2)], RandomReal[L1 + 2, (L1 + 2) (L2 + 2)]} // Transpose, 200]; mesh0 = ...


10

If you are not completely attached to Voronoi, you might consider tiling with hexagons and then perturbing their coordinates. GraphicsComplex makes it work. Define a hexagon. HexTile[s_] := Polygon[s*{{Sqrt[3], 1}/2, {0, 1}, {-Sqrt[3], 1}/2, {-Sqrt[3], -1}/2, {0, -1}, {Sqrt[3], -1}/2}] Allow for translation. TranslateObject[p_, {...


9

mesh = VoronoiMesh[pts]; hexagons = Select[Length[#[[1]]] == 6 &] @ MeshPrimitives[mesh, {2, "Interior"}]; DiscretizeGraphics @ Graphics @ hexagons SeedRandom[1] rt = 0.5; pts = Flatten[Table[{3/2 i + RandomReal[rt], Sqrt[3] j + Mod[i, 2] Sqrt[3]/2 + RandomReal[rt]}, {i, L + 2}, {j, L + 2}], 1]; mesh = VoronoiMesh[pts]; hexagons = Select[Length[#[...


16

Here is what I was suggesting in comments: SeedRandom[] relaxed = Nest[ PropertyValue[{VoronoiMesh[#, {{-1, 1}, {-1, 1}}], {2, All}}, MeshCellCentroid] &, RandomReal[{-1, 1}, {45, 2}], 500 ]; mesh = VoronoiMesh[relaxed, {{-1, 1}, {-1, 1}}, MeshCellStyle -> {1 -> White}]; Then extract the cell primitives corresponding to the interior ...


0

In the meantime, I believe I have found an answer. Might not be the best one, but I'm sharing it anyway. One thing we could do is to track the position of the specific section I want to delimit. One can do that using Position. In my case, I want to track Control 2. Thus, defining the Grid as grid and Control 2 as ctr2, the following code does what I want ...


5

Update: Remove the automatic content padding from Setters in TogglerBar to eliminate changes in item sizes: noPadding = Style[#, DefaultOptions -> {Setter -> { ContentPadding -> 0}}] &; Manipulate[c, Dynamic @ Grid[{ {"Checkbox 1", Control[{{a, 0, ""}, {1, 0}}], If[a == 1, noPadding @ Control[{{c, {0}, ""}, {1 -> "Edit", ...


2

I found that on my system (V11.3 running on MacOS 10.13.4) setting the mesh style with MeshCellStyle -> (RGBColor[.1, .1, .1, #] &) /@ list results in a light blue wash, which is applied to all regions by default, tainting the grays produced for those cells where the opacity is low. This can corrected giving VoronoiMesh the option BaseStyle -> ...


Top 50 recent answers are included