size = { 575, 353 }

defineProperty("pilots_head_x", globalPropertyf("sim/graphics/view/pilots_head_x"))
defineProperty("pilots_head_y", globalPropertyf("sim/graphics/view/pilots_head_y"))
defineProperty("pilots_head_z", globalPropertyf("sim/graphics/view/pilots_head_z"))


defineProperty("dome", globalPropertyf("cl300/dome"))
defineProperty("custom_slider_ratio_4", globalPropertyf("sim/flightmodel2/misc/custom_slider_ratio[4]"))
defineProperty("night_lights", globalPropertyf("sim/graphics/scenery/percent_lights_on"))
defineProperty("p_cush", globalPropertyf("cl300/p_cush"))

defineProperty("headpsi", globalPropertyf("sim/graphics/view/pilots_head_psi"))
defineProperty("headthe", globalPropertyf("sim/graphics/view/pilots_head_the"))

picture = loadImage("cprefl_1.png", 0, 0, 256, 256)
picture2 = loadImage("cprefl_3.png", 0, 0, 256, 256)



scale = 0.20
coeff1 = 0.25

coeff2 = 0.1
brt = 0.35
brt2 = 0.35
view_coeff1 = 0

function draw (all)

if get(headpsi) <= 360 and get(headpsi) >= 180 then
view_coeff1 = (360-get(headpsi))/1500
else
view_coeff1 = - get(headpsi)/1500
end

brt = 0.35*(1.1-get(night_lights)*get(night_lights)) + 0.25*get(dome)*get(night_lights)*get(night_lights)
brt2 = 0.35*(1.1-0) + 0.35*get(dome)*0




if get(custom_slider_ratio_4) > 0.5 and get(p_cush) < 0.5 then picture = loadImage("cprefl_1.png", 0, 0, 256, 256) else picture = loadImage("cprefl_2.png", 0, 0, 256, 256) end

coeff1 = scale - (get(pilots_head_z) + 6.510527)*0.1

--drawRectangle( 464, 7, 85, 78,0,0,0,1)
--drawRectangle( 464, 85, 85, 78,0,0,0,1)

drawTexturePart(picture, 15, 19, 207, 157, 0.2 + (get(pilots_head_y) - 0.902208)*coeff2, 0.61 + (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 1*coeff1, 0.75*coeff1,1,1,1,1*brt)
drawTexturePart(picture, 15, 185, 207, 157, 0.2 + (get(pilots_head_y) - 0.902208)*coeff2, 0.46 + (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 1*coeff1, 0.75*coeff1,1,1,1,1*brt)
drawTexturePart(picture, 235, 19, 207, 157, 0.2 + (get(pilots_head_y) - 0.902208)*coeff2, 0.3 + (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 1*coeff1, 0.75*coeff1,1,1,1,1*brt)
drawTexturePart(picture, 235, 185, 207, 157, 0.2 + (get(pilots_head_y) - 0.902208)*coeff2, 0.1 + (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 1*coeff1, 0.75*coeff1,1,1,1,1*brt)
drawTexturePart(picture, 464, 161, 92, 84, 0.2 + (get(pilots_head_y) - 0.902208)*coeff2, 0.43 + (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 0.25*coeff1, 0.18*coeff1,1,1,1,1*brt)
drawTexturePart(picture, 464, 253, 92, 84, 0.27 + (get(pilots_head_y) - 0.902208)*coeff2, 0.43 + (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 0.25*coeff1, 0.18*coeff1,1,1,1,1*brt)

drawTexturePart(picture2, 464, 7, 85, 78, 0.45 + (get(pilots_head_y) - 0.902208)*coeff2, 0.5+ (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 0.3, 0.3,1,1,1,1.5*brt)
drawTexturePart(picture2, 464, 85, 85, 78, 0.45 + (get(pilots_head_y) - 0.902208)*coeff2, 0.1+ (get(pilots_head_x) + 0.47244)*coeff2 + view_coeff1, 0.3, 0.3,1,1,1,1.5*brt)


end
