PixelKit Reference


pod 'PixelKit'
import PixelKit
let finalPix: PIX = pix
finalPix.view.frame = view.bounds
view.addSubview(finalPix.view)

Resource PIXs

let camera = CameraPIX()
camera.camera = .front
camera.camRes = ._1080p
camera.manualExposure = true
camera.iso = 320
let image = ImagePIX()
image.image = UIImage("image-name")
let video = VideoPIX()
video.load(fileNamed: "video-name",
           withExtension: "mov")
video.play()
video.pause()
video.reset()
video.restart()
video.volume = 0.5
video.loops = true
video.rate = 2.0
// macOS only
let screenCapture = ScreenCapturePIX()
// iOS only
let streamIn = StreamInPIX()

Generator PIXs

let color = ColorPIX(res: ._1080p)
color.color = LiveColor(r: 1.0, g: 0.5,
                        b: 0.0, a: 1.0)
let circle = CirclePIX(res: ._1080p)
circle.radius = 0.5
circle.position = .touchXY
let rect = RectanglePIX(res: ._1080p)
rect.size = LiveSize(w: 0.5, h: 0.5)
rect.cornerRadius = 0.1
let polygon = PolygonPIX(res: ._1080p)
polygon.vertexCount = 6
polygon.cornerRadius = 0.1
let arc = ArcPIX(res: ._1080p)
arc.angleFrom = -0.5
arc.angleTo = 0.5
let line = LinePIX(res: ._1080p)
line.positionTo = LivePoint(x: 0.25,
                            y: 0.25)
let noise = NoisePIX(res: ._1080p)
noise.octaves = 7
noise.zPosition = .live
let ramp = GradientPIX(res: ._1080p)
ramp.direction = .vertical
ramp.colorSteps = [
    ColorStep(step: 0.0, color: .black),
    ColorStep(step: 1.0, color: .white)
]
let text = TextPIX(res: ._1080p)
text.text = "Lorem Ipsum"
let metal = MetalPIX(res: ._1080p, code:
    """
    pix = float4(u, v, 0.0, 1.0);
    """
)

Effect PIXs

let levels = LevelsPIX()
levels.inPix = pix
levels.brightness = 2.0
levels.darkness = 0.5
levels.contrast = 0.5
levels.gamma = 0.5
levels.inverted = true
levels.opacity = 0.5
let res = ResPIX(res: ._1080p)
res.inPix = pix
res.placement = .aspectFill
let blur = BlurPIX()
blur.inPix = pix
blur.style = .guassion
blur.radius = 0.5
let edge = EdgePIX()
edge.inPix = pix
edge.strength = 2.0
let threshold = ThresholdPIX()
threshold.inPix = pix
threshold.threshold = 0.5
let quantize = QuantizePIX()
quantize.inPix = pix
quantize.fraction = 0.125
let transform = TransformPIX()
transform.inPix = pix
transform.position = .touchXY
transform.rotation = .live
transform.scale = 0.5
let kaleidoscope = KaleidoscopePIX()
kaleidoscope.inPix = pix
kaleidoscope.divisions = 12
kaleidoscope.mirror = true
kaleidoscope.rotation = .live
let twirl = TwirlPIX()
twirl.inPix = pix
twirl.strength = 0.5
let feedback = FeedbackPIX()
feedback.inPix = pix
feedback.feedPix = pix
let channelMix = ChannelMixPIX()
channelMix.inPix = pix
channelMix.red = .red
channelMix.green = .green
channelMix.blue = .blue
channelMix.alpha = .alpha
let chromaKey = ChromaKeyPIX()
chromaKey.inPix = pix
chromaKey.keyColor = .green
let cornerPin = CornerPinPIX()
cornerPin.inPix = pix
cornerPin.corners.topLeft =
    CGPoint(x: 0.0, y: 1.0)
cornerPin.corners.topRight =
    CGPoint(x: 1.0, y: 1.0)
cornerPin.corners.bottomLeft =
    CGPoint(x: 0.0, y: 0.0)
cornerPin.corners.bottomRight =
    CGPoint(x: 1.0, y: 0.0)
let hueSat = HueSatPIX()
hueSat.inPix = pix
hueSat.hue = 0.5
hueSat.sat = 0.5
let crop = CropPIX()
crop.inPix = pix
crop.cropFrame = CGRect(x: 0.0,
                        y: 0.0,
                        width: 1.0,
                        height: 1.0)
let flipFlop = FlipFlopPIX()
flipFlop.inPix = pix
flipFlop.flip = .x
flipFlop.flop = .left
let range = RangePIX()
range.inPix = pix
range.inLow = 0.1
range.inHigh = 0.9
let sharpen = SharpenPIX()
sharpen.inPix = pix
sharpen.contrast = 2.0
let slope = SlopePIX()
slope.inPix = pix
slope.amplitude = 2.0
let sepia = SepiaPIX()
sepia.inPix = pix
sepia.color = .orange
let flare = FlarePIX()
flare.inPix = pix
flare.scale = 0.5
flare.count = 3
let clamp = ClampPIX()
clamp.inPix = pix
clamp.low = 0.0
clamp.high = 1.0
let convert = ConvertPIX()
convert.inPix = pix
convert.mode = .squareToCircle
let delay = DelayPIX()
delay.inPix = pix
delay.delayFrames = 60
let freeze = FreezePIX()
freeze.inPix = pix
freeze.freeze = true
let metal = MetalEffectPIX(res: ._1080p,
    code:
    """
    float gamma = 0.25;
    pix = pow(inPix, 1.0 / gamma);
    """
)
metal.inPix = pix

Merger Effect PIXs

let cross = CrossPIX()
cross.inPixA = pixA
cross.inPixB = pixB
cross.fraction = 0.5
let blend = BlendPIX()
blend.inPixA = pixA
blend.inPixB = pixB
blend.blendMode = .multiply
let displace = DisplacePIX()
displace.inPixA = pixA
displace.inPixB = pixB
displace.distance = 0.5
let lookup = LookupPIX()
lookup.inPixA = pixA
lookup.inPixB = pixB
lookup.axis = .x
let lumaLevels = LumaLevelsPIX()
lumaLevels.inPixA = pixA
lumaLevels.inPixB = pixB
lumaLevels.brightness = 2.0
lumaLevels.darkness = 0.5
lumaLevels.contrast = 0.5
lumaLevels.gamma = 0.5
lumaLevels.opacity = 0.5
let lumaBlur = LumaBlurPIX()
lumaBlur.inPixA = pixA
lumaBlur.inPixB = pixB
lumaBlur.style = .box
lumaBlur.radius = 0.5
let remap = RemapPIX()
remap.inPixA = pixA
remap.inPixB = pixB
let reorder = ReorderPIX()
reorder.inPixA = pixA
reorder.inPixB = pixB
reorder.redInput = .a
reorder.redChannel = .red
reorder.greenInput = .a
reorder.greenChannel = .green
reorder.blueInput = .b
reorder.blueChannel = .blue
reorder.alphaInput = .b
reorder.alphaChannel = .alpha
let timeMachine = TimeMachinePIX()
timeMachine.inPixA = pixA
timeMachine.inPixB = pixB
timeMachine.seconds = 2.0
let metal = MetalMergerEffectPIX(
    res: ._1080p,
    code:
    """
    pix = pow(inPixA, 1.0 / inPixB);
    """
)
metal.inPixA = pixA
metal.inPixB = pixB

Multi Effect PIXs

let blends = BlendsPIX()
blends.inPixs = [pixA, pixB, pixC]
blends.blendMode = .add
let array = ArrayPIX()
array.inPixs = [pixA, pixB, pixC]
array.buildGrid(xCount: 10,
                xRange: -0.5...0.5,
                yCount: 10,
                yRange: -0.5...0.5)
array.buildHexagonalGrid(scale: 0.4)
array.buildCircle(count: 12,
                  scale: 0.5)
array.buildLine(count: 10,
                from: LivePoint(x: -0.5,
                                y: -0.5),
                to: LivePoint(x: 0.5,
                              y: 0.5))
array.buildRandom(count: 100)
let metal = MetalMultiEffectPIX(
    res: ._1080p,
    code:
    """
    float4 a = inTexs.sample(s, uv, 0);
    float4 b = inTexs.sample(s, uv, 1);
    float4 c = inTexs.sample(s, uv, 2);
    pix = a + b + c;
    """
)
metal.inPixs = [pixA, pixB, pixC]

Output PIXs

// iOS only
let airPlay = AirPlayPIX()
airPlay.inPix = pix
let rec = RecPIX()
rec.inPix = pix
rec.startRec()
rec.pauseRec()
rec.stopRec({ url in })
// iOS only
let streamOut = StreamOutPIX()
streamOut.inPix = pix
streamOut.quality = 0.5
streamOut.connect()

Docs