Skip to content

Instantly share code, notes, and snippets.

@metaphore
metaphore / gdxtp-downloads.html
Last active October 16, 2021 17:43
Chrome bookmarklet to display latest release download count for https://github.com/crashinvaders/gdx-texture-packer-gui project.
data:text/html,<script>
fetch('https://api.github.com/repos/crashinvaders/gdx-texture-packer-gui/releases').then(response => {
response.text().then(responseText => {
let parsedResponse = JSON.parse(responseText);
let content = parsedResponse[0].assets.map(asset => ({
file: asset.name,
downloads: asset.download_count
}));
let htmlContent = JSON.stringify(content, null, 4);
alert(htmlContent);
@metaphore
metaphore / HqnxEffect.java
Last active September 7, 2023 10:05
[libGDX] HQX (HQ2X, HQ3X, HQ4X) upscaling filter implementation (Java and Kotlin) using GLSL shaders.
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.GdxRuntimeException;
/**
@metaphore
metaphore / PhotoshopToSpine.jsx
Last active February 11, 2020 09:22
EsotericSoftware Spine photoshop export script with parallax layers.
#target photoshop
app.bringToFront();
// This script exports Adobe Photoshop layers as individual PNGs. It also
// writes a JSON file which can be imported into Spine where the images
// will be displayed in the same positions and draw order.
// Copyright (c) 2012-2017, Esoteric Software
// All rights reserved.
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@metaphore
metaphore / PhotoshopToSpine.jsx
Created October 22, 2019 06:01
EsotericSoftware Spine photoshop export script with parallax layers.
#target photoshop
app.bringToFront();
// This script exports Adobe Photoshop layers as individual PNGs. It also
// writes a JSON file which can be imported into Spine where the images
// will be displayed in the same positions and draw order.
// Copyright (c) 2012-2017, Esoteric Software
// All rights reserved.
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@metaphore
metaphore / ShaderAlphaTest.java
Created September 24, 2019 13:15
GDX VFX transparency rendering test
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
@metaphore
metaphore / StringRender.java
Created October 29, 2017 19:19
BitmapFont string render to an image file.
BitmapFont font = interfaceService.getSkin().getFont("default-font");
GlyphLayout glyphLayout = new GlyphLayout(font, getString("langZhTw"));
final int w = MathUtils.ceil(glyphLayout.width + 2f);
final int h = MathUtils.ceil(glyphLayout.height + 2f);
OrthographicCamera cam = new OrthographicCamera(w, h);
cam.setToOrtho(false, w, h);
cam.update();
@metaphore
metaphore / corona-imagesheet.lua
Created September 8, 2016 16:08
Old corona image sheet format exporter for TexturePackerGUI
--
-- created with TexturePacker (http://www.codeandweb.com/texturepacker)
--
-- {{smartUpdateKey}}
--
-- local sheetInfo = require("mysheet")
-- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() )
-- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} )
--
@metaphore
metaphore / RenameLayers.jsx
Last active May 10, 2020 13:25
Simple Photoshop script that renames selected layers
#target photoshop
function main() {
if (app.activeDocument == null) {
alert("You should open some document to execute that script" + selectedLayers.length);
return;
}
selectedLayers = getSelectedLayers();
if (selectedLayers.length == 0) {
@metaphore
metaphore / FadeWidget.java
Last active December 10, 2015 20:20
[LibGDX] Actor for fade in/out effect
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
@metaphore
metaphore / RoundCornerFrameLayout.java
Created December 9, 2015 18:32
[Android] Frame layout with rounded corners
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* Frame layout that has rounded corners (it clips content too).