mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-15 02:01:09 +01:00
IChing node.
This commit is contained in:
parent
a186c71f9a
commit
6ea422c166
40
game/addons/mat_maker_gd/nodes/pattern/iching.gd
Normal file
40
game/addons/mat_maker_gd/nodes/pattern/iching.gd
Normal file
@ -0,0 +1,40 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Vector2) var size : Vector2 = Vector2(4, 4)
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#IChing(vec2($columns, $rows)*$uv, float($seed))
|
||||
return Patterns.IChingc(uv, size, ps)
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
@ -1,66 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
var image : Image
|
||||
var tex : ImageTexture
|
||||
|
||||
export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1)
|
||||
export(Vector2) var bmax : Vector2 = Vector2(1, 1)
|
||||
|
||||
export(bool) var refresh setget reff,reffg
|
||||
|
||||
func _ready():
|
||||
if !Engine.editor_hint:
|
||||
gen()
|
||||
|
||||
|
||||
func gen() -> void:
|
||||
if !image:
|
||||
image = Image.new()
|
||||
image.create(300, 300, false, Image.FORMAT_RGBA8)
|
||||
|
||||
if !tex:
|
||||
tex = ImageTexture.new()
|
||||
|
||||
# var bmin : Vector2 = Vector2(0.1, 0.1)
|
||||
# var bmax : Vector2 = Vector2(1, 1)
|
||||
|
||||
image.lock()
|
||||
|
||||
var w : float = image.get_width()
|
||||
var h : float = image.get_width()
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE)
|
||||
|
||||
var col : Color = IChingc(v)
|
||||
|
||||
image.set_pixel(x, y, col)
|
||||
|
||||
|
||||
image.unlock()
|
||||
|
||||
tex.create_from_image(image)
|
||||
# texture = tex
|
||||
|
||||
var seed_o57193 = 16936;
|
||||
var p_o57193_columns = 2.000000000;
|
||||
var p_o57193_rows = 2.000000000;
|
||||
|
||||
func IChingc(uv : Vector2) -> Color:
|
||||
return Patterns.IChingc(uv, Vector2(p_o57193_columns, p_o57193_rows), float(seed_o57193));
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
||||
func reff(bb):
|
||||
if bb:
|
||||
gen()
|
||||
|
Loading…
Reference in New Issue
Block a user