Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Swift language does not work (colour)?

import Foundation
func getPixel(_ p: UnsafeMutablePointer<Int>!, atX x: Int, y: Int)
{
   return
}
print(getPixel(_:atX:-925y800))

sorry this isn't a Roblox question (but this is for Roblox, I'm just not using Lua to do it) but I just can't solve this & Im wondering if any of you can. Im trying to get the colour of a pixel at coordinates -925 & 800 using the Swift language, please help me Ive been working on this for hours & nothing works

error: repl.swift:37:21: error: expected ',' separator print(getPixel(_:atX:-925y800)) ^ ,

error: repl.swift:37:21: error: expected expression in list of expressions print(getPixel(_:atX:-925y800)) ^

error: repl.swift:37:26: error: expected a digit after integer literal prefix print(getPixel(_:atX:-925y800))

3 comments

0

I know nothing about "Swift" sorry!

0

You need to use lua.

0

I did use Lua, but Lua was way too slow for what I was trying to do, Swift is much faster but for some reason this is broken

1 answer

✓ Accepted answer

I'm pretty sure that you are looking for the colorAt() function rather then the getPixel() function.

let image = UIImage(named: "Image") //Image goes here
let bitmap = NSBitmapImageRep(ciImage: CIImage(image))
let color = bitmap.colorAt(x: -925, y: 800)

The colorAt() is a member of NSBitmapImageRep and you can initialize one using a ciImage. The colorAt() function returns a NSColor optional and has two int parameters representing the coordinates of the pixel.

1 comment

0

thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.