Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 3056

Questions on the construction of 2D and 3D graphics through the direct use of primitives, directives, and functions. Include the graphics3d tag for questions specifically on 3D graphics. This tag is not to be used for basic questions on visualizing functions and lists using the various flavors of Plot commands.

6 votes

How to get rid of the blank areas around alphabetical images?

Use ImageCrop. It does exactly what you want, at least in this case... except in the case where "empty" space exists only on one side of the image, which it refuses to crop. To work around that, you c …
kirma's user avatar
  • 19.1k
14 votes

How to draw all paths from (1,1) to (n,n) by move (+1, 0) or (0, +1)?

A solution just to show Solve can also be used directly on basis of the problem specification: With[{max = 4}, With[{coords = Table[{x[n], y[n]}, {n, 2 max - 1}]}, coords /. Solve[ (* th …
kirma's user avatar
  • 19.1k
1 vote

Pattern rotation in graphene

Element] reg, u, v}]; VoronoiMesh[ Join[centers[Rectangle[{-3, -3}, {5 + 2/3, 14}], -\[Pi]/24], centers[Rectangle[{5 + 1/3, -3}, {14, 14}]]], {{0, 11}, {0, 11}}] // MeshPrimitives[#, 1] & // Graphics
kirma's user avatar
  • 19.1k
6 votes

How to quickly find all grid cells covered by a geometric region?

It is already quite much faster than either, at least for polygons: With[{reg = Polygon@RandomReal[{0, 10}, {3, 2}]}, Graphics[{reg, Blue, Opacity[1/2], Rectangle /@ Select[Flatten[CoordinateBoundsArray …
kirma's user avatar
  • 19.1k
2 votes

Troubleshooting Set Delayed Error

This is a rewrite of the code in a style more natural to Mathematica: Manipulate[ Graphics[ {Opacity[.2], MapThread[Translate, {{{Yellow, Disk[{0, 0}, 10, {0, 2 Pi/3}]}, {Orange, Disk[ … 3]@RotationTransform[x][{10, 0}], {i, 0, 2}]}]}, PlotRange -> All, Axes -> True], {x, 0, 2 Pi}] This could be further simplified to a MapThread over colors and sector angles: Manipulate[ Graphics
kirma's user avatar
  • 19.1k
6 votes
2 answers
584 views

How to fill outside instead of inside graphical shapes?

I want to omit parts of Graphics from scenes by defining a geometric shape where details are visible, a "keyhole" of sorts, and fill all the rest as one would do to insides of the regular graphics primitives … Polygon[pts_] :> {Line[pts]}]}], Sequence @@ opts]] showWithHole[ Graphics[{Blue, Disk[{1, 0}, 3/2]}], Directive[Opacity[1/2], White], Red, Graphics[{Disk[{0, 0}, 1], FilledCurve[{{Line@CirclePoints …
kirma's user avatar
  • 19.1k
4 votes
Accepted

How to fill outside instead of inside graphical shapes?

Polygon[pts_] :> {Line[pts]}, {Line[ Tuples[scaledbounds][[{1, 2, 4, 3}]]]}]]}], Sequence @@ opts]] showWithHole[ Graphics[{Red, Disk[{1, 0}, 3/2]}], Directive[Opacity[9/10], White], Black … , Graphics[{Disk[{0, 0}, 1], FilledCurve[{{Line@CirclePoints[{2, 1}, 1/2, 6]}, {Line@CirclePoints[{2, 1}, 1/4, 6]}}]}], MaxCellMeasure -> 0.001] …
kirma's user avatar
  • 19.1k
3 votes

How to fit the curve that this lines made? The length of lines are all fixed

Based on your image, but not your statement on lengths of lines: With[{eqn = a - a x / (1 - a)}, Show[ Quiet@Plot[Table[eqn, {a, 0, 1, 1 / 20}], {x, 0, 1}, Evaluated -> True, AspectRatio -> Aut …
kirma's user avatar
  • 19.1k
18 votes
5 answers
892 views

How to quickly find all grid cells covered by a geometric region?

I have constructed a method that produces correct results: With[{reg = Polygon@RandomReal[{0, 10}, {3, 2}]}, Graphics[{reg, Blue, Opacity[1/2], Rectangle[{x, y}] /. …
kirma's user avatar
  • 19.1k
5 votes
Accepted

How to check if points lie within a circle

points per circle: With[{pts = RandomReal[{-10, 10}, {10000, 2}], disks = Table[Disk[RandomReal[{-5, 5}, 2], RandomReal[{1, 2}]], {3}]}, Show[ListPlot[(Select@RegionMember@#)[pts] & /@ disks], Graphics
kirma's user avatar
  • 19.1k
2 votes

How to quickly find all grid cells covered by a geometric region?

A method based on RegionDilation introduced in v12.3: With[{reg = Polygon@RandomReal[{0, 10}, {3, 2}]}, Graphics[{reg, Blue, Opacity[1/2], Rectangle /@ Select[Flatten[CoordinateBoundsArray@Floor@RegionBounds … This is about ten times slower for triangles than the method above, but still faster than the original: With[{reg = Polygon@RandomReal[{0, 10}, {3, 2}]}, Graphics[{reg, Blue, Opacity[1/2], Rectangle …
kirma's user avatar
  • 19.1k
10 votes
Accepted

How to efficiently make this color wheel?

Consider, for instance: RegionPlot[ Element[{x, y}, Annulus[{0, 0}, {0.8, 1}]], {x, -1, 1}, {y, -1, 1}, Frame -> False, BoundaryStyle -> None, ColorFunctionScaling -> False, ColorFunction -> (Hue …
kirma's user avatar
  • 19.1k
4 votes

Filling between a curve and a Line

Your Line has a constant $y$ value... so I picked a bit more adventurous example: With[{line = Interpolation[ {{-Pi, Cos[-Pi]}, {Pi/4, Cos[Pi/4]}}, InterpolationOrder -> 1]}, Plot[{Cos[x …
kirma's user avatar
  • 19.1k
5 votes
Accepted

How to draw a truncated hexagonal tiling?

derive the tiling from some more abstract definition or just to reproduce it, but reproducing it is not particularly hard: With[ {gridbasis = a {1, 0} + b RotationTransform[60 Degree][{1, 0}]}, Graphics … tiling. *) countregion = Rectangle[{-5/2, -5/2}, {5/2, 5/2}]; (* Visualise 12-gons (polys) which are inside in countregion. *) Cases[polys, poly_RegularPolygon /; RegionWithin[countregion, poly]] // Graphics
kirma's user avatar
  • 19.1k
18 votes

Find intersection of pairs of straight lines

.}}; (* Convert coordinate-lists to two collections of lines which can be used as primitives in both in graphics and new geometric computation. *) {lines1, lines2} = Line[Partition[#, 2]]& /@ {p1, … Solve[{x, y} \[Element] lines1 && {x, y} \[Element] lines2, {x, y}]; (* Represent all these as Graphics. *) Graphics[{Blue, lines1, Red, lines2, Black, PointSize …
kirma's user avatar
  • 19.1k

15 30 50 per page