Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,59 @@
|
|||
package main
|
||||
|
||||
// Files required to build supporting package raster are found in:
|
||||
// * Bitmap
|
||||
// * Write a PPM file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os/exec"
|
||||
"raster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b := raster.NewBitmap(400, 300)
|
||||
// a little extravagant, this draws a design of dots and lines
|
||||
b.FillRgb(0xc08040)
|
||||
for i := 0; i < 2000; i++ {
|
||||
b.SetPxRgb(rand.Intn(400), rand.Intn(300), 0x804020)
|
||||
}
|
||||
for x := 0; x < 400; x++ {
|
||||
for y := 240; y < 245; y++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
for y := 260; y < 265; y++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
}
|
||||
for y := 0; y < 300; y++ {
|
||||
for x := 80; x < 85; x++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
for x := 95; x < 100; x++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
}
|
||||
|
||||
// pipe logic
|
||||
c := exec.Command("cjpeg", "-outfile", "pipeout.jpg")
|
||||
pipe, err := c.StdinPipe()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = c.Start()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = b.WritePpmTo(pipe)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = pipe.Close()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
convert[img_, out_] :=
|
||||
Module[{pipe =
|
||||
StartProcess[{"WolframKernel", "-noinit", "-noprompt", "-run",
|
||||
"Export[\"out.jpg\",ImportString[InputString[],\"PPM\"]]"}]},
|
||||
WriteString[pipe, ExportString[Image[Graphics[]], "PPM"]];
|
||||
Close[pipe];];
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
let print_jpeg ~img ?(quality=96) () =
|
||||
let cmd = Printf.sprintf "cjpeg -quality %d" quality in
|
||||
(*
|
||||
let cmd = Printf.sprintf "ppmtojpeg -quality %d" quality in
|
||||
let cmd = Printf.sprintf "convert ppm:- -quality %d jpg:-" quality in
|
||||
*)
|
||||
let ic, oc = Unix.open_process cmd in
|
||||
output_ppm ~img ~oc;
|
||||
try
|
||||
while true do
|
||||
let c = input_char ic in
|
||||
print_char c
|
||||
done
|
||||
with End_of_file -> ()
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue