Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Make a program that draws a picture

Name: Anonymous 2016-08-11 23:22

It can be simple, like just a single pixel or a line or a shape.

Name: Anonymous 2016-08-12 0:12

echo 'R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' | base64 -d >image.gif

Name: Anonymous 2016-08-12 1:10

>>2
Cute. How about an svg?

Name: Anonymous 2016-08-12 4:46

javascript:(function(){$$ = document.createElement("canvas");$$.style.cssText = "position: fixed; top: 0; left: 0; opacity: 0.5";$$.width = window.innerWidth;$$.height = window.innerHeight;document.body.appendChild($$);$ = $$.getContext("2d");$.translate($$.width / 2, $$.height / 2);setInterval(function(){$.save();$.setTransform(1, 0, 0, 1, 0, 0);$.clearRect(0, 0, $$.width, $$.height);$.restore();$.fillStyle = "black";$.font = "bold 69pt Arial";$.textAlign="center"; $.fillText("hax my anus", 0, 0);$.rotate(0.01);}, 25);})();

Name: Anonymous 2016-08-12 12:38

10 PRINT "/"

Name: Anonymous 2016-08-12 13:05

import Data.ByteString (ByteString, pack, writeFile)
import Data.Word
import Data.Array
import Data.List

type Bit = Bool
type Coordinate = (Int, Int)

type Bitmap = Array Coordinate Bit

empty w h = array ((0, 0), (w - 1, h - 1)) [ ((x, y), False) | x <- [0..w - 1], y <- [0..h - 1] ]

circle x y r = empty (x * 2) (y * 2) // step (r - 1) 0 where
step x y | x <= y = draw (x, y)
step x y = draw (x, y) ++ step (if x^2 + y^2 <= r^2 then x else x - 1) (y + 1)
draw (x', y') = flip zip (repeat True)
(map (\(x', y') -> (x + x', y + y'))
[( x', y'),
(-x', y'),
( x', -y'),
(-x', -y'),
( y', x'),
(-y', x'),
( y', -x'),
(-y', -x')])

base 0 = [False]
base 1 = [True]
base x = if odd x then True:(base ((x - 1) / 2)) else False:(base (x / 2))
where x / y = x `div` y

unbase :: [Bit] -> Word8
unbase xs = unbase' xs 0 where
unbase' [] _ = 0
unbase' (x:xs) n = (if x then 1 else 0) * (2^n) + (unbase' xs (n + 1))
extend xs n x = if length xs < n then xs ++ (take (n - length xs) (repeat x))
else xs
encode :: Int -> [Word8]
encode n = (reverse . map unbase) [a, b, c, d] where
bs = (extend (base n) 32 False)
(a, bs') = splitAt 8 bs
(b, bs'') = splitAt 8 bs'
(c, d) = splitAt 8 bs''

emit :: Bitmap -> ByteString
emit b = (pack . concat) [farbfeld,
(encode . (+ 1) . fst . snd . bounds) b,
(encode . (+ 1) . snd . snd . bounds) b,
payload] where
payload = concatMap (\b -> if b then black else white) ((map snd . sort . assocs) b)
black = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF]
white = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
sort = sortBy $ \((a, b), _) ((d, e), _) -> if b == e then compare a d else compare b e

farbfeld = [0x66, 0x61, 0x72, 0x62, 0x66, 0x65, 0x6C, 0x64]

main = writeFile "circle.ff" (emit (circle 1000 1000 500))

Name: Anonymous 2016-08-12 13:16

>>6
wow so elegant muh monads lol xdDDD

Name: Anonymous 2016-08-12 14:16

import Data.Word

freq = 0.3
spread = 8.0

unbase :: Integral int => int -> Word8 -> Word8 -> Word8 -> int
unbase base r g b = (fi r*base+fi g)*base+fi b
where fi = fromIntegral

-- | Approximate a 24-bit Rgb colour with a colour in the xterm256 6x6x6 colour cube, returning its index.
rgb24bit_to_xterm256 :: (Integral t) => Word8 -> Word8 -> Word8 -> t
rgb24bit_to_xterm256 r g b = let f = (`div` 43)
in 16 + unbase 6 (f r) (f g) (f b)

lolcat _ [] = ""

lolcat (color, lineColor, ansi) ('\n':xs) =
"\n" ++ lolcat (color', color', ansi) xs
where color' = lineColor + 1

lolcat (color, lineColor, ansi) ('\ESC':xs) =
lolcat (color, lineColor, True) xs

lolcat (color, lineColor, True) ('m':xs) =
lolcat (color, lineColor, False) xs

lolcat (color, lineColor, True) (x:xs) =
lolcat (color, lineColor, True) xs

lolcat (color, lineColor, False) (x:xs) =
"\ESC[38;5;" ++ colored ++ "m" ++ [x] ++ "\ESC[0m" ++ lolcat (color + 1 / spread, lineColor, False) xs
where red = round (sin (freq * color) * 127) + 128
green = round (sin (freq * color + 2 * pi / 3) * 127) + 128
blue = round (sin (freq * color + 4 * pi / 3) * 127) + 128
colored = show $ rgb24bit_to_xterm256 red green blue

main = interact $ lolcat (0, 0, False)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List