Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个偏移来使用自定义画家画线,我需要检查这些偏移是否在直线上(水平)。我该如何检查?如果不是它不在一条直线上,如何改变偏移量。
如果两条线共享相同的 dy 属性,则它们是水平直的。
要检查它们是否相同,您可以执行以下操作:
Offset o1 = ...; Offset o2 = ...; if(o1.dy == o2.dy) { // horizontal line } else { // not horizontal }