FedericoGB25
Coder
Hi guys, is there anyone who knows about swift? I'm trying a personal project that if he composed de in showing photographs taken in a "virtual sheet", but I would also like to do a button that randomizes these photographs, that is, that swaps positions randomly:
Does anyone have any suggestions? Thank you
Swift:
import SPCComponents
import Foundation
let space = Space()
space.backgroundImage = #imageLiteral(resourceName: "IMG_0049.JPG")
let button = Button()
space.add(button, at: Point(x: 0, y: -400))
button.backgroundColor = #colorLiteral(red: 0.9529411764705882, green: 0.6862745098039216, blue: 0.13333333333333333, alpha: 1.0)
let myAlbum = PhotoAlbum(named: "Le mie foto")
let image1 = myAlbum[1].image
let image2 = myAlbum[2].image
let image3 = myAlbum[3].image
let image4 = myAlbum[4].image
let image5 = myAlbum[5].image
let image6 = myAlbum[6].image
let image7 = myAlbum[7].image
let image8 = myAlbum[8].image
let image9 = myAlbum[9].image
// Foto 1
let photo1 = ImageView()
photo1.image = image1
space.add(photo1, at: Point(x: -300, y: 250), size: Size(width: 500, height: 200))
let photo2 = ImageView()
photo2.image = image2
space.add(photo2, at: Point(x: 0, y: 280), size: Size(width: 500, height: 200))
// Foto 3
let photo3 = ImageView()
photo3.rotation = 0
photo3.image = image3
photo3.scale = 1.25
space.add(photo3, at: Point(x: 310, y: 250), size: Size(width: 240, height: 300))
// Foto 4
let photo4 = ImageView()
photo4.rotation = 0
photo4.image = image4
photo4.scale = 1.25
space.add(photo4, at: Point(x: -320, y: 10), size: Size(width: 240, height: 300))
// Foto 5
let photo5 = ImageView()
photo5.rotation = 0
photo5.image = image5
photo5.scale = 1.25
space.add(photo5, at: Point(x: 5, y: 60), size: Size(width: 240, height: 300))
// Foto 6
let photo6 = ImageView()
photo6.rotation = 0
photo6.image = image6
photo6.scale = 1.25
space.add(photo6, at: Point(x: 320, y: -10), size: Size(width: 240, height: 300))
// Foto 7
let photo7 = ImageView()
photo7.rotation = 0
photo7.image = image7
photo7.scale = 1.25
space.add(photo7, at: Point(x: -320, y: -240), size: Size(width: 240, height: 300))
// Foto 8
let photo8 = ImageView()
photo8.rotation = 0
photo8.image = image8
photo8.scale = 1.25
space.add(photo8, at: Point(x: 5, y: -200), size: Size(width: 240, height: 300))
// Foto 9
let photo9 = ImageView()
photo9.rotation = 0
photo9.image = image9
photo9.scale = 1.25
space.add(photo9, at: Point(x: 320, y: -240), size: Size(width: 240, height: 300))
let label = Label()
let style = TextStyle(.Futura, fontSize: 90, color:#colorLiteral(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) )
label.rotation = 0
label.textStyle = style
label.shadowColor = #colorLiteral(red: 0.239215686917305, green: 0.6745098233222961, blue: 0.9686274528503418, alpha: 1.0)
label.shadowOffset = Size(width: 1, height: 1)
label.text = "Poems Code Machine"
space.add(label, at: Point(x: 0, y: 450))
Does anyone have any suggestions? Thank you