[PythonCAD] schema location / colors

Art Haas ahaas at airmail.net
Tue Jul 27 17:06:03 CEST 2004


On Mon, Jul 26, 2004 at 09:26:48PM -0500, Eric Wilhelm wrote:
> Will this eventually point at an actual .xsd file or something?
>     schemaLocation="http://www.pythoncad.org">

Yes. That location was filler until the schema was finished, and I
haven't worked on that in quite some time. :-(

> What I really want to know is why colors are assigned id's like so:
> 
>       <image:Color b="0" color="#000000" g="0" id="0" r="0"/>
>       <image:Color b="255" color="#0000ff" g="0" id="1" r="0"/>
>       <image:Color b="255" color="#00ffff" g="255" id="2" r="0"/>
>       <image:Color b="210" color="#508cd2" g="140" id="3" r="80"/>
>       <image:Color b="0" color="#ffff00" g="255" id="4" r="255"/>
>       <image:Color b="255" color="#ffffff" g="255" id="5" r="255"/>
> 
> This seems to be an unnecessary complication in representing the colors 
> (though your notes about transitioning to strictly #00FF00 representations 
> are duly noted.)

I initially thought defining the colors as just R, G, and B values made
sense. I then added the 'color=' bit. The idea was that entities would
just reference the color id, and by doing so would reduce the file size
as the 'cid=X' is smaller than 'color=#XXXXXX'.

> Why even have a table of colors?  I'll try to answer my own question, but 
> first a rant about the failings of AutoCAD.
> 
> Granted, the hexadecimal representation was not likely very standard when 
> autocad started and 24-bit color was possibly even unheard-of at that time.  
> However, they maintained the ACI (Autocad Color Index) convention through to 
> 2000 (I think it changed near version 2004?)
> 
> The ACI uses the numbers 0-256 to represent 255 colors and the special 'by 
> layer' (256) and 'by block' (0) colors.  My guess is that this convention 
> started partly from the need for optimization and partly from the lack of a 
> predominant convention.  Today's hardware is rocket-like compared to the 
> hardware of the 70's, so we can safely discard optimization as a need for 
> indexing colors.
> 
> However, the #09ABCF hexadecimal convention limits us to some extent because 
> we cannot have the non-color colors (or rather, inherited colors) of 'by 
> block' or 'by layer' or even 'by date' (that last one is just for fun.)  But, 
> since we are storing things textually and not allocating three byte-sized 
> registers on a magnetic drum, we can use arbitrarily high ascii characters in 
> these slots and have colors like #BY0001, or simply deliberately disobey the 
> 6-character limit and call it #BYLAYER.  The presence of one high character 
> is enough to throw a color_parse() subroutine into mode-2, but a convention 
> of #BYfoo allows us a little bit of delicious optimization (e.g. color[1] == 
> "Y".)
> 
> So, I propose that the colors be represented directly in the entities' 
> properties as 'extended hexidecimal'.  If a color table is needed then, it 
> would belong to a layer (or to the drawing), simply listing the default 
> colors per-layer.
> 
> A blue circle:
>   <image:Circle color="#0000ff" cp="0" id="1" r="127.27922061357856" 
> style="0"/>
> 
> A blue layer:
>   <image:Layer id="0" color="#0000ff" name="TopLayer" scale="1.0">
>     <image:Circles>
>       <image:Circle color="#BYLAYER" cp="0" id="1" r="127.27922061357856" 
> style="0"/>
> 
> I don't have any strong opinion about where the layer's properties are
> stored, but this seems to be a fitting place.

As someone not coming from an AutoCAD background, I had no background on
how colors were dealt with in that program. I like the '#xxxxxx' format
for specifying colors as it's used in lots of software like X Window
colors or web page colors. The hexidecimal format is easy to deal with
in Python as well.

I've not thought of having a layer color before, though how you
represent it above makes sense. If such a feature gets added to the
program, I'd want to see the entities reference the color in a different
manner than by using the "color=" attribute. I don't know just what
right now, but I'm not initially keen on the '#BYLAYER' approach. I
don't like the idea of having "color=" be something other than a hex
formatted color string.

As for layer colors, I that ability something that is used frequently in
AutoCAD? I don't see much use for it initially ...

Art

-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822


More information about the PythonCAD mailing list