Skip to content

Instantly share code, notes, and snippets.

View vahids's full-sized avatar

Vahid vahids

View GitHub Profile
@vahids
vahids / mainActivity.kt
Created October 26, 2017 13:18
My First Kotlin class
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
configureViewElements()
}
private fun configureViewElements() {
configureSubmitButton()
@vahids
vahids / LiveCameraView.swift
Last active April 23, 2019 05:24
Live camera UIView on Swift 5
//
// CustomeCameraView.swift
// Live Camera View
//
// Created by Vahid Sayad on 4/22/19.
// Copyright © 2019. All rights reserved.
//
import UIKit
import AVFoundation
private func hsbToHSL(h: CGFloat, s: CGFloat, b: CGFloat) -> (h: CGFloat, s: CGFloat, l: CGFloat) {
// both hsv and hsl values are in [0, 1]
var newS: CGFloat = s
let l = (CGFloat(2) - s) * b / CGFloat(2)
if (l != 0) {
if (l == 1) {
newS = 0
} else if (l < 0.5) {
newS = newS * b / (l * 2)