Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by zhoy · Jun 14, 2016 at 01:13 AM · circlemodelingdrawingmesh verticestexturecoord

Somthing Weird! Creating filled circle with gradient(alpha) texture

alt text

Look the final drawing Effect . the Angle step count is 4 .why every corner has sharp line.

the texture used by shader is 4X4 size. top 2 pixels alpha == 0

        int count  = 4;//Mathf.Max(40, Mathf.RoundToInt(cicle.outter_radius * 0.1f));
         float step = 360 / count;
         float outter = cicle.outter_radius;
         float inner = (cicle.outter_radius - cicle.outter_soft);
 
         Quaternion target = Quaternion.identity;
         Vector3 dir  = Vector3.zero;
         //Vector3 from = Quaternion.Euler(0, 0, (180 % count == 0) && (count % 2 == 0) ? 180 / count: 0) *Vector3.up;
         //from.Normalize();
         Vector3 from = Vector3.up;
         /*outter*/
         if (cicle.outter_soft > 0)
         {
             v1 = cicle.center + from * inner;
             v2 = cicle.center + from * outter;
            
             for (int i = 1; i < count + 1; i++)
             {
                 target = Quaternion.Euler(0, 0, -step * i);
                 dir = target * from;
                 dir.Normalize();
                 v3 = cicle.center + dir * outter;
                 v4 = cicle.center + dir * inner;
                 FillVerts(cicle.geometry, v1, v2, v3, v4);
                 FillTopUVColor(cicle.geometry, cicle.color, false);
                 v1 = v4;
                 v2 = v3;
             }
         }
         if (cicle.inner_radius < cicle.outter_radius)
         {
             outter = cicle.outter_radius - cicle.outter_soft;
             inner = cicle.inner_radius + cicle.inner_soft;
             v1 = cicle.center + from * inner;
             v2 = cicle.center + from * outter;
             /*mider*/
             for (int i = 1; i < count + 1; i++)
             {
                 target = Quaternion.Euler(0, 0, -step * i);
                 dir = target * from;
                 v3 = cicle.center + dir * outter;
                 v4 = cicle.center + dir * inner;
                 FillVerts(cicle.geometry, v1, v2, v3, v4);
                 FillSolidUVColor(cicle.geometry, cicle.color);
                 v1 = v4;
                 v2 = v3;
             }
         }
         if (cicle.inner_soft > 0)
         {
             outter = cicle.inner_radius + cicle.inner_soft;
             inner = cicle.inner_radius;
             v1 = cicle.center + from * inner;
             v2 = cicle.center + from * outter;
             /*inner*/
             for (int i = 1; i < count + 1; i++)
             {
                 target = Quaternion.Euler(0, 0, -step * i);
                 dir = target * from;
                 v3 = cicle.center + dir * outter;
                 v4 = cicle.center + dir * inner;
                 FillVerts(cicle.geometry, v1, v2, v3, v4);
                 FillBottomUV(cicle.geometry, cicle.color);
                 v1 = v4;
                 v2 = v3;
             }
         }

     void FillTopUVColor(UIGeometry geometry, Color color, bool solid = false)
     {
         if (solid)
         {
             geometry.uvs.Add(new Vector2(0, 0.4f));
             geometry.uvs.Add(new Vector2(0, 0.6f));
             geometry.uvs.Add(new Vector2(1, 0.6f));
             geometry.uvs.Add(new Vector2(1, 0.4f));
         }
         else
         {
             geometry.uvs.Add(new Vector2(0, 0.5f));
             geometry.uvs.Add(new Vector2(0, 1));
             geometry.uvs.Add(new Vector2(1, 1));
             geometry.uvs.Add(new Vector2(1, 0.5f));
         }
         geometry.cols.Append(color, 4);
     }

 Sample Texture is:![alt text][2]


[2]: /storage/temp/72109-hline.png

circle.png (2.3 kB)
hline.png (941 B)
Comment
Add comment · Show 2
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
avatar image zhoy · Jun 14, 2016 at 01:21 AM 0
Share

inner_soft means inner soft border. by controlling the texture coord. this demo inner_soft is 0

params is below: Circle circle = new Circle(new Vector3(400, -400,0),200,300,Color.blue); circle.outter_soft = 200; circle.inner_soft = 0; test_canvas.DrawCircle(circle);

Circle Declare is : public class Circle : Shape { public Circle(Vector3 center, float radius,Color color) { this.center = center; this.color = color; inner_radius = 0; outter_radius = radius; } public Circle(Vector3 center, float radius_o, float radius_i, Color color) { this.center = center; this.color = color; inner_radius = radius_i; outter_radius = radius_o; } public Vector3 center; public Color color; public float outter_radius; public float inner_radius; public float outter_soft; public float inner_soft; }

avatar image zhoy · Jun 14, 2016 at 01:30 AM 0
Share

Drawing Soft Rect. Drawing Result is: alt text

 Code is:
 
 caller :
      FRect rect = new FRect(new Rect(0,0, 1200, 1200), Color.black);
     rect.left_soft = 600;
     rect.right_soft = 600;
     rect.top_soft = 600;
     rect.bottom_soft = 600;
     test_canvas.DrawRect(rect);
  
rect.png (4.7 kB)

0 Replies

· Add your reply
  • Sort: 

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

59 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a dynamic circle outline around a circle object to indicate radius 1 Answer

How do you draw 2D circles and primitives 5 Answers

Create 2D Low poly style 0 Answers

How to create a circular sprite? (Fb profile pic) 2 Answers

Unity 2D collider coinciding and not triggering. 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