Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Spatial
- #scene root:
- #----MeshInstance
- #----HSlider (0, 512, step=1_
- #----Camera:
- #--------Direction Light
- func _ready():
- pass
- func get_percent(cur, pmin, pmax):
- var r = 0
- var g = 0
- var x= 0
- if cur >= pmax:
- cur = cur-pmax-pmin
- x = 1
- else:
- cur = cur-pmin
- x = 0
- cur+=1
- if cur > 255:
- cur = 255
- print(cur)
- var percent = int(float(cur)/(float(pmax)/100.0))
- print(percent)
- if percent == 0:
- percent =1
- if x == 1:
- r= 255.0-((float(cur)/100.0)*float(percent))
- g= 255.0
- else:
- r= 255.0
- g= 0.0+((float(cur)/100.0)*float(percent))
- return Color(int(r), int(g), int(0), int(1))
- func change_material(colour):
- var set_material = FixedMaterial.new()
- set_material.set_parameter(set_material.PARAM_DIFFUSE, colour)
- self.get_node("MeshInstance").set("material/0", set_material)
- func _on_HSlider_value_changed( value ):
- var col = get_percent(value, 0, 255)
- change_material(col)
- print(col)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement