KLayout layer properties
RAIMAD has support for creating
KLayout's lyp (layer properties) files.
This page provides a brief overview of these capabilities.
For exhaustive documentation
(different layer properties and their values;
builtin dither pattern names;
builtin line pattern names),
please read the KLayout docs,
or consult
src/raimad/cif/lyp.py.
Layer properties can be assigned to an object using
the _experimental_lyp dict, mapping
CIF layer names
(not RAIMAD layer names -- see CIF Layer Names)
to rai.lyp.Properties objects:
import raimad as rai
class Foo(rai.Compo):
_experimental_lyp = {
'RED': rai.lyp.Properties(
fill_color='#ff0000',
frame_color='#00ffff',
width=2,
),
'BLUE': rai.lyp.Properties(
fill_color='#0000ff',
frame_color='#ffaa00',
width=5,
),
}
def _make(self):
self.subcompos.append(rai.RectLW(10, 10).proxy().map('red'))
self.subcompos.append(rai.RectLW(10, 10)
.proxy().movex(20).map('blue'))
The .lyp file needs to be exported separately from the .cif file:
compo = Foo()
rai.export_cif(compo, 'foo.cif')
rai.export_lyp(compo, 'foo.lyp')
In KLayout, the .lyp file can be loaded using
File > Load Layer Properties:
Dither patterns and line stipples are supported too.
rai.lyp.dithers and rai.lyp.lines are DictLists
(see DictList), so you may use .attribute
syntax.
Some dither and lines names, however,
contain spaces and dashes,
so you need to use ['index'] syntax to access these.
class Foo(rai.Compo):
_experimental_lyp = {
'ROOT': rai.lyp.Properties(
fill_color='#ff0000',
frame_color='#00ffff',
dither_pattern=rai.lyp.dithers.pyramids,
line_style=rai.lyp.lines['short dash-dotted'],
width=5,
),
}
def _make(self):
self.subcompos.append(rai.RectLW(10, 10).proxy())
RAIMAD also ships with some custom dither patterns not available in standard KLayout:
for idx, name in enumerate(rai.cif.lyp.raidithers.keys()):
print(f"{idx}: {name}")
0: tifuun
1: tifuunalt
2: pebble
3: snow
4: carrot
5: stratal
6: raimad
7: oni
class Demo(rai.Compo):
_experimental_lyp = {
f'A{i}': rai.cif.lyp.Properties(dither_pattern=pattern)
for i, pattern
in enumerate(rai.cif.lyp.raidithers.values())
}
def _make(self) -> None:
for i, name in enumerate(rai.cif.lyp.raidithers.keys()):
x = i % 4 * 70
y = i // 4 * 70
print(f"{x}, {y}: {name}")
self.subcompos.append(
rai.RectLW(64, 64)
.proxy()
.move(x, y)
.map(f'A{i}')
)
User-defined dither patterns and lines are possible too:
bowtie = rai.cif.lyp.CustomDitherPattern(
name='bowtie',
lines=(
'****....',
'****....',
'**..**..',
'**..**..',
'..**..**',
'..**..**',
'....****',
'....****',
)
)
class Custom(rai.Compo):
_experimental_lyp = {
'FOO': rai.lyp.Properties(
line_style=rai.lyp.CustomLineStyle(
name='ascii',
pattern='*.*..*.*.....**..*..**..**.**...',
),
width=5,
dither_pattern=bowtie,
),
}
def _make(self):
self.subcompos.r1 = rai.RectLW(4, 4).proxy().map('foo')
#rai.export_cif(Foo())
#rai.export_lyp(Foo())