Bitmap/AutoHotkey: Difference between revisions

From Rosetta Code
Content added Content deleted
m (moved Basic bitmap storage/AutoHotkey to Bitmap/AutoHotkey: To reflect the parent page's new title.)
mNo edit summary
Line 1: Line 1:
{{collection|Basic bitmap storage}}
{{collection|Basic bitmap storage}}
{{works with|AutoHotkey|L45}}
{{works with|AutoHotkey_L|45}}
<lang AutoHotkey>test:
<lang AutoHotkey>test:
blue := color(0,0,255) ; rgb
blue := color(0,0,255) ; rgb

Revision as of 01:39, 9 February 2010

Bitmap/AutoHotkey is part of Basic bitmap storage. You may find other members of Basic bitmap storage at Category:Basic bitmap storage.
Works with: AutoHotkey_L version 45

<lang AutoHotkey>test: blue := color(0,0,255)  ; rgb cyan := color(0,255,255) MsgBox % "blue:r,g,b,rgb " blue.R "," blue.G "," blue.B ", " blue.rgb() MsgBox % "cyan:r,g,b,rgb " cyan.R "," cyan.G "," cyan.B ", " cyan.RGB() blue_square := Bitmap(10, 10, blue) x := blue_square[4,4] ; get pixel(4,4) msgbox % "blue: 4,4,R,G,B, RGB: " x.R ", " x.G ", " x.B ", " x.rgb() blue_square[4,4] := cyan ; set pixel(4,4) x := blue_square[4,4] ; get pixel(4,4) msgbox % "cyan: 4,4,R,G,B, RGB: " x.R ", " x.G ", " x.B ", " x.rgb() return

Bitmap(width = 1, height = 1, background = 0) { global black black := color(0,0,0) if !background background := black

   static BitmapType
   if !BitmapType
       BitmapType
       := Object("fill", "Bitmap_Fill")

img := Object("width", width

               ,"height", height
               , "base"    , BitmapType)

img._SetCapacity(width * height)

 img.fill(background)

Return img }


Bitmap_Fill(bitmap, color) {

 loop % bitmap.height
 {
   height := A_Index
   loop % bitmap.width
   {
     width := A_Index
     bitmap[height, width] := color
   }
 }
return bitmap

}


Color(r, g, b) {

   static ColorType
   if !ColorType
       ColorType
       := Object("rgb"   , "Color_rgb")
   return Object("r" , r, "g", g, "b", b
               , "base"    , ColorType)
; return Object("r" , r, "g", g, "b", b, "rgb", "Color_rgb")

}

Color_rgb(clr) { return clr.R << 16 | clr.G << 8 | clr.B }

!r::reload !q::exitapp</lang>