4 people like it.
Like the snippet!
F# logo generator
A simple way to render the F# logo with integer scaling to avoid aliasing
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
|
#if INTERACTIVE
#r "System.Drawing.dll"
#endif
open System.Drawing
let drawRect (xPos,yPos,height,direction,col) scale (bm:Bitmap) =
let rec loop x y d i =
for z = min (xPos*scale) x to (max (xPos*scale) x) - 1 do
bm.SetPixel(z,y,Color.FromArgb(col))
if i = 0 then bm
elif i = ((height*scale) / 2) + 1
then loop (x + d) (y + 1) (0 - d) (i - 1)
else loop (x + d) (y + 1) d (i - 1)
loop (xPos*scale) (yPos*scale) direction (height*scale)
let scale = 18
let size = 29 * scale
let back,dark,light = 0x0,0xff378bba,0xff30b9db
let image =
[(14,0,28,-1,dark);(14,7,14,-1,back);(14,9,10,-1,dark);(15,0,28,1,light);(15,7,14,1,back)]
|> List.fold (fun bm c -> drawRect c scale bm) (new Bitmap(size, size))
image.Save("fslogo.png", Imaging.ImageFormat.Png)
|
namespace System
namespace System.Drawing
val drawRect : xPos:int * yPos:int * height:int * direction:int * col:int -> scale:int -> bm:Bitmap -> Bitmap
Full name: Script.drawRect
val xPos : int
val yPos : int
val height : int
val direction : int
val col : int
val scale : int
val bm : Bitmap
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)
val loop : (int -> int -> int -> int -> Bitmap)
val x : int
val y : int
val d : int
val i : int
val z : int
val min : e1:'T -> e2:'T -> 'T (requires comparison)
Full name: Microsoft.FSharp.Core.Operators.min
val max : e1:'T -> e2:'T -> 'T (requires comparison)
Full name: Microsoft.FSharp.Core.Operators.max
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
Color.FromArgb(argb: int) : Color
Color.FromArgb(alpha: int, baseColor: Color) : Color
Color.FromArgb(red: int, green: int, blue: int) : Color
Color.FromArgb(alpha: int, red: int, green: int, blue: int) : Color
val scale : int
Full name: Script.scale
val size : int
Full name: Script.size
val back : int
Full name: Script.back
val dark : int
Full name: Script.dark
val light : int
Full name: Script.light
val image : Bitmap
Full name: Script.image
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State
Full name: Microsoft.FSharp.Collections.List.fold
val c : int * int * int * int * int
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