<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fun w/ODS Graphics: Chock Full O'Presents Xmas Tree in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318157#M11144</link>
    <description>&lt;P&gt;A &lt;A href="https://en.wikipedia.org/wiki/Q*bert" target="_self"&gt;Q*bert&lt;/A&gt; Christmas!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6331i25BE86CE5C774776/image-size/small?v=v2&amp;amp;px=-1" border="0" alt="from http://www.hardcoregaming101.net/" title="from http://www.hardcoregaming101.net/" /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Dec 2016 18:53:19 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2016-12-11T18:53:19Z</dc:date>
    <item>
      <title>Fun w/ODS Graphics: Chock Full O'Presents Xmas Tree</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318135#M11141</link>
      <description>&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6327i5F2CA7F59E068944/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="XMASTREE.png" title="XMASTREE.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Truth be told, the underlying concept here isn't all that different than &lt;A href="http://blogs.sas.com/content/iml/2011/12/16/a-sas-christmas-tree.html" target="_self"&gt;Rick Wicklin's 2011 throwback ASCII Xmas tree&lt;/A&gt;, but with shaded boxes ("presents") taking the place of ASCII characters in an effort to mimic some of the nice polygon Christmas tree art work floating about the web. Happy Holidays, all!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CODE&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Fun w/SAS ODS Graphics: Xmas tree made up of Xmas presents;

*==&amp;gt; Generate polygon vertices for a "Xmas present" (each face will be shaded differently); 

data XmasPresent;
angle=30*constant("PI")/180;                  * Add some perspective;
id=1;                                         * Right face;
x=0; y=1; output;
x=0; y=0; output;
x=cos(angle); y=sin(angle); output;
y+1; output;
id=2;                                         * Left face;
x=0; y=1; output;
x=0; y=0; output;
x=-cos(angle); y=sin(angle); output;
y+1; output;
id=3;                                         * Top face;
x=0; y=1; output;
x=-cos(angle); y=sin(angle)+1; output;
x=0; y=sin(angle)+1+sin(angle); output;
x=cos(angle); y=sin(angle)+1; output;
run;

data XmasPresent;                             * Add sequence # for plotting;
set XmasPresent;
seq+1;

*==&amp;gt; Generate points for presents that will make up the "Xmas tree"; 

data xmastree;                                
do row=12 to 3 by -1;                         * Tree is 10 rows (first row is 1 present, last is 10 presents); 
  yoffset=row*2*.875;                         * Adjust row height (87.5%) to tighten things up;
  do col=0 to 9;
    xoffset=^mod(row,2)+col*2+1;              * Offset each row's columns by 1;
    idoffset+3;
    rndcolor=put(ceil(7*ranuni(14)),1.);      * Assign one of 7 random colors to present; 
    if (row-3)&amp;lt;=xoffset&amp;lt;=(10.5+(12-row)) then
      output;                                 * Output only desired # points for row (1, 2, ..., 10);
  end;
end;
row=2;                                        * Generate "trunk" (2 rows of 3/2 presents);
yoffset=row*2*.875;
do col=3 to 5;
  xoffset=2+col*2;
  idoffset+3;
  rndcolor=put(ceil(7*rand("Uniform")),1.); 
  output;
end;
row=1;
yoffset=row*2*.875;
do col=4 to 5;
  xoffset=mod(row,2)+col*2;
  idoffset+3;
  rndcolor=put(ceil(7*rand("Uniform")),1.); 
  output;
end;
row=0;                                        * Generate "stand" (1 row of 5 presents);
yoffset=row*2*.875;
do col=2 to 6;
  xoffset=2+col*2;
  idoffset+3;
  rndcolor=put(ceil(7*rand("Uniform")),1.); 
  output;
end;

*==&amp;gt; Merge Xmas tree points with Xmas present polygon points; 

proc sql;
create table xmastreepresents as 
select x+xoffset as x, y+yoffset as y,                       /* Keep present faces separate for shading */
       case when id=1 then idoffset+id else . end as newid,  /* Right face */
       case when id=2 then idoffset+id else . end as newid2, /* Left face */
       case when id=3 then idoffset+id else . end as newid3, /* Top face */
       RndColor
from xmastree x, xmaspresent p order by idoffset+id, seq;

*==&amp;gt; Hard work's done, let's plot a Xmas tree! (transparency used to shade present faces); 

ods listing image_dpi=300 gpath='/folders/myfolders';
ods graphics on / reset antialias width=5in height=5in imagename="XMASTREE";

proc template;
define statgraph xmastemplate;
  begingraph;
    entryfootnote  "HAPPY HOLIDAYS!" / textattrs=(size=14pt weight=bold);     
    discreteAttrMap name='PresentColor';     * Translate random color #'s to colors;
      value '1' / fillattrs=(color=blue);
      value '2' / fillattrs=(color=red);
      value '3' / fillattrs=(color=green);
      value '4' / fillattrs=(color=purple);
      value '5' / fillattrs=(color=orange);
      value '6' / fillattrs=(color=hotpink);
      value '7' / fillattrs=(color=black);
    endDiscreteAttrMap;
    discreteAttrVar attrVar=PresentC var=RndColor attrMap="PresentColor";
    layout overlayequated / border=false xaxisopts=(display=(line ticks tickvalues)) 
                            yaxisopts=(display=(line ticks tickvalues));
      polygonplot id=newid x=x y=y / display=(fill) group=presentc fillATTRS=(transparency=.75) INCLUDEMISSINGGROUP=FALSE;
      polygonplot id=newid2 x=x y=y / display=(fill) group=presentc fillATTRS=(transparency=.45) INCLUDEMISSINGGROUP=FALSE;
      polygonplot id=newid3 x=x y=y / display=(fill) group=presentc fillATTRS=(transparency=0) INCLUDEMISSINGGROUP=FALSE;
    endlayout;
  endgraph;
end;

proc sgrender data=xmastreepresents template=xmastemplate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 16:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318135#M11141</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2016-12-11T16:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/ODS Graphics: Chock Full O'Presents Xmas Tree</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318138#M11142</link>
      <description>&lt;P&gt;Another good one, Ted. &amp;nbsp; I suggest removing the axes and wall border.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 16:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318138#M11142</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-12-11T16:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/ODS Graphics: Chock Full O'Presents Xmas Tree</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318143#M11143</link>
      <description>&lt;P&gt;Good suggestion - revised LAYOUT statement and image below!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6328iEE26DA65371D9594/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="XMASTREE.png" title="XMASTREE.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;layout overlayequated / xaxisopts=(display=none) yaxisopts=(display=none) walldisplay=none;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Dec 2016 17:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318143#M11143</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2016-12-11T17:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/ODS Graphics: Chock Full O'Presents Xmas Tree</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318157#M11144</link>
      <description>&lt;P&gt;A &lt;A href="https://en.wikipedia.org/wiki/Q*bert" target="_self"&gt;Q*bert&lt;/A&gt; Christmas!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6331i25BE86CE5C774776/image-size/small?v=v2&amp;amp;px=-1" border="0" alt="from http://www.hardcoregaming101.net/" title="from http://www.hardcoregaming101.net/" /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 18:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/318157#M11144</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-12-11T18:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/ODS Graphics: Chock Full O'Presents Xmas Tree</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/319556#M11189</link>
      <description>&lt;P&gt;wow&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 15:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-ODS-Graphics-Chock-Full-O-Presents-Xmas-Tree/m-p/319556#M11189</guid>
      <dc:creator>bemenogu</dc:creator>
      <dc:date>2016-12-16T15:07:03Z</dc:date>
    </item>
  </channel>
</rss>

