There’s an undocumented feature in the current version of Codea.

It’s not documented because it hasn’t gone through testing. You can test it out now.

touch objects now have two extra fields: `radius` and `radiusTolerance`. This represents a very rough approximation of the radius of a touch based on how much of your finger is covering the screen.

The below example exaggerates the effect by multiplying the radius by two. If you roll your finger across the screen you should see the ellipse change size.

`radiusTolerance` represents the estimated accuracy of the `radius`. So the minimum radius is `radius - radiusTolerance` and the max is `radius + radiusTolerance`.

``````function setup()
end

function draw()
background(40, 40, 50)

strokeWidth(5)

end
``````

Note: This feature is iOS 8 only, if you are on iOS 7 then you will see a radius and radiusTolerance of `0`.

Any ideas for what this could be used for?

More sensitive/accurate buttons, perhaps?

Painting apps

or a piano app, where velocity would be related to the radius?

That code does not work for me (on ios8, latest release). It gives me incredibly small values, 1.7*(10^-189) is the average value Im getting. And that value is AFTER i had to use math.abs() on the numbers, because i was also getting super tiny negative numbers. Then i multiplied the radii by 10^190 and was getting ellipse sizes that were completely random, and not related to how much screen coverage i got. Interestingly enough, a bit later i was getting touch radii equal to -inf and inf.

EDIT: also, after the touch begins, it doesnt seem that the ellipse ever changes sizes

EDIT2: I decided to test the radius tolerance and it is a drastically larger number but still very small. Im getting about 1.3*(10^-133) on average for it, which is about 10^54 larger than the radius itself.

I took the above code and it works fine for me, iOS 8.3 and latest beta. When I print CurrentTouch.radius, I get 2 values depending on how hard I press. A light touch gives 20.890265 and a harder touch gives 31.34375.

EDIT: I show a radiusTolerance of 5.21875 .

We should have a fat finger contest :))

@Ignatz - I was thinking that too!

If I touch the screen with the palm of my hand, I get a value of 240.

@Monkeyman32123 I think it could be very dependent on what device you have, what the accuracy of the touch radius is.

interesting?light touch and hard touch

Great! I just built a feature into my game for IPhones to have things you touch show above the finger but I had to choose a guesstimate value for average finger size. This should be a great help for that.

Makes sense @Simeon

And @Ignatz, I think my values give me the win for a “skinny finger” contest

Makes sense but my code to draw touch markers based on the touch.radius made the end of touch location marker disappear!

@jaj_TheDeveloper, you might be able to do it by having the user place all 5 fingers on the screen, then you see which is the largest and that is your thumb average

@JakAttak but I would need them to do it multiple times because the thumb’s `touch.radius` is not always the same. I could use the following or similar code to work out the average:

``````totalradius = 0

for i = 1, #radius do
end

``````

I created a thumb detector but it isn’t super accurate.

``````function touched(touch)
if touch.radius > 23.506999 and touch.state == BEGAN then