Message Boards Message Boards

0
|
4156 Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Set Opacity?

Posted 7 years ago

Hello everyone,

I would like to ask if you do not know how to set the transparency for the set of graphics objects? I know that uses the “Opacity” but the problem is with the intersection of objects that is darker. I would like to merge graphics objects and set uniform opacity (no darker color for objects intersection). I have basic example:

Graphics[{Red,Text[Style["Text",160]],Black,Opacity[0.5],Disk[],Disk[{0.5,0}]}] 

My real task contains monochrome graphics object and directives like: Line, Thickness, Disk, Text, JoinForm, CapForm

Thanks

POSTED BY: Mirek M
9 Replies
Posted 7 years ago

Thanks!

StadiumShape is good substitution.

/.Line[a_List]:>StadiumShape[a,0.05] 
POSTED BY: Mirek M
Posted 7 years ago

Thanks, but what you describe about documentation is probably not result for my task.

If I add line to my graphics like this:

Graphics[{Red, Text[Style["Text", 160]], Black, Opacity[0.5], Disk[], 
  Disk[{0.5, 0}], Thickness[0.05], Line[{{0, 0}, {3, 1}}]}]

I tried modify code:

joineddisks = 
 MeshPrimitives[
  BoundaryDiscretizeGraphics[{Disk[], Disk[{0.5, 0}], Thickness[0.05],
     Line[{{0, 0}, {3, 1}}]}, MaxCellMeasure -> 0.002], 
  2]; Graphics[{Red, Text[Style["Text", 160]], Black, Opacity[0.5], 
  joineddisks}]

OR

joineddisks = 
 MeshPrimitives[
  BoundaryDiscretizeGraphics[{Disk[], Disk[{0.5, 0}], Thickness[0.05],
     Line[{{0, 0}, {3, 1}}]}, MaxCellMeasure -> 0.002], 
  1]; Graphics[{Red, Text[Style["Text", 160]], Black, Opacity[0.5], 
  joineddisks}]

Result is incorrect - Line with specific thickness is missing. I mean that Line is not transformed to edge form.

POSTED BY: Mirek M

Use StadiumShape such that it is a 2D object, not a 1D object. Again, it is not really supported at the moment, so you have to do some tricks to get the same effect.

Other method would be to Rasterize graphics objects first, then use SetAlphaChannel, then use Inset or Texture to put it back.

POSTED BY: Sander Huisman
Posted 7 years ago

Solution is very good. Problem is with Line with defined Thickness. If I add line then this line is not converted to mesh.

Thanks Mirek

POSTED BY: Mirek M

Second argument of MeshPrimitives is in the above example '2' meaning it will get surfaces (like disks). You can also do '1' in order to get lines... Look at the documentation!!

POSTED BY: Sander Huisman
Posted 7 years ago

I would like to thank Sander Huisman for his response and answer.

POSTED BY: Mirek M

Adam Sandler?

POSTED BY: Sander Huisman
Posted 7 years ago

Very sorry for the garbled names. I corrected it.

POSTED BY: Mirek M

I'm quite sure this is currently not easily possible.

Style[{disk1, disk2},Opacity[0.5]]

does not give the intended result. Also GraphicsGroup does not give the right result. You could do it like this:

joineddisks=MeshPrimitives[BoundaryDiscretizeGraphics[{Disk[],Disk[{0.5,0}]},MaxCellMeasure->0.002],2];
Graphics[{Red,Text[Style["Text",160]],Black,Opacity[0.5],joineddisks}]

giving:

enter image description here

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract