This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static func scale(_ image: UIImage, fromRect: CGRect = .zero, targetSize: CGSize) -> UIImage { | |
let renderer = UIGraphicsImageRenderer(size: targetSize) | |
return renderer.image { context in | |
// UIImage and CGContext coordinates are flipped. | |
var transform = CGAffineTransform(translationX: 0.0, y: targetSize.height) | |
transform = transform.scaledBy(x: 1, y: -1) | |
context.cgContext.concatenate(transform) | |
// UIImage -> cropped CGImage | |
let makeCroppedCGImage: (UIImage) -> CGImage? = { image in | |
guard let cgImage = image.cgImage else { return nil } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var transform = CGAffineTransform(translationX: 0.0, y: targetSize.height) | |
transform = transform.scaledBy(x: 1, y: -1) | |
context.cgContext.concatenate(transform) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scaling the full image | |
let originalImage = UIImage(named: "example_photo.jpg")! | |
var targetSize = CGSize(width: 100, height: 100) | |
imageView.image = ImageScaler.scaleToFill(originalImage, in: targetSize) | |
// Scaling only a small part of the image | |
let originalImage = UIImage(named: "example_photo.jpg")! | |
var fromRect = CGRect(x: 362.0, y: 449.0, width: 260.0, height: 160.0) | |
var targetSize = CGSize(width: 100, height: 100) | |
imageView.image = ImageScaler.scaleToFill(originalImage, in: targetSize, from: fromRect) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PublishDocumentation | |
on: | |
workflow_dispatch: | |
release: | |
types: [ published ] | |
jobs: | |
publish: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
author: Toomas Vahter | |
author_url: https://www.augmentedcode.io | |
github_url: https://github.com/laevandus/IndexedDataStore | |
output: Docs | |
swift_build_tool: xcodebuild | |
build_tool_arguments: | |
- -scheme | |
- IndexedDataStore | |
- -sdk | |
- iphoneos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Wave: Shape { | |
var amplitude: Double | |
var frequency: Double | |
func path(in rect: CGRect) -> Path { | |
let sinCenterY = amplitude | |
let path = CGMutablePath() | |
path.move(to: CGPoint(x: 0, y: sinCenterY)) | |
let width = Double(rect.width) | |
for x in stride(from: 0, through: width, by: 1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State private var amplitude = 10.0 | |
@State private var frequency = 0.1 | |
var body: some View { | |
ZStack { | |
Wave(amplitude: amplitude, frequency: frequency) | |
.fill(Color.blue) | |
.frame(height: 300.0) | |
.animation(.easeInOut(duration: 3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
included: | |
- ../ButtonKit | |
- ../ButtonGallery | |
disabled_rules: | |
- compiler_protocol_init | |
- cyclomatic_complexity | |
- file_length | |
- force_cast | |
- function_body_length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if which swiftlint >/dev/null; then | |
# Relative path from the .xcodeproj which contains this script | |
swiftlint lint --config ../swiftlint.yml | |
else | |
echo "warning: SwiftLint not installed" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/laevandus/SwiftPackageAppWorkspace.git | |
open ButtonGallery.xcworkspace |