POV-Ray : Newsgroups : povray.text.scene-files : foreach macro : Re: foreach macro Server Time
15 May 2021 18:38:51 EDT (-0400)
  Re: foreach macro  
From: jr
Date: 24 Apr 2021 11:00:00
Message: <web.6084314cd564bfd479819d986cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...  I wanted to add another demo/"teaser" scene but run out of time, in
> the coming days perhaps.

a kind soul advised me that if I want to get people interested in the
'Foreach()' macro, I need to _sell_ it.  hence the teaser below (and attached
for convenience).


enjoy, jr.



/* obfusc.pov */

#version 3.8;

global_settings {assumed_gamma 1}

#include "foreach.inc"
#include "logo.inc"

camera {
  location <3.25,0,-4.5>
  direction z
  right x * (4/3)
  up y
  angle 80
  look_at <3.25,0,0>
}

/* the data.  the character codes are obscured 'rot13' style */
#declare A = array {
  array mixed {<0, 1, 0>, .75, 0,
          array {122, 110, 113, 114, 45, 130, 128, 118, 123, 116}},
  array mixed {<0, 0, 0>, 1, 1,
          array {93, 92, 99, 58, 95, 110, 134}},
  array mixed {<0, -1, 0>, .75, 0,
          array {64, 59, 69, 59, 61, 58, 110, 121, 125, 117, 110}}
};

#declare font_ = array {"comic.ttf", "comicbd.ttf"};

/* make plain text */
#macro m_ch(i_,elem_)
  chr(elem_ - 13)
#end

#declare str_ = array [3];

#for (i_,0,2)
  #declare str_[i_] = concat(Foreach(A[i_][3], dictionary {.Macro: "m_ch"}));
#end

/* et voila */
object {
  Povray_Logo
  texture {
    pigment {color rgb <1,1,0>}
    finish {ambient 0 emission 1}
  }
  scale 1.5
  translate <5.3, .3, 0>
}

#macro m_text(i_,elem_)
  text {
    ttf font_[elem_[2]] str_[i_], .1, 0
    texture {
      pigment {color rgb <1,1,0>}
      finish {ambient 0 emission 1}
    }
    scale (<1,1,1> * elem_[1])
    translate elem_[0]
  }
#end

Foreach(A, dictionary {.Macro: "m_text"})


Post a reply to this message


Attachments:
Download 'obfusc.pov.txt' (2 KB)

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.