|
|
A scene file I just added to my tool box directory.
As the #switch #case only compares floats and not strings I always have to
figure out what character is what number. To scratch that itch a little scene
that writes an include file for the 'reverse look up' of the chr function using
a dictionary. It covers the ascii chars 34 to 127 as I don't know how to use a
'bell' as key.
---%<------%<------%<---
// Persistence of Vision Ray Tracer Scene / Include File
// File: chars.pov
// Vers: 3.8
//
// Desc: A scenefile to create an include file with a dictionary to look up
// the ascii numbers for characters.
// Author: Ingo Janssen
// Date: 2023-06-06
#version 3.8;
global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }}
#fopen CHR "chr.inc" write
#write (CHR "#version 3.8;\n
#ifndef(chr_Inc_Temp)
#declare chr_Inc_Temp = version;
#ifdef(View_POV_Include_Stack)
#debug \"including chr.inc\"
#end\n\n"
)
#write (CHR "#declare Chr = dictionary {\n")
#for (i, 34, 127)
#if (chr(i) = "\"" | chr(i) = "\\")
#write (CHR concat("[\"\\", chr(i),"\"] : ", str(i,0,0),"\n"))
#else
#write (CHR concat("[\"", chr(i),"\"] : ", str(i,0,0),"\n"))
#end
#end
#write (CHR "};\n\n")
#write (CHR " #version chr_Inc_Temp;
#end")
#fclose CHR
#include "chr.inc"
#debug concat(str(Chr["\""], 0, 0), "\n") // The " has to be escaped
#debug concat(str(Chr["\\"], 0, 0), "\n") // the \ has to be escaped
#debug concat(str(Chr["F"], 0, 0), "\n")
#debug concat(str(Chr["&"], 0, 0), "\n")
---%<------%<------%<---
Post a reply to this message
|
|
|
|
"ingo" <nomail@nomail> wrote:
> A scene file I just added to my tool box directory.
>
> As the #switch #case only compares floats and not strings I always have to
> figure out what character is what number. To scratch that itch a little scene
> that writes an include file for the 'reverse look up' of the chr function using
> a dictionary. It covers the ascii chars 34 to 127 as I don't know how to use a
> 'bell' as key.
Can you not use asc() for this ?`
http://www.povray.org/documentation/view/3.7.1/228/
You can use chr(7) to quote the ASCII bell character.
https://www.povray.org/documentation/view/3.7.2/232/
This code outputs 7
#version 3.7;
global_settings { assumed_gamma 1.0 }
#debug "\n"
#debug str(asc(chr(7)), 0, 0)
#debug "\n"
#error ""
Perhaps chr(7) can also be used as a key in a v3.8 dictionary (?)
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
|