working plant builder but not seeds oupsi
This commit is contained in:
@@ -5,7 +5,7 @@ const IMAGE_HEIGHT := 2048
|
||||
|
||||
const SEED_TEXTURE_SIZE = 150
|
||||
|
||||
const COLOR_PALETTE : Array[Color] = [
|
||||
const COLOR_PALETTE: Array[Color] = [
|
||||
Color("#78AEBA"),
|
||||
Color("#A7B35B"),
|
||||
Color("#DB6B75"),
|
||||
@@ -75,25 +75,21 @@ func shuffle_weighted(array: Array, weights: Array[int]):
|
||||
func build_seed_texture(random_seed: int) -> Texture:
|
||||
rng.seed = random_seed
|
||||
|
||||
var texture_set : SeedTextureSet = pick_random(seed_texture_sets)
|
||||
var sedd_image := Image.create(SEED_TEXTURE_SIZE,SEED_TEXTURE_SIZE, false, Image.FORMAT_RGBA8)
|
||||
var texture_set: SeedTextureSet = pick_random(seed_texture_sets)
|
||||
var seed_image := Image.create(SEED_TEXTURE_SIZE, SEED_TEXTURE_SIZE, false, Image.FORMAT_RGBA8)
|
||||
|
||||
for color_texture in texture_set.color_textures:
|
||||
var color_image = color_texture.get_image().duplicate()
|
||||
color_image.resize(SEED_TEXTURE_SIZE,SEED_TEXTURE_SIZE)
|
||||
for color_image in texture_set.color_images:
|
||||
color_image.resize(SEED_TEXTURE_SIZE, SEED_TEXTURE_SIZE)
|
||||
modulate_image(color_image, pick_random(COLOR_PALETTE))
|
||||
sedd_image.blend_rect(
|
||||
color_image,
|
||||
Rect2i(0,0,SEED_TEXTURE_SIZE,SEED_TEXTURE_SIZE),
|
||||
Vector2i.ZERO
|
||||
)
|
||||
if texture_set.outline_texture:
|
||||
var outline_image = texture_set.outline_texture.get_image().duplicate()
|
||||
outline_image.resize(SEED_TEXTURE_SIZE,SEED_TEXTURE_SIZE)
|
||||
sedd_image.blend_rect(outline_image, Rect2i(0,0,SEED_TEXTURE_SIZE,SEED_TEXTURE_SIZE),Vector2i.ZERO)
|
||||
seed_image.blend_rect(color_image, Rect2i(0, 0, SEED_TEXTURE_SIZE, SEED_TEXTURE_SIZE), Vector2i.ZERO)
|
||||
|
||||
if texture_set.outline_image:
|
||||
var outline_image = texture_set.outline_image
|
||||
outline_image.resize(SEED_TEXTURE_SIZE, SEED_TEXTURE_SIZE)
|
||||
seed_image.blend_rect(outline_image, Rect2i(0, 0, SEED_TEXTURE_SIZE, SEED_TEXTURE_SIZE), Vector2i.ZERO)
|
||||
|
||||
if rng.randi()%2 == 0:
|
||||
sedd_image.flip_x()
|
||||
if rng.randi() % 2 == 0:
|
||||
seed_image.flip_x()
|
||||
|
||||
return ImageTexture.create_from_image(image)
|
||||
|
||||
@@ -125,7 +121,7 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
parts_to_place[OriginType.MUTATION_ORIGIN].append(parts_mutation_associations[mutation.id].parts)
|
||||
mutation_weights.append(mutation_weight_base)
|
||||
|
||||
var base_image_coord = blend_part(image_center, Vector2.ZERO, base_part)
|
||||
var base_image_coord = blend_part(image_center, -base_part.root.position, base_part)
|
||||
populate_part(parts_to_place, weight_per_origin_type, mutation_weights, base_part, base_image_coord)
|
||||
|
||||
texture = ImageTexture.create_from_image(image)
|
||||
@@ -202,7 +198,7 @@ func blend_part(parent_image_coord: Vector2i, attach_position: Vector2, part_to_
|
||||
image.blend_rect(part_image, Rect2i(Vector2i.ZERO, part_to_blend.image.get_size()), part_image_coord - part_image_center)
|
||||
return part_image_coord
|
||||
|
||||
func modulate_image(i : Image, color : Color):
|
||||
func modulate_image(i: Image, color: Color):
|
||||
for x in i.get_size().x:
|
||||
for y in i.get_size().y:
|
||||
i.set_pixel(x,y, i.get_pixel(x,y)*color)
|
||||
i.set_pixel(x, y, i.get_pixel(x, y) * color)
|
||||
|
||||
Reference in New Issue
Block a user