Aniamt - 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 Aniamt.php

  1. import SwiftUI
  2.  
  3. struct ContentView: View {
  4.     @State private var showTriangle = false
  5.     
  6.     var body: some View {
  7.         VStack {
  8.             TriangleView()
  9.                 .opacity(showTriangle ? 1 : 0)
  10.                 .onAppear {
  11.                     withAnimation(.easeInOut(duration: 1.0)) {
  12.                         showTriangle = true
  13.                     }
  14.                 }
  15.         }
  16.         .frame(maxWidth: .infinity, maxHeight: .infinity)
  17.     }
  18. }
  19.  
  20. struct TriangleView: View {
  21.     let triangleLength: CGFloat = 150
  22.     
  23.     var body: some View {
  24.         ZStack {
  25.             TriangleShape(triangleLength: triangleLength)
  26.                 .fill(Color.blue)
  27.             Circle()
  28.                 .frame(width: 8)
  29.                 .position(x: triangleLength / 2, y: 0)
  30.                 .foregroundColor(.red)
  31.             Circle()
  32.                 .frame(width: 8)
  33.                 .position(x: 0, y: triangleLength * sqrt(3) / 2)
  34.                 .foregroundColor(.green)
  35.             Circle()
  36.                 .frame(width: 8)
  37.                 .position(x: triangleLength, y: triangleLength * sqrt(3) / 2)
  38.                 .foregroundColor(.yellow)
  39.         }
  40.     }
  41. }
  42.  
  43. struct TriangleShape: Shape {
  44.     var triangleLength: CGFloat
  45.     
  46.     func path(in rect: CGRect) -> Path {
  47.         let centerX = rect.midX
  48.         let centerY = rect.midY - triangleLength * sqrt(3) / 6
  49.         
  50.         var path = Path()
  51.         path.move(to: CGPoint(x: centerX, y: centerY - triangleLength / 2))
  52.         path.addLine(to: CGPoint(x: centerX - triangleLength / 2, y: centerY + triangleLength / 2))
  53.         path.addLine(to: CGPoint(x: centerX + triangleLength / 2, y: centerY + triangleLength / 2))
  54.         path.closeSubpath()
  55.         
  56.         return path
  57.     }
  58. }
  59.  
  60. @main
  61. struct EquilateralTriangleApp: App {
  62.     var body: some Scene {
  63.         WindowGroup {
  64.             ContentView()
  65.         }
  66.     }
  67. }
  68.  
File Description
  • Aniamt
  • PHP Code
  • 22 Aug-2023
  • 1.84 Kb
You can Share it: