Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Godot 4 #18

Merged
merged 7 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Godot-specific ignores
.godot/
1 change: 0 additions & 1 deletion .import/.gdignore

This file was deleted.

3 changes: 0 additions & 3 deletions .import/big_girl.png-754f0f0d6dfb59be89c1740b6e6efe9c.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_1.png-333deb77b0704b1dbc870fe6e4f196d8.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_2.png-e52a4b06031a6333bc8650eca26e6887.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_3.png-f92bf721b4b95b5069c71ab9cf0e97e6.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_4.png-45edb70c23971c039af04fa5dbdcaaa7.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_5.png-1b451ecea90a7e4d62336b8583907f6d.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_6.png-7aa39a1344e9c61133ab9c2c987834e4.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_7.png-a7ce2ee49deabfbb8fbb016207cd66a6.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/broken_8.png-ed151b82e422ca5d1cb0f94b119f4a5e.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/chocolade.png-133c20be04c5cef3a091e85c330c58d5.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/chocolade.png-95b002e5474e23fb2f510fa0889fea05.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/chocolate.png-71f0b3f21fa72c012e3cf4459c291ed4.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/colors.png-2327716dbe503c2e0dad16b40390b7e6.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/colors.png-40b53df46e367f867ea3e9d1c2b8b622.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/colors2.png-8c88a20c00b5041866a0982896d7c406.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/colors2.png-dba0d2fd2e29a0a51d2be5fe6aa7f787.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/girl.png-65a2715ad34f2d82dbc61833d2fc5569.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/girl.png-fdf04babb7cd69125af1a4b14f3e4fbe.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/green_parrot.jpg-2c63cc95c24f61a7787f3f6b23230869.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/green_parrot.png-a4172bcfb5e0b1167ac302df314da4de.md5

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/img1.png-71f6c0377b53d6fbb4f531fc6329f03d.md5

This file was deleted.

Binary file removed .import/img1.png-71f6c0377b53d6fbb4f531fc6329f03d.stex
Binary file not shown.
3 changes: 0 additions & 3 deletions .import/img1.png-ae8d723bbf84bec16d3d0cb2e66dc0c2.md5

This file was deleted.

Binary file removed .import/img1.png-ae8d723bbf84bec16d3d0cb2e66dc0c2.stex
Binary file not shown.
3 changes: 0 additions & 3 deletions .import/img2.png-662e7b7297d8f6fc6b076fb8b6160649.md5

This file was deleted.

Binary file removed .import/img2.png-662e7b7297d8f6fc6b076fb8b6160649.stex
Binary file not shown.
3 changes: 0 additions & 3 deletions .import/img2.png-d1ec452f22748d50c6e55b472d694282.md5

This file was deleted.

Binary file removed .import/img2.png-d1ec452f22748d50c6e55b472d694282.stex
Binary file not shown.
3 changes: 0 additions & 3 deletions .import/landscape.png-77a0e77a779ae87de91b28123384b598.md5

This file was deleted.

3 changes: 0 additions & 3 deletions .import/one_color.png-6857feb02b3390a8cc51212bdf156415.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/one_color.png-9ff64251a3622c6d771307e8ba2495aa.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/parrot.jpg-c442b2019afa87f273ef0e4ffcebaf5e.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/parrots.png-cd25385047a57cef4638daad6806d9ac.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/transparent.png-3ee13e5156c488fba12a199b2c602700.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/transparent.png-b800a44ccbe42cf4a683bc725add0d51.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/two_colors.png-882920e455db32764176f970b89f83fa.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/two_colors.png-afa35caee370b4d4b30c0ad446ea97de.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/untitled_1.png-3fd40731b8ee5435ce916b3a381b55ca.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/untitled_2.png-9f352c0e0cdbae77623156c028c335f0.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/untitled_3.png-bb03193029d14a8ee13c574a03f90181.md5

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions .import/wallpaper.png-7f01c283c63ae28e54953233a1b76d95.md5

This file was deleted.

Binary file not shown.
44 changes: 16 additions & 28 deletions Main.gd
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
extends Control

const GIFExporter = preload("res://gdgifexporter/exporter.gd")
const MedianCutQuantization = preload("res://gdgifexporter/quantization/median_cut.gd")
const UniformQuantization = preload("res://gdgifexporter/quantization/uniform.gd")
const GIFExporter := preload("res://gdgifexporter/exporter.gd")
const MedianCutQuantization := preload("res://gdgifexporter/quantization/median_cut.gd")
const UniformQuantization := preload("res://gdgifexporter/quantization/uniform.gd")

var img1: Image
var img2: Image
var img3: Image
var img4: Image
var img1: Image = preload("res://imgs/colors2.png").get_image()
var img2: Image = preload("res://imgs/colors.png").get_image()
var img3: Image = preload("res://imgs/one_color.png").get_image()
var img4: Image = preload("res://imgs/half_transparent.png").get_image()

var export_thread: Thread = Thread.new()
var timer: float = 0
var should_count: bool = false
var count_mutex: Mutex = Mutex.new()

var imgs := []
var export_thread := Thread.new()
var timer := 0.0
var should_count := false
var count_mutex := Mutex.new()


func _ready():
img1 = Image.new()
img2 = Image.new()
img3 = Image.new()
img4 = Image.new()
img1.load("res://imgs/colors2.png")
img1.convert(Image.FORMAT_RGBA8)
img2.load("res://imgs/colors.png")
img2.convert(Image.FORMAT_RGBA8)
img3.load("res://imgs/one_color.png")
img3.convert(Image.FORMAT_RGBA8)
img4.load("res://imgs/half_transparent.png")
img4.convert(Image.FORMAT_RGBA8)
var img_texture := ImageTexture.new()
img_texture.create_from_image(img1)
var img_texture := ImageTexture.create_from_image(img1)
$CenterContainer/VBoxContainer/TextureRect.texture = img_texture


Expand All @@ -50,7 +39,7 @@ func export_thread_method(_args: Dictionary):
count_mutex.lock()
should_count = true
count_mutex.unlock()
var exporter = GIFExporter.new(img1.get_width(), img1.get_height())
var exporter := GIFExporter.new(img1.get_width(), img1.get_height())
exporter.add_frame(img1, 1, MedianCutQuantization)
exporter.add_frame(img2, 1, MedianCutQuantization)
exporter.add_frame(img3, 1, MedianCutQuantization)
Expand All @@ -63,15 +52,14 @@ func export_thread_method(_args: Dictionary):
timer = 0
count_mutex.unlock()

var file: File = File.new()
file.open("user://result.gif", File.WRITE)
var file := FileAccess.open("user://result.gif", FileAccess.WRITE)
file.store_buffer(exporter.export_file_data())
file.close()


func _on_Button_pressed():
if not should_count:
if export_thread.is_active():
if export_thread.is_started():
export_thread.wait_to_finish()
export_thread = Thread.new()
export_thread.start(self, "export_thread_method", {})
export_thread.start(export_thread_method.bind({}))
33 changes: 12 additions & 21 deletions Main.tscn
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://babsvfuef2pcq"]

[ext_resource path="res://Main.gd" type="Script" id=1]
[ext_resource type="Script" path="res://Main.gd" id="1"]

[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")

[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 491.0
margin_top = 286.0
margin_right = 532.0
margin_bottom = 314.0
layout_mode = 2
alignment = 1

[node name="Button" type="Button" parent="CenterContainer/VBoxContainer"]
margin_right = 41.0
margin_bottom = 20.0
layout_mode = 2
text = "Start"

[node name="TextureRect" type="TextureRect" parent="CenterContainer/VBoxContainer"]
margin_top = 24.0
margin_right = 41.0
margin_bottom = 24.0
layout_mode = 2

[node name="TextureRect2" type="TextureRect" parent="CenterContainer/VBoxContainer"]
margin_top = 28.0
margin_right = 41.0
margin_bottom = 28.0
layout_mode = 2

[connection signal="pressed" from="CenterContainer/VBoxContainer/Button" to="." method="_on_Button_pressed"]
6 changes: 3 additions & 3 deletions default_env.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[gd_resource type="Environment" load_steps=2 format=3 uid="uid://byyxtyx523h6k"]

[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id="1"]

[resource]
background_mode = 2
background_sky = SubResource( 1 )
sky = SubResource("1")
Loading