Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Nicki · Aug 23, 2010 at 01:09 PM · iphonescreenpixeldrawingbrush

determine how much space is left on screen

Hello, I'm new to Unity development and I would like some help if it is possible!

I want to make an iphone drawing application like that described here

http://www.flashperfection.com/tutorials/Mouse-Drawing-in-AS3-96618.html

where the user can draw the screen with a brush (their finger). I need a way to determine that all the surface has been drawn. Any ideas on how to accomplish that? Is there a way in Unity to calculate how many pixels have been drawn?

Thanks in advance!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Wolfram · Aug 23, 2010 at 02:56 PM

Does is have to be pixel-precise? If so, I guess you'd have to count pixels one way or another. For example, instead of just drawing on the screen, also "draw" into a 2D array mask. You can stop if every entry of that array has been set (if you scan linearly for entries that haven't been set yet, note you can bail out at the first unset entry you find, and don't need to process the complete array everytime).

It is very likely that there are GPU/Shader functions to help you with that (i.e., determining whether all pixels of a mask have been set/reset), but I haven't looked into that.

If your result doesn't need to be pixel-precise, you can use an analytical method - but since that would have to be determined over all circles drawn so far, it is likely to be more expensive. Start with the surface area of your display, width*height in pixels. If you draw a circle, subtract its area from that value (take care of clipping near the borders by re-adding the area of the clipped circle segments). If you now move the mouse/finger (and maybe change the radius), you can compute the area difference between two consecutive frames by computing the area of the resulting crescent between these two circles. However, you would need to clip any new circle that is to be drawn against all other circles that have been drawn already, to determine the overlap and only subtract the area that's actually "new". This last step makes the analytical method probably not feasible.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Unity iPhone - Camera Orthographic size - Differing results 1 Answer

Lighting disparity using spotlights between editor and iDevices 0 Answers

android platform 0 Answers

black screen when simulating 1 Answer

Screen flickers when app is moving to background 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges