📝 add test file `ppmgen.nas`
This commit is contained in:
parent
73278ea2dd
commit
007b83bed5
|
@ -45,4 +45,5 @@ nasal.exe
|
|||
|
||||
# misc
|
||||
.vscode
|
||||
dump
|
||||
dump
|
||||
a.ppm
|
|
@ -10,7 +10,7 @@
|
|||
|
||||

|
||||

|
||||

|
||||

|
||||
[](./LICENSE)
|
||||
|
||||
> This document is also available in: [__中文__](./doc/README_zh.md) | [__English__](./README.md)
|
||||
|
|
1
makefile
1
makefile
|
@ -59,6 +59,7 @@ test:nasal
|
|||
@ ./nasal -op -e test/nasal_test.nas
|
||||
@ ./nasal -op -c test/occupation.nas
|
||||
@ ./nasal -op -t -d test/pi.nas
|
||||
@ ./nasal -op -c test/ppmgen.nas
|
||||
@ ./nasal -op -t -d test/prime.nas
|
||||
@ ./nasal -op -e test/qrcode.nas
|
||||
@ ./nasal -op -t -d test/quick_sort.nas
|
||||
|
|
2
nasal.h
2
nasal.h
|
@ -1,6 +1,6 @@
|
|||
#ifndef __NASAL_H__
|
||||
#define __NASAL_H__
|
||||
#define __nasver "10.0"
|
||||
#define __nasver "10.1"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -60,6 +60,7 @@ var testfile=[
|
|||
"nasal_test.nas ",
|
||||
"occupation.nas ",
|
||||
"pi.nas ",
|
||||
"ppmgen.nas ",
|
||||
"prime.nas ",
|
||||
"qrcode.nas ",
|
||||
"quick_sort.nas ",
|
||||
|
|
|
@ -53,6 +53,7 @@ var filechecksum=func(){
|
|||
"./test/md5.nas", "./test/md5compare.nas",
|
||||
"./test/module_test.nas", "./test/nasal_test.nas",
|
||||
"./test/occupation.nas", "./test/pi.nas",
|
||||
"./test/ppmgen.nas",
|
||||
"./test/prime.nas", "./test/qrcode.nas",
|
||||
"./test/quick_sort.nas", "./test/scalar.nas",
|
||||
"./test/snake.nas", "./test/tetris.nas",
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
var RD=func(i,j){
|
||||
return chr(bits.u32_and(255,j*0.25+i*0.001));
|
||||
}
|
||||
var GR=func(i,j){
|
||||
return chr(bits.u32_and(255,j*0.15));
|
||||
}
|
||||
var BL=func(i,j){
|
||||
return chr(bits.u32_and(255,j*0.05));
|
||||
}
|
||||
var pixel_write=func(fd,i,j){
|
||||
var color=RD(i,j)~GR(i,j)~BL(i,j);
|
||||
io.write(fd,color);
|
||||
}
|
||||
|
||||
var fd=io.open("a.ppm","wb");
|
||||
io.write(fd,"P6\n512 512\n255\n");
|
||||
for(var i=0;i<512;i+=1)
|
||||
for(var j=0;j<512;j+=1)
|
||||
pixel_write(fd,i,j);
|
||||
io.close(fd);
|
Loading…
Reference in New Issue