aniamtion1 - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of aniamtion1.php
- import SwiftUI
- struct ContentView: View {
- @State private var drawToPointA = false
- @State private var drawToPointB = false
- @State private var drawToPointC = false
- var body: some View {
- VStack {
- TrianglePathView(drawToPointA: drawToPointA, drawToPointB: drawToPointB, drawToPointC: drawToPointC)
- .frame(width: 200, height: 200)
- .onAppear {
- withAnimation(.easeInOut(duration: 1.0)) {
- drawToPointA = true
- }
- DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
- withAnimation(.easeInOut(duration: 1.0)) {
- drawToPointB = true
- }
- }
- DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
- withAnimation(.easeInOut(duration: 1.0)) {
- drawToPointC = true
- }
- }
- }
- }
- }
- }
- struct TrianglePathView: View {
- var drawToPointA: Bool
- var drawToPointB: Bool
- var drawToPointC: Bool
- var body: some View {
- GeometryReader { geometry in
- Path { path in
- let centerX = geometry.size.width / 2
- let centerY = geometry.size.height / 2
- path.move(to: CGPoint(x: centerX, y: centerY - 100))
- if drawToPointA {
- path.addLine(to: CGPoint(x: centerX - 50, y: centerY + 50))
- }
- if drawToPointB {
- path.addLine(to: CGPoint(x: centerX + 50, y: centerY + 50))
- }
- if drawToPointC {
- path.addLine(to: CGPoint(x: centerX, y: centerY - 100))
- }
- }
- .stroke(Color.blue, lineWidth: 2)
- }
- }
- }
- @main
- struct DrawTriangleApp: App {
- var body: some Scene {
- WindowGroup {
- ContentView()
- }
- }
- }