Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
import "graphics" for Canvas, ImageData, Color
|
||||
import "dome" for Window, Process
|
||||
import "io" for FileSystem
|
||||
|
||||
class Bitmap {
|
||||
construct new(name, width, height) {
|
||||
Window.title = name
|
||||
Window.resize(width, height)
|
||||
Canvas.resize(width, height)
|
||||
_bmp = ImageData.create(name, width, height)
|
||||
// create bitmap
|
||||
for (y in 0...height) {
|
||||
for (x in 0...width) {
|
||||
var c = Color.rgb(x % 256, y % 256, (x * y) % 256)
|
||||
pset(x, y, c)
|
||||
}
|
||||
}
|
||||
_w = width
|
||||
_h = height
|
||||
}
|
||||
|
||||
init() {
|
||||
// write bitmap to a PPM file
|
||||
var ppm = "P6\n%(_w) %(_h)\n255\n"
|
||||
for (y in 0..._h) {
|
||||
for (x in 0..._w) {
|
||||
var c = pget(x, y)
|
||||
ppm = ppm + String.fromByte(c.r)
|
||||
ppm = ppm + String.fromByte(c.g)
|
||||
ppm = ppm + String.fromByte(c.b)
|
||||
}
|
||||
}
|
||||
FileSystem.save("output.ppm", ppm)
|
||||
Process.exit(0)
|
||||
}
|
||||
|
||||
pset(x, y, col) { _bmp.pset(x, y, col) }
|
||||
|
||||
pget(x, y) { _bmp.pget(x, y) }
|
||||
|
||||
update() {}
|
||||
|
||||
draw(alpha) {}
|
||||
}
|
||||
|
||||
var Game = Bitmap.new("Bitmap - write to PPM file", 320, 320)
|
||||
Loading…
Add table
Add a link
Reference in a new issue