Coverage for qpdk / samples / sample0.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-14 10:27 +0000

1# --- 

2# jupyter: 

3# jupytext: 

4# text_representation: 

5# extension: .py 

6# format_name: percent 

7# format_version: '1.3' 

8# jupytext_version: 1.17.3 

9# --- 

10 

11# %% [markdown] 

12# # Write GDS with Hello World 

13# 

14# This sample demonstrates creating a simple GDS layout with text and geometric shapes. 

15 

16# %% 

17from __future__ import annotations 

18 

19import gdsfactory as gf 

20 

21from qpdk import LAYER 

22 

23# %% [markdown] 

24# ## Sample Function 

25# 

26# Creates a component with 'Hello world' text and a rectangle positioned relative to each other. 

27 

28 

29# %% 

30@gf.cell 

31def sample0_hello_world() -> gf.Component: 

32 """Returns a component with 'Hello world' text and a rectangle.""" 

33 c = gf.Component() 

34 ref1 = c.add_ref(gf.components.rectangle(size=(10, 10), layer=LAYER.M1_DRAW)) 

35 ref2 = c.add_ref(gf.components.text("Hello", size=10, layer=LAYER.M1_DRAW)) 

36 ref3 = c.add_ref(gf.components.text("world", size=10, layer=LAYER.M1_DRAW)) 

37 ref1.xmax = ref2.xmin - 5 

38 ref3.xmin = ref2.xmax + 2 

39 ref3.rotate(90) 

40 return c