| 124 | |
| 125 | if (visualEntry.color) { |
| 126 | visualEntryJson.setMapValue("color", Valdi::Value(visualEntry.color.value().toString())); |
| 127 | } |
| 128 | |
| 129 | visualEntries->emplace(i, std::move(visualEntryJson)); |
| 130 | } |
| 131 | |
| 132 | out.setMapValue("visualEntries", Valdi::Value(visualEntries)); |
| 133 | |
| 134 | return out; |
| 135 | } |
| 136 | |
| 137 | Ref<Valdi::RefCountable> TextLayout::getAttachmentAtPoint(Point location, Scalar tolerance) const { |
| 138 | Ref<Valdi::RefCountable> bestCandidate; |
| 139 | Scalar shortestDistance = 0.0f; |
| 140 | for (const auto& attachment : _attachments) { |
| 141 | if (attachment.bounds.contains(location)) { |
| 142 | return attachment.attachment; |
| 143 | } |
| 144 | |
| 145 | auto closestPoint = attachment.bounds.closestPoint(location); |
| 146 | auto distance = Point::distance(location, closestPoint); |
| 147 | |