summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorOscar Campbell <oscar@campbell.nu>2015-05-31 02:55:06 +0200
committerOscar Campbell <oscar@campbell.nu>2015-05-31 02:55:06 +0200
commit6a43b0e81721919d864ce053e0c0c624ba8c0127 (patch)
tree2cf049fad17c65735705edeed85585133c78b17d /tools
parent49b953533a05c984524daec359dbfb692a692eab (diff)
downloadNim-6a43b0e81721919d864ce053e0c0c624ba8c0127.tar.gz
Clean up to compiler style. Refine error-msg for illegal octal 'O'
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions
-03-27 19:20:59 +0100 committer Araq <rumpf_a@web.de> 2014-03-27 19:20:59 +0100 fixes #1009' href='/ahoang/Nim/commit/tests/vm/trgba.nim?h=devel&id=3365b42bbe5e09f8e8a739597ae5e49e2ff2c259'>3365b42bb ^
93eb9c456 ^
3365b42bb ^
93eb9c456 ^
3365b42bb ^
93eb9c456 ^
3365b42bb ^













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







                               
                             
 



                                               
 
                                             
                  
                                               
                  
                                               
                  
                                               













                                         
discard """
  output: '''[127, 127, 0, 255]
[127, 127, 0, 255]
'''
"""

#bug #1009
type
  TAggRgba8* = array[4, byte]

template R*(self: TAggRgba8): byte = self[0]   
template G*(self: TAggRgba8): byte = self[1]   
template B*(self: TAggRgba8): byte = self[2]   
template A*(self: TAggRgba8): byte = self[3]   

template `R=`*(self: TAggRgba8, val: byte) = 
  self[0] = val   
template `G=`*(self: TAggRgba8, val: byte) =   
  self[1] = val   
template `B=`*(self: TAggRgba8, val: byte) =   
  self[2] = val   
template `A=`*(self: TAggRgba8, val: byte) =   
  self[3] = val   

proc ABGR* (val: int| int64): TAggRgba8 =
  var V = val
  result.R = V and 0xFF
  V = V shr 8
  result.G = V and 0xFF
  V = V shr 8
  result.B = V and 0xFF
  result.A = (V shr 8) and 0xFF

const
  c1 = ABGR(0xFF007F7F) 
echo ABGR(0xFF007F7F).repr, c1.repr