2 people like it.
Like the snippet!
Sierpinski Carpet
The Sierpinski carpet is a plane fractal first described by Wacław Sierpiński in 1916.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
|
#if INTERACTIVE
#r "System.Drawing.dll"
#endif
open System.Drawing
let isSierpinskiCarpetPixelFilled(x, y) =
let rec f (x,y) =
if x > 0 || y > 0 then
if x % 3 = 1 && y % 3 = 1 then false
else f (x/3,y/3)
else true
f (x,y)
let width,height = 728, 728
let image = new Bitmap(width, height)
for y = 0 to height-1 do
for x = 0 to width-1 do
if isSierpinskiCarpetPixelFilled(x,y)
then image.SetPixel(x,y,Color.Black)
image.Save("carpet.png", Imaging.ImageFormat.Png)
|
namespace System
namespace System.Drawing
val isSierpinskiCarpetPixelFilled : x:int * y:int -> bool
Full name: Script.isSierpinskiCarpetPixelFilled
val x : int
val y : int
val f : (int * int -> bool)
val width : int
Full name: Script.width
val height : int
Full name: Script.height
val image : Bitmap
Full name: Script.image
Multiple items
type Bitmap =
inherit Image
new : filename:string -> Bitmap + 11 overloads
member Clone : rect:Rectangle * format:PixelFormat -> Bitmap + 1 overload
member GetHbitmap : unit -> nativeint + 1 overload
member GetHicon : unit -> nativeint
member GetPixel : x:int * y:int -> Color
member LockBits : rect:Rectangle * flags:ImageLockMode * format:PixelFormat -> BitmapData + 1 overload
member MakeTransparent : unit -> unit + 1 overload
member SetPixel : x:int * y:int * color:Color -> unit
member SetResolution : xDpi:float32 * yDpi:float32 -> unit
member UnlockBits : bitmapdata:BitmapData -> unit
...
Full name: System.Drawing.Bitmap
--------------------
Bitmap(filename: string) : unit
(+0 other overloads)
Bitmap(stream: System.IO.Stream) : unit
(+0 other overloads)
Bitmap(original: Image) : unit
(+0 other overloads)
Bitmap(filename: string, useIcm: bool) : unit
(+0 other overloads)
Bitmap(type: System.Type, resource: string) : unit
(+0 other overloads)
Bitmap(stream: System.IO.Stream, useIcm: bool) : unit
(+0 other overloads)
Bitmap(width: int, height: int) : unit
(+0 other overloads)
Bitmap(original: Image, newSize: Size) : unit
(+0 other overloads)
Bitmap(width: int, height: int, format: Imaging.PixelFormat) : unit
(+0 other overloads)
Bitmap(width: int, height: int, g: Graphics) : unit
(+0 other overloads)
Bitmap.SetPixel(x: int, y: int, color: Color) : unit
type Color =
struct
member A : byte
member B : byte
member Equals : obj:obj -> bool
member G : byte
member GetBrightness : unit -> float32
member GetHashCode : unit -> int
member GetHue : unit -> float32
member GetSaturation : unit -> float32
member IsEmpty : bool
member IsKnownColor : bool
...
end
Full name: System.Drawing.Color
property Color.Black: Color
Image.Save(filename: string) : unit
Image.Save(stream: System.IO.Stream, format: Imaging.ImageFormat) : unit
Image.Save(filename: string, format: Imaging.ImageFormat) : unit
Image.Save(stream: System.IO.Stream, encoder: Imaging.ImageCodecInfo, encoderParams: Imaging.EncoderParameters) : unit
Image.Save(filename: string, encoder: Imaging.ImageCodecInfo, encoderParams: Imaging.EncoderParameters) : unit
namespace System.Drawing.Imaging
Multiple items
type ImageFormat =
new : guid:Guid -> ImageFormat
member Equals : o:obj -> bool
member GetHashCode : unit -> int
member Guid : Guid
member ToString : unit -> string
static member Bmp : ImageFormat
static member Emf : ImageFormat
static member Exif : ImageFormat
static member Gif : ImageFormat
static member Icon : ImageFormat
...
Full name: System.Drawing.Imaging.ImageFormat
--------------------
Imaging.ImageFormat(guid: System.Guid) : unit
property Imaging.ImageFormat.Png: Imaging.ImageFormat
More information