| 1 |
import wx |
|---|
| 2 |
import dc |
|---|
| 3 |
import gui |
|---|
| 4 |
|
|---|
| 5 |
def draw_ruler( image, glossy=False ): |
|---|
| 6 |
"Draw a ruler of length 200nm onto the image" |
|---|
| 7 |
if not image.IsSpatial(): |
|---|
| 8 |
return False |
|---|
| 9 |
sampling = image.GetSpatialSampling() |
|---|
| 10 |
im_size = 2000/sampling[0] |
|---|
| 11 |
bmp = wx.EmptyBitmap(im_size,20) |
|---|
| 12 |
the_dc = wx.MemoryDC( bmp ) |
|---|
| 13 |
the_dc.SetPen( wx.Pen(wx.Colour(0,0,0,0),0,wx.TRANSPARENT) ) |
|---|
| 14 |
brushes = [ wx.Brush( wx.Colour( 30, 30, 30 ), wx.SOLID ), |
|---|
| 15 |
wx.Brush( wx.Colour( 200, 200, 200 ), wx.SOLID ) ] |
|---|
| 16 |
|
|---|
| 17 |
for i in range(0,5): |
|---|
| 18 |
the_dc.SetBrush( brushes[ i % 2 ] ) |
|---|
| 19 |
the_dc.DrawRectangle( i*im_size/5, 0, 50, 20 ) |
|---|
| 20 |
if ( glossy ): |
|---|
| 21 |
the_dc.SetBrush(wx.Brush(wx.Colour(255,255,255,30))) |
|---|
| 22 |
the_dc.DrawEllipse( -50, -10, im_size+100, 20 ) |
|---|
| 23 |
wi = bmp.ConvertToImage() |
|---|
| 24 |
dc.Blit( wi, im, Point( ( int(image.GetSize().GetWidth()-im_size )/2), 10 ) ) |
|---|
| 25 |
return True |
|---|
| 26 |
|
|---|
| 27 |
the_bm = wx.EmptyBitmap(200,20,depth=32) |
|---|
| 28 |
im = CreateImage( Size( 400, 400 ) ) |
|---|
| 29 |
im.SetSpatialSampling( Vec3( 10, 10, 1 )) |
|---|
| 30 |
im.ApplyIP( alg.Randomize() ) |
|---|
| 31 |
draw_ruler( im ) |
|---|
| 32 |
|
|---|
| 33 |
v = Viewer( im ) |
|---|