updated to Swift 4

This commit is contained in:
Marius Horga 2017-10-03 12:55:38 -05:00
parent 1b040d7fb2
commit bc61d4f939
4 changed files with 6 additions and 10 deletions

View File

@ -2,7 +2,7 @@
import MetalKit import MetalKit
import PlaygroundSupport import PlaygroundSupport
let frame = NSRect(x: 0, y: 0, width: 400, height: 400) let frame = NSRect(x: 0, y: 0, width: 400, height: 800)
let delegate = MetalView() let delegate = MetalView()
let view = MTKView(frame: frame, device: delegate.device) let view = MTKView(frame: frame, device: delegate.device)
view.delegate = delegate view.delegate = delegate

View File

@ -14,10 +14,12 @@ float distanceToParticle(float2 point, Particle p) {
kernel void compute(texture2d<float, access::write> output [[texture(0)]], kernel void compute(texture2d<float, access::write> output [[texture(0)]],
constant float &time [[buffer(0)]], constant float &time [[buffer(0)]],
uint2 gid [[thread_position_in_grid]]) { uint2 gid [[thread_position_in_grid]]) {
int width = output.get_width(); float width = output.get_width();
int height = output.get_height(); float height = output.get_height();
float2 uv = float2(gid) / float2(width, height); float2 uv = float2(gid) / float2(width, height);
float2 center = float2(0.5, time); float aspect = width / height;
uv.x *= aspect;
float2 center = float2(aspect / 2, time);
float radius = 0.05; float radius = 0.05;
float stop = 1 - radius; float stop = 1 - radius;
if (time >= stop) { center.y = stop; } if (time >= stop) { center.y = stop; }

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>