Skip to content

Instantly share code, notes, and snippets.

View kunofellasleep's full-sized avatar

Kuno Fell Asleep kunofellasleep

View GitHub Profile
@kunofellasleep
kunofellasleep / AppleShowAllFiles.sh
Last active April 15, 2019 05:23
不可視ファイル表示
defaults write com.apple.finder AppleShowAllFiles -boolean true
killAll Finder
@kunofellasleep
kunofellasleep / adb install overwrite
Created March 20, 2019 07:00
apk上書きインストール
adb install -r /Users/path/is/here/app.apk
@kunofellasleep
kunofellasleep / keystore gen
Created March 20, 2019 06:55
keystore gen
keytool -genkey -v -keyalg RSA -keystore /Users/kuno/path/is/here/[name].keystore -alias [appname] -validity 10000
@kunofellasleep
kunofellasleep / InstaStories.swift
Created February 27, 2019 08:14
Share on Instagram stories
import UIKit
class InstaStories: NSObject {
private let urlScheme = URL(string: "instagram-stories://share")!
enum optionsKey: String {
case StickerImage = "com.instagram.sharedSticker.stickerImage"
case bgImage = "com.instagram.sharedSticker.backgroundImage"
case bgVideo = "com.instagram.sharedSticker.backgroundVideo"
kernel void blendAdd(
texture2d<float, access::write> outTex [[texture(0)]],
texture2d<float, access::read> inTex [[texture(1)]],
texture2d<float, access::read> inTex2 [[texture(2)]],
uint2 gid [[thread_position_in_grid]]) {
float4 c = inTex.read(gid).rgba;
float4 add = inTex2.read(gid).rgba;
c.rgb += add.rgb;
outTex.write(c.rgba, gid);
}
kernel void saturation(
texture2d<float, access::write> outTex [[texture(0)]],
texture2d<float, access::read> inTex [[texture(1)]],
uint2 gid [[thread_position_in_grid]]) {
//HIGH: More than 1, LOW: Less than 1
float filterLevel = 1.1;
float4 c = inTex.read(gid).rgba;
float3 hsv = rgb2hsv(c.rgb);
hsv[1] = hsv[1] * filterLevel;
c.rgb = hsv2rgb(hsv);
kernel void contrast(
texture2d<float, access::write> outTex [[texture(0)]],
texture2d<float, access::read> inTex [[texture(1)]],
uint2 gid [[thread_position_in_grid]]) {
//HIGH: More than 1, LOW: Less than 1
float filterLevel = 1.2;
float4 c = inTex.read(gid).rgba;
c = float4((c.rgb - float3(0.5)) * filterLevel + float3(0.5), 1.0);
outTex.write(c.rgba, gid);
}
kernel void chromaticAberration(
texture2d<float, access::write> outTex [[texture(0)]],
texture2d<float, access::read> inTex [[texture(1)]],
uint2 gid [[thread_position_in_grid]]) {
float filterLevel = 3.5;
float4 c = float4(0.0, 0.0, 0.0, 1.0);
//収差に使用するレイヤーの色味
float3 weight[4] = {
float3(0.0f, 0.0f, 0.5f),
float3(0.0f, 0.5f, 0.5f),
kernel void sharpen(
texture2d<float, access::write> outTex [[texture(0)]],
texture2d<float, access::read> inTex [[texture(1)]],
uint2 gid [[thread_position_in_grid]]) {
float4 c = float4(0.0, 0.0, 0.0, 1.0);
//隣接ピクセルを使用して色を決定するためのパラメータ
float weight[3][3] = {
{0, -1, 0},
{-1, 5, -1},
{0, -1, 0}
import Metal
import MetalKit
class ImageProcessor: NSObject {
//ハードウェアとしてのGPUを抽象化したプロトコル
lazy var device: MTLDevice! = MTLCreateSystemDefaultDevice()
//コマンドバッファの実行順を管理するキュー
var commandQueue: MTLCommandQueue!