aniamtion1 - PHP Online

Form of PHP Sandbox

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.



Your result can be seen below.

Result of php executing





Full code of aniamtion1.php

  1. import SwiftUI
  2.  
  3. struct ContentView: View {
  4.     @State private var drawToPointA = false
  5.     @State private var drawToPointB = false
  6.     @State private var drawToPointC = false
  7.     
  8.     var body: some View {
  9.         VStack {
  10.             TrianglePathView(drawToPointA: drawToPointA, drawToPointB: drawToPointB, drawToPointC: drawToPointC)
  11.                 .frame(width: 200, height: 200)
  12.                 .onAppear {
  13.                     withAnimation(.easeInOut(duration: 1.0)) {
  14.                         drawToPointA = true
  15.                     }
  16.                     DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
  17.                         withAnimation(.easeInOut(duration: 1.0)) {
  18.                             drawToPointB = true
  19.                         }
  20.                     }
  21.                     DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
  22.                         withAnimation(.easeInOut(duration: 1.0)) {
  23.                             drawToPointC = true
  24.                         }
  25.                     }
  26.                 }
  27.         }
  28.     }
  29. }
  30.  
  31. struct TrianglePathView: View {
  32.     var drawToPointA: Bool
  33.     var drawToPointB: Bool
  34.     var drawToPointC: Bool
  35.     
  36.     var body: some View {
  37.         GeometryReader { geometry in
  38.             Path { path in
  39.                 let centerX = geometry.size.width / 2
  40.                 let centerY = geometry.size.height / 2
  41.                 
  42.                 path.move(to: CGPoint(x: centerX, y: centerY - 100))
  43.                 
  44.                 if drawToPointA {
  45.                     path.addLine(to: CGPoint(x: centerX - 50, y: centerY + 50))
  46.                 }
  47.                 if drawToPointB {
  48.                     path.addLine(to: CGPoint(x: centerX + 50, y: centerY + 50))
  49.                 }
  50.                 if drawToPointC {
  51.                     path.addLine(to: CGPoint(x: centerX, y: centerY - 100))
  52.                 }
  53.             }
  54.             .stroke(Color.blue, lineWidth: 2)
  55.         }
  56.     }
  57. }
  58.  
  59. @main
  60. struct DrawTriangleApp: App {
  61.     var body: some Scene {
  62.         WindowGroup {
  63.             ContentView()
  64.         }
  65.     }
  66. }
  67.  
File Description
  • aniamtion1
  • PHP Code
  • 22 Aug-2023
  • 2.03 Kb
You can Share it: