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:
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.
background(40, 40, 50)
ellipse(CurrentTouch.x, CurrentTouch.y, CurrentTouch.radius * 2)
Note: This feature is iOS 8 only, if you are on iOS 7 then you will see a radius and radiusTolerance of
Any ideas for what this could be used for?
More sensitive/accurate buttons, perhaps?
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
touch.radius==0 when touch.state==ENDED
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
totalradius = totalradius + radius[i]
thumbav = totalradius/#radius
I created a thumb detector but it isn’t super accurate.
if touch.radius > 23.506999 and touch.state == BEGAN then
print("that is your thumb.")
well, it works 79% of the time for me. Others may have a different thumb average.
@Simeon is there any way to get this more sensitive?
I tried to apply it to this old Wiggle project by @West and @JakAttak (attached)
Similar to other reports above, I only ever see two values for the radius: a smaller one, and if I press really really really hard, a larger one, but nothing in between.
I modified this project a little, to fake a tapering effect at the start of a touch, and I think it looks pretty cool, illustrating how much cooler it would be if it could actually detect finer variations of radius.