0
$\begingroup$

I can't manage to display a BooleanRegion in the Wolfram Cloud Notebook:

floor = Block[{
  outer =Rectangle[{0, 0}, {2900, 6350}],
  x1 = Rectangle[{2900-445,0}, {2900, 740}],
  x2 = Rectangle[{2900-450, 6350-520}, {2900, 6350}]
}, BooleanRegion[Xor, {outer, x1, x2}] ];

Graphics[{FaceForm[Pink], floor//Region}, AspectRatio -> Automatic]

It seems to produce a blank graphic object: enter image description here

Do you think this is an issue with the Wolfram Cloud Notebook, or did I make some error in my code?

$\endgroup$
  • 1
    $\begingroup$ The region definition itself looks fine to me. However I am not sure the graphics can show a Region object. What does Region[floor] return? Does that display your region? $\endgroup$ – MarcoB Dec 18 '19 at 4:59
  • $\begingroup$ @MarcoB: Yes, Region[floor] does work. $\endgroup$ – user64494 Dec 18 '19 at 8:16
  • $\begingroup$ @Marco Carl gave the answer (as the current Mathematica version at least). That being said, it is somewhat counterintuitive to me than regions are displayed graphically in the Notebook and in Show--but aren't graphic primitive nevertheless. $\endgroup$ – Sylvain Leroux Dec 18 '19 at 10:57
3
$\begingroup$

A Region object is not a graphics primitive, and so it won't work inside of a Graphics object. On the other hand, starting in M12, a MeshRegion object is a graphics primitive, so you can use a discretized version of a region instead:

Graphics[{FaceForm[Pink],floor//DiscretizeRegion},AspectRatio->Automatic]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks, Carl. It works as expected, but isn't using DiscretizeRegion an overkill when working with such a simple region than given in my example? Maybe it would be better to completely avoid regions in such use cases, and work only with polygons. But that's probably another question... BTW MeshRegion does not appear in the list of Graphics primitives in the doc: reference.wolfram.com/language/ref/Graphics#1953776833, or did I miss something? $\endgroup$ – Sylvain Leroux Dec 18 '19 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.