Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/aienux/allen/surface.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / allen / surface.om` 185 lines ยท 3959 bytes Raw Blame History 1 note Bounded text surface at native scale. See SURFACE.md. The screens lay out on a logical 2 note 768 x 384 grid (Cv); every glyph and fill lands in the native frame Nfrm (look-paint.om) at 3 note Cvs[0] native pixels per logical pixel, centred by Cvs[2], Cvs[3]. Glyphs are rasterised at 4 note the logical cap height times the scale, so type stays crisp on a 4K panel. 5 note Cvs: 0 scale, 1 logical cap, 2 x offset, 3 y offset, 4..7 the clip in native pixels. 6 global Canvas uchar 884736 7 global Cv ulong 8 8 global Cvs ulong 8 9 global Cvpose long 2 10 fn cvinit w ulong h ulong to bool 11 if or eq w 0 gt w 768 12 ret false 13 end 14 if or eq h 0 gt h 384 15 ret false 16 end 17 for i ulong 8 18 put Cv i 0 19 end 20 put Cv 0 w 21 put Cv 1 h 22 put Cv 4 w 23 put Cv 5 h 24 put Cv 6 1 25 for i ulong 8 26 put Cvs i 0 27 end 28 put Cvs 0 1 29 sw = ulong get Lg 0 30 sh = ulong get Lg 1 31 if and ge sw w ge sh h 32 s = div sw w 33 if lt div sh h s 34 s = div sh h 35 end 36 if eq s 0 37 s = 1 38 end 39 put Cvs 0 s 40 put Cvs 2 div sub sw mul w s 2 41 put Cvs 3 div sub sh mul h s 2 42 end 43 put Cvs 4 get Cvs 2 44 put Cvs 5 get Cvs 3 45 put Cvs 6 mul w get Cvs 0 46 put Cvs 7 mul h get Cvs 0 47 ret true 48 end 49 fn cvclip x ulong y ulong w ulong h ulong to bool 50 if eq get Cv 6 0 51 ret false 52 end 53 if or gt x get Cv 0 gt y get Cv 1 54 ret false 55 end 56 if gt w sub get Cv 0 x 57 ret false 58 end 59 if gt h sub get Cv 1 y 60 ret false 61 end 62 put Cv 2 x 63 put Cv 3 y 64 put Cv 4 w 65 put Cv 5 h 66 s = get Cvs 0 67 put Cvs 4 add mul x s get Cvs 2 68 put Cvs 5 add mul y s get Cvs 3 69 put Cvs 6 mul w s 70 put Cvs 7 mul h s 71 ret true 72 end 73 fn cvfont cap ulong wt ulong to bool 74 note The face for the following glyphs: cap in logical pixels, rasterised at native size. 75 put Cvs 1 cap 76 n = mul cap get Cvs 0 77 if gt n 64 78 n = 64 79 end 80 ret afinit n wt 81 end 82 fn cvblend bg ulong fg ulong a ulong to ulong 83 v = mul bg sub ulong 255 a 84 v = add v mul fg a 85 ret div v 255 86 end 87 fn cvin x long y long to bool 88 if or lt x long get Cvs 4 lt y long get Cvs 5 89 ret false 90 end 91 if ge x long add get Cvs 4 get Cvs 6 92 ret false 93 end 94 ret lt y long add get Cvs 5 get Cvs 7 95 end 96 fn cvmixat at ulong a ulong color ulong to void 97 note One native pixel of the frame toward color by a/255. 98 d = ulong get Nfrm at 99 r = cvblend and shr d 16 255 and shr color 16 255 a 100 g = cvblend and shr d 8 255 and shr color 8 255 a 101 b = cvblend and d 255 and color 255 a 102 put Nfrm at uint or or shl r 16 shl g 8 b 103 end 104 fn cvpixel x long y long a uchar color ulong to void 105 note Native coordinates, held inside the clip. 106 if not cvin x y 107 ret 108 end 109 at = add mul ulong y ulong get Lg 0 ulong x 110 cvmixat at ulong a color 111 end 112 fn cvrow yy ulong color ulong to void 113 y = add get Cvpose 1 long yy 114 at = mul yy get Af 3 115 for x ulong get Af 3 116 px = add get Cvpose 0 long x 117 cvpixel px y get Alpha add at x color 118 end 119 end 120 fn cvblit x long y long color ulong to void 121 note x, y: the glyph's logical origin and baseline; the mask offsets Ab are native already. 122 s = long get Cvs 0 123 ox = add mul x s long get Cvs 2 124 oy = add mul y s long get Cvs 3 125 put Cvpose 0 add ox get Ab 0 126 put Cvpose 1 add oy get Ab 1 127 for yy ulong get Af 4 128 cvrow yy color 129 end 130 end 131 fn cvargs x long y long color ulong to bool 132 if or eq get Cv 6 0 eq get Af 0 0 133 ret false 134 end 135 if or lt x -4096 gt x 4096 136 ret false 137 end 138 if or lt y -4096 gt y 4096 139 ret false 140 end 141 ret le color `16777215` 142 end 143 fn cvglyph c uchar x long y long color ulong to bool 144 if not cvargs x y color 145 ret false 146 end 147 if not afglyph c 148 ret false 149 end 150 cvblit x y color 151 put Cv 7 div get Af 5 get Cvs 0 152 ret true 153 end 154 fn cvfillrow y long x0 long n long a ulong color ulong to void 155 for k ulong ulong n 156 cvpixel add x0 long k y uchar a color 157 end 158 end 159 fn cvfill x ulong y ulong w ulong h ulong color ulong a ulong to void 160 note A logical rectangle mixed toward color by a/255 (255: solid), inside the clip. 161 if eq get Cv 6 0 162 ret 163 end 164 if gt x get Cv 0 165 ret 166 end 167 if gt y get Cv 1 168 ret 169 end 170 if gt w sub get Cv 0 x 171 ret 172 end 173 if gt h sub get Cv 1 y 174 ret 175 end 176 if gt a 255 177 a = 255 178 end 179 s = get Cvs 0 180 x0 = long add mul x s get Cvs 2 181 y0 = long add mul y s get Cvs 3 182 for yy ulong mul h s 183 cvfillrow add y0 long yy x0 long mul w s a color 184 end 185 end