(_args: ICompBuilderArgs)
| 30 | } |
| 31 | |
| 32 | export function createInputOutputComps(_args: ICompBuilderArgs): ICompDef<any>[] { |
| 33 | |
| 34 | let w = 6; |
| 35 | let h = 4; |
| 36 | let output: ICompDef<ICompDataOutput> = { |
| 37 | defId: 'io/output0', |
| 38 | altDefIds: ['output0'], |
| 39 | name: "Output", |
| 40 | size: new Vec3(w, h), |
| 41 | ports: [ |
| 42 | { id: 'x', name: 'x', pos: new Vec3(0, 2), type: PortType.In, width: 32 }, |
| 43 | ], |
| 44 | build: (builder) => { |
| 45 | let data = builder.addData({ |
| 46 | inPort: builder.getPort('x'), |
| 47 | }); |
| 48 | |
| 49 | builder.addPhase(() => { }, [data.inPort], []); |
| 50 | |
| 51 | return builder.build(); |
| 52 | }, |
| 53 | render: ({ comp, cvs, ctx, exeComp, styles }) => { |
| 54 | if (!exeComp) { |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | ctx.save(); |
| 59 | ctx.font = makeCanvasFont(styles.fontSize, FontType.Mono); |
| 60 | ctx.fillStyle = '#000'; |
| 61 | ctx.textAlign = 'center'; |
| 62 | ctx.textBaseline = 'middle'; |
| 63 | |
| 64 | let value = exeComp.data.inPort.value; |
| 65 | ctx.fillText(value.toString(), comp.pos.x + comp.size.x / 2, comp.pos.y + comp.size.y / 2); |
| 66 | |
| 67 | ctx.restore(); |
| 68 | }, |
| 69 | }; |
| 70 | |
| 71 | |
| 72 | let constW = 10; |
| 73 | let const32: ICompDef<ICompDataInput, IInputConfig> = { |
| 74 | defId: 'io/const32', |
| 75 | altDefIds: ['const32'], |
| 76 | name: "Const32", |
| 77 | size: new Vec3(constW, h), |
| 78 | ports: (args, compDef) => { |
| 79 | let portType = PortType.Out; |
| 80 | let pos = portPlacementToPos(args.portPos, args.w, args.h); |
| 81 | |
| 82 | return [ |
| 83 | { id: 'out', name: '', pos, type: portType, width: args.bitWidth }, |
| 84 | ]; |
| 85 | }, |
| 86 | initConfig: () => ({ |
| 87 | value: 4, |
| 88 | valueMode: HexValueInputType.Hex, |
| 89 | bitWidth: 32, |
no test coverage detected