Basic: buffer
buffer
The key features
- Memory control and always safe with array limits
- Common component to multiple purposes
The buffer is one of the key primitives of AnimationCPU. It is used to store and manipulate data and text. Everything uses a buffer. A buffer is always a 2D table with rows and columns, allowing you to store multiline text, easily attach any kind of data, and solve 80% of tasks more efficiently with 2D structures. If you're used to working with 1D arrays in other languages, you'll be pleasantly surprised by the possibilities a 2D buffer unlocks for vibe coding.
import
_ @sys.obj;
buffer.new - create buffer
lines0=buffer.new(u0, 100,1000);
buffer.set.size - buffer resize
buffer.set.size(u0, buf0,i, size);
buffer.dma - attach to dma
buffer.dma(u0, dma0, buf,i);
buffer.clone - text clone
text0=buffer.clone(u0, strings0,i);
str.clone - clone string to buffer
str.clone(buf,i); -> buf
buffer get/set
buffer.set - set value
buffer.set(u0, buf,i,offs, v0);
buffer.set2(u0, buf,i,offs, v0,v1);
buffer.set3(u0, buf,i,offs, v0,v1,v2);
buffer.set4(u0, buf,i,offs, v0,v1,v2,v3);
buffer.get - get value
v0:=buffer.get(u0, buf,i,offs);
buffer strings
buffer.print.v0 - print value0
buffer.print.v(u0, lines0,0, date.start);
buffer.trim.left.eol - text trim
query0 = buffer.trim.left.eol(text0);
buffer util
buffer.shr - shift right
buffer.shr(u0, buffer,i);
buffer geometry
buffer.new.rect0 - new v2rect array
buffer.new.rect0(dma, id, x,y, w,h);
buffer.add.rect0 - add to v2rect array
buffer.add.rect0(dma, id, x,y, w,h);
to review
buffer clear
Buffer clear
buffer.dma(u0, dma0, buf0,0);
dma.strip.size(u0, dma0, 0);
buffer resize
Buffer resize
buffer.dma(u0, dma0, buf0,0);
dma.strip.size(u0, dma0, 10);