Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Swift language does not work (colour)?

Asked by
roquick 41
6 years ago
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))

0
I know nothing about "Swift" sorry! SebbyTheGODKid 198 — 6y
0
You need to use lua. uhTeddy 101 — 6y
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 roquick 41 — 6y

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
6 years ago
Edited 6 years ago

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.

0
thank you roquick 41 — 6y
Ad

Answer this question