Skip to content

Instantly share code, notes, and snippets.

@menangen
Created October 9, 2020 16:45
Show Gist options
  • Save menangen/e2a6b5647f8614ce90574ef0d64ed556 to your computer and use it in GitHub Desktop.
Save menangen/e2a6b5647f8614ce90574ef0d64ed556 to your computer and use it in GitHub Desktop.
Context leak detected, msgtracer returned -1
//
// main.swift
// CGImageTest
//
// Created by menangen on 09.10.2020.
//
import Foundation
import SpriteKit
import GameKit
func getTextureImage(_ index: Int, isSky: Bool = true) -> SKTexture {
let colorTable = [
NSColor(red: 0.0, green: 0.15, blue: 0.85, alpha: 1.0),
NSColor(red: 1, green: 1, blue: 1, alpha: 1.0),
NSColor(red: 0.5, green: 0.55, blue: 0.5, alpha: 1.0),
NSColor(red: 0.8, green: 0.85, blue: 0.9, alpha: 1.0)
]
let perlinSource = GKPerlinNoiseSource(
frequency: 1,
octaveCount: 7,
persistence: 0.5,
lacunarity: 2.0,
seed: 123
)
let noise = GKNoise(perlinSource)
noise.gradientColors = [
-1.0: colorTable[isSky ? 0 : 2],
1.0 : colorTable[isSky ? 1 : 3]
]
noise.move(by: vector_double3(Double(index), 0, 0))
let noiseMap = GKNoiseMap(noise,
size: SIMD2(repeating: 1),
origin: SIMD2(repeating: 0.0),
sampleCount: SIMD2(repeating: 16),
seamless: false)
let t = SKTexture(noiseMap: noiseMap)
let i = t.cgImage()
return t
}
for y in 0...64 {
for x in 0...64 {
let t = getTextureImage(x)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment