Message Boards Message Boards

2
|
4567 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Question about flattening images

2 Replies

The best solution I've come up with so far is to use Blend. Basically, I make a list where each entry in the table is a Graphics object with one missing 9-gon and a transparent background, apply Blend to the whole list, and then ImageCompose with a blank image with the background color I want (of course, I first just had a list with only one 9-gon in each entry, but this gets way too washed out when you apply Blend).

Here's the code:

 n = 9;
 m = 20;
 cols = Insert[#, First[#], 4] &[
   RGBColor /@ {"#E45171", "#F8A79B", "#F8D99B", "#002C6A"}];
 imglist = 
  Table[Graphics[
    Table[{FaceForm[
       Directive[Blend[cols[[;; 4]], Mod[\[Theta]/(2 \[Pi]), 1]], 
        Opacity[.3]]], 
      EdgeForm[
       Directive[Blend[cols[[;; 4]], Mod[\[Theta]/(2 \[Pi]), 1]], 
        Thickness[.004]]], 
      Polygon[Table[{Cos[\[Theta]] + Cos[\[Phi] + \[Theta]], 
         Sin[\[Theta]] + Sin[\[Phi] + \[Theta]]}, {\[Phi], 0, 
         2 \[Pi] - 2 \[Pi]/n, 2 \[Pi]/n}]]}, {\[Theta], 2 \[Pi] i/m, 
      2 \[Pi] (m + i - 2)/m, 2 \[Pi]/m}], PlotRange -> 3, 
    ImageSize -> 540, Background -> None], {i, 1, m}];
 ImageCompose[Graphics[Background -> cols[[5]], ImageSize -> 540], 
  Blend[imglist]]

And the resulting image:

Semitransparent 9-gons on a blue background

This seems like an annoyingly heavy-handed way of accomplishing this, so I'd still be very happy to hear about better solutions.

Posted 9 years ago
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