✨ add new test file burningship.nas
This commit is contained in:
parent
ef4af8f195
commit
4c8e1dfe91
Binary file not shown.
After Width: | Height: | Size: 161 KiB |
|
@ -379,7 +379,7 @@ var dump = func {
|
|||
# Don't recurse into aliases, lest we get stuck in a loop
|
||||
if(type != "ALIAS") {
|
||||
var children = node.getChildren();
|
||||
foreach(c; children) { dump(name ~ "/", c); }
|
||||
foreach(var c; children) { dump(name ~ "/", c); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ var createNodeObjectsFromHash = func (property_list, namespace = nil) {
|
|||
logprint(LOG_WARN, "createNodeObjectsFromHash: Error, property_list argument is not a hash.");
|
||||
return nil;
|
||||
}
|
||||
foreach (key; keys(property_list)) {
|
||||
foreach (var key; keys(property_list)) {
|
||||
namespace[key] = props.getNode(property_list[key],1);
|
||||
}
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ var UpdateManager =
|
|||
obj.needs_update = 0;
|
||||
obj.property = {};
|
||||
obj.is_numeric = {};
|
||||
foreach (hashkey; obj.hashkeylist) {
|
||||
foreach (var hashkey; obj.hashkeylist) {
|
||||
obj.property[hashkey] = props.globals.getNode(hashkey);
|
||||
obj.lastval[hashkey] = nil;
|
||||
# var ty = obj.property[hashkey].getType();
|
||||
|
@ -833,7 +833,7 @@ var UpdateManager =
|
|||
me.needs_update = 0;
|
||||
|
||||
if (obj != nil or me.lastval == nil) {
|
||||
foreach (hashkey; me.hashkeylist) {
|
||||
foreach (var hashkey; me.hashkeylist) {
|
||||
if (me.isnum) {
|
||||
if (me.lastval[hashkey] == nil or math.abs(me.lastval[hashkey] - obj[hashkey]) >= me.delta) {
|
||||
me.needs_update = 1;
|
||||
|
@ -847,7 +847,7 @@ var UpdateManager =
|
|||
}
|
||||
if (me.needs_update) {
|
||||
me.changed(obj);
|
||||
foreach (hashkey; me.hashkeylist) {
|
||||
foreach (var hashkey; me.hashkeylist) {
|
||||
me.lastval[hashkey] = obj[hashkey];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
import.std.process_bar;
|
||||
|
||||
var ppm = func(filename, width, height, RGB) {
|
||||
# P3 use ASCII number
|
||||
# P6 use binary character
|
||||
var fd = io.open(filename, "wb");
|
||||
io.write(fd, "P6\n"~width~" "~height~"\n255\n");
|
||||
for(var i = 0; i<height; i += 1) {
|
||||
for(var j = 0; j<width; j += 1) {
|
||||
io.write(fd,RGB(i,j));
|
||||
}
|
||||
}
|
||||
io.close(fd);
|
||||
}
|
||||
|
||||
var width = 1920;
|
||||
var height = 1080;
|
||||
var bar = (os.platform()=="windows")?
|
||||
process_bar.bar(front:"sharp", back:"point", sep:"line", length:50):
|
||||
process_bar.high_resolution_bar(50);
|
||||
|
||||
var f = func(i, j) {
|
||||
var (yMin, yMax, xMin, xMax) = (-2, 1.1, -3.2, 2);
|
||||
var (yDel, xDel) = (yMax-yMin, xMax-xMin);
|
||||
var (y, x) = ((i/height)*yDel+yMin, (j/width)*xDel+xMin);
|
||||
var (x0, y0) = (x, y);
|
||||
for(var iter = 0; iter<64; iter += 1) {
|
||||
(x0, y0) = (math.abs(x0), math.abs(y0));
|
||||
var (x1, y1) = ((x0*x0)-(y0*y0)+x, 2*x0*y0+y);
|
||||
(x0, y0) = (x1, y1);
|
||||
if ((x0*x0)+(y0*y0)>8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var progress = (i*width+j+1)/(width*height);
|
||||
if (progress*100-int(progress*100)==0) {
|
||||
print(bar.bar(progress), " ", progress*100, "% \r");
|
||||
}
|
||||
iter = iter>=25? 255:int(iter/25*255);
|
||||
var c = char(iter);
|
||||
return c~c~c;
|
||||
}
|
||||
|
||||
ppm("burningship.ppm", width, height, f);
|
||||
println();
|
|
@ -1,6 +1,6 @@
|
|||
import.std.process_bar;
|
||||
|
||||
var ppm=func(filename, width, height, RGB){
|
||||
var ppm = func(filename, width, height, RGB) {
|
||||
# P3 use ASCII number
|
||||
# P6 use binary character
|
||||
var fd = io.open(filename, "wb");
|
||||
|
@ -15,8 +15,8 @@ var ppm=func(filename, width, height, RGB){
|
|||
|
||||
var width = 1600;
|
||||
var height = 900;
|
||||
var bar=(os.platform()=="windows")?
|
||||
process_bar.bar(front:"sharp",back:"point",sep:"line",length:50):
|
||||
var bar = (os.platform()=="windows")?
|
||||
process_bar.bar(front:"sharp", back:"point", sep:"line", length:50):
|
||||
process_bar.high_resolution_bar(50);
|
||||
|
||||
var RGB = func(h, w) {
|
||||
|
|
|
@ -1,41 +1,43 @@
|
|||
import.std.process_bar;
|
||||
|
||||
var ppm=func(filename,width,height,RGB){
|
||||
var ppm = func(filename, width, height, RGB) {
|
||||
# P3 use ASCII number
|
||||
# P6 use binary character
|
||||
var fd=io.open(filename,"wb");
|
||||
io.write(fd,"P3\n"~width~" "~height~"\n255\n");
|
||||
for(var i=0;i<height;i+=1){
|
||||
for(var j=0;j<width;j+=1)
|
||||
var fd = io.open(filename, "wb");
|
||||
io.write(fd, "P6\n"~width~" "~height~"\n255\n");
|
||||
for(var i = 0; i<height; i += 1) {
|
||||
for(var j = 0; j<width; j += 1) {
|
||||
io.write(fd,RGB(i,j));
|
||||
io.write(fd,"\n");
|
||||
}
|
||||
}
|
||||
io.close(fd);
|
||||
}
|
||||
|
||||
var width=1920;
|
||||
var height=1080;
|
||||
var bar=(os.platform()=="windows")?
|
||||
process_bar.bar(front:"sharp",back:"point",sep:"line",length:50):
|
||||
var width = 1920;
|
||||
var height = 1080;
|
||||
var bar = (os.platform()=="windows")?
|
||||
process_bar.bar(front:"sharp", back:"point", sep:"line", length:50):
|
||||
process_bar.high_resolution_bar(50);
|
||||
var f=func(i,j){
|
||||
var (yMin,yMax,xMin,xMax)=(-1.35,1.35,-3.3,1.5);
|
||||
var (yDel,xDel)=(yMax-yMin,xMax-xMin);
|
||||
var (y,x)=((i/height)*yDel+yMin,(j/width)*xDel+xMin);
|
||||
var (x0,y0)=(x,y);
|
||||
for(var iter=0;iter<64;iter+=1){
|
||||
var (x1,y1)=((x0*x0)-(y0*y0)+x,2*x0*y0+y);
|
||||
(x0,y0)=(x1,y1);
|
||||
if((x0*x0)+(y0*y0)>4){
|
||||
var f = func(i, j) {
|
||||
var (yMin, yMax, xMin, xMax) = (-1.35, 1.35, -3.3, 1.5);
|
||||
var (yDel, xDel) = (yMax-yMin, xMax-xMin);
|
||||
var (y, x) = ((i/height)*yDel+yMin, (j/width)*xDel+xMin);
|
||||
var (x0, y0) = (x, y);
|
||||
for(var iter = 0; iter<64; iter += 1) {
|
||||
var (x1, y1) = ((x0*x0)-(y0*y0)+x, 2*x0*y0+y);
|
||||
(x0, y0) = (x1, y1);
|
||||
if ((x0*x0)+(y0*y0)>4) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var progress=(i*width+j+1)/(width*height);
|
||||
if(progress*100-int(progress*100)==0){
|
||||
print(bar.bar(progress)," ",progress*100,"% \r");
|
||||
var progress = (i*width+j+1)/(width*height);
|
||||
if (progress*100-int(progress*100)==0) {
|
||||
print(bar.bar(progress), " ", progress*100, "% \r");
|
||||
}
|
||||
iter=iter==25?255:int(iter/25*255);
|
||||
return iter~" "~iter~" "~iter~" ";
|
||||
iter = iter>=25? 255:int(iter/25*255);
|
||||
var c = char(iter);
|
||||
return c~c~c;
|
||||
}
|
||||
ppm("a.ppm",width,height,f);
|
||||
|
||||
ppm("mandelbrotset.ppm", width, height, f);
|
||||
println();
|
||||
|
|
Loading…
Reference in New Issue