Snippets Collections
https://medium.com/swlh/how-to-create-a-custom-gradient-in-swift-with-cagradientlayer-ios-swift-guide-190941cb3db2

lazy var gradient: CAGradientLayer = {
        let gradient = CAGradientLayer()
        gradient.type = .axial
        gradient.colors = [
            
            hexStringToUIColor(hex: "468d01"),
            hexStringToUIColor(hex: "acdc08")
        ]
        
        gradient.locations = [0,0.95]
        return gradient
    }()


func views() {
              gradient.frame = logInView.bounds
            logInView.layer.addSublayer(gradient)
            
            let x = logInView.frame.origin.x
            let y = logInView.frame.origin.y
            
            print("x = ", x)
            print("y = ", y)
            
            gradient.startPoint = CGPoint(x: 0, y: y)
            gradient.endPoint = CGPoint(x: 1, y: y)

}


    func hexStringToUIColor (hex:String) -> CGColor {
        var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

        if (cString.hasPrefix("#")) {
            cString.remove(at: cString.startIndex)
        }

        if ((cString.count) != 6) {
            return UIColor.gray.cgColor
        }

        var rgbValue:UInt64 = 0
        Scanner(string: cString).scanHexInt64(&rgbValue)

        return CGColor(
            red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
            green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
            blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
            alpha: CGFloat(1.0)
        )
    }

# You can use imageMagick to create a gradient image on the fly, but with all the weird possibilities I didn't quite get the hang of it (yet). Anyway, a default 50:50 gradient can be created via "convert -size 100x100 gradient:black-white target.png". To shift the center, you can chain multiple gradients and use the ""-append" flag
❯ convert -size 1000x600 gradient:black-black -size 1000x400 gradient:black-none -append gradient.png

# To use the gradient as a mask on your image, they should be the same size. You can easily resize the image. But keep in mind that imageMagixk respects the proportions and resizes X and Y according to the smaller value
❯ convert gradient.png -resize 1200x800 gradient_resized.png

# Here is how to combine the two, so that you're left with a new image with the mask applied
❯ convert content.jpg gradient_resized.png -alpha on -compose CopyOpacity -composite result.png
 .conic-gradient {
  background: conic-gradient(from 90deg, #fff, #000);
}                               
                                
.gradient {
  background-image:
    radial-gradient(
      yellow,
      #f06d06
    );
}
.gradient {
  background-image:
    linear-gradient(
      to right, 
      red, 
      blue,
      yellow, 
      green
    );
}
star

Fri Sep 09 2022 07:26:02 GMT+0000 (Coordinated Universal Time)

#ios #swift #gradient #gradent
star

Wed Jun 09 2021 08:17:27 GMT+0000 (Coordinated Universal Time) terminal help output, try and error and brain stuff

#image #convert #gradient #clipping #mask #transparency #typo3 #imagemagick
star

Fri Apr 24 2020 11:55:55 GMT+0000 (Coordinated Universal Time) https://css-tricks.com/snippets/css/css-conic-gradient/

#css #css #conic #gradient
star

Fri Jan 10 2020 19:00:00 GMT+0000 (Coordinated Universal Time) https://css-tricks.com/snippets/css/css-radial-gradient/

#css #design #gradient #webdev
star

Wed Jan 08 2020 19:00:00 GMT+0000 (Coordinated Universal Time)

#css #design #gradient

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension