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

feat: optimize assets #10

Merged
merged 4 commits into from
Oct 26, 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
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store

tmp.*
.env

Expand Down
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"

[dependencies]
starknet = "2.1.1"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts", rev = "05429e4" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts", rev = "v0.7.0" }

[scripts]
test = "scarb cairo-test"
Expand Down
Binary file modified assets/.DS_Store
Binary file not shown.
Binary file added assets/kam_compressed_102523/t1_balrog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t1_dragon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t1_griffin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t1_jiansgshi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t1_juggernaut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t1_manticore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t1_minotaur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_chimera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_chupacabra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_hydra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_juggernaut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_lich.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_nephilim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_nue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t2_qilin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_banshee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_cyclops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_giant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_harpy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_vampire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_weretiger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_werewolf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t3_wyvern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t4_direwolf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t4_fenrir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/kam_compressed_102523/t4_ghoul.png
Binary file added assets/kam_compressed_102523/t4_goblin.png
Binary file added assets/kam_compressed_102523/t4_golem.png
Binary file added assets/kam_compressed_102523/t4_hippogriff.png
Binary file added assets/kam_compressed_102523/t4_jaguar.png
Binary file added assets/kam_compressed_102523/t4_kappa.png
Binary file added assets/kam_compressed_102523/t4_sprite.png
Binary file added assets/kam_compressed_102523/t4_wraith.png
Binary file added assets/kam_compressed_102523/t5_bear.png
Binary file added assets/kam_compressed_102523/t5_fairy.png
Binary file added assets/kam_compressed_102523/t5_kelpie.png
Binary file added assets/kam_compressed_102523/t5_pixie.png
Binary file added assets/kam_compressed_102523/t5_rat.png
Binary file added assets/kam_compressed_102523/t5_skeleton.png
Binary file added assets/kam_compressed_102523/t5_wolf.png
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
17 changes: 7 additions & 10 deletions scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,27 @@ def hex_to_felt(val):
def prep_art():
# header = '<svg id="leetart" width="100%" height="100%" viewBox="0 0 20000 20000" xmlns="http://www.w3.org/2000/svg"><style>#leetart{background-image:url('
# footer = ");background-repeat:no-repeat;background-size:contain;background-position:center;image-rendering:-webkit-optimize-contrast;-ms-interpolation-mode:nearest-neighbor;image-rendering:-moz-crisp-edges;image-rendering:pixelated;}</style></svg>"
assets_dir = "./assets"
assets_dir = "./assets/kam_compressed_102523"
for fn in os.listdir(assets_dir):
if not fn.startswith("t"):
continue

with open(f"{assets_dir}/{fn}", "rb") as f:
content = base64.b64encode(f.read()).decode(encoding="utf-8")
name = fn.split(".png")[0].split("_")[1].upper()
name = fn.split(".png")[0].split("_")[1]
to_cairo(name, content)


def to_cairo(name, content):
print(f"else if beast == {name}")
print("{")
print("#[inline(always)]")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this update

print("fn get_" + name + "_svg() -> LongString {")
print(" let mut content = ArrayTrait::<felt252>::new();")
for c in str_to_array(content):
print(f" content.append('{c}');")

print(" content.into()")
print("}")


if __name__ == "__main__":
prep_art()
print(
str_to_array(
'data:image/svg+xml;utf8,<svg%20width="100%"%20height="100%"%20viewBox="0%200%2020000%2020000"%20xmlns="http://www.w3.org/2000/svg"><style>svg{background-image:url(data:image/png;base64,'
)
)
prep_art()
1,200 changes: 538 additions & 662 deletions src/beast.cairo

Large diffs are not rendered by default.