// InvertMask inverts the alpha values in the current clipping mask such that
// a fully transparent region becomes fully opaque and vice versa.
556510
func (dc *Context) InvertMask() {
	if dc.mask == nil {
		dc.mask = image.NewAlpha(dc.im.Bounds())
	} else {
		for i, a := range dc.mask.Pix {
			dc.mask.Pix[i] = 255 - a
		}
	}
}
864154
func ipInMasks(ip net.IP, masks []net.IPNet) bool {
	for _, mask := range masks {
		if mask.Contains(ip) {
			return true
		}
	}
	return false
}
837088
func (p *PWMPin) InvertPolarity(invert bool) (err error) {
	if !p.enabled {
		polarity := "normal"
		if invert {
			polarity = "inverted"
		}
		_, err = p.write(p.pwmPolarityPath(), []byte(polarity))
	} else {
		err = fmt.Errorf("Cannot set PWM polarity when enabled")
	}
	return
}
778327
func (q Quality) Invert() Quality {
	switch q.Type {
	case PerfectType:
		return q
	case MajorType:
		return Quality{MinorType, q.Size}
	case MinorType:
		return Quality{MajorType, q.Size}
	case AugmentedType:
		return Quality{DiminishedType, q.Size}
	case DiminishedType:
		return Quality{AugmentedType, q.Size}
	default:
		panic(fmt.Sprintf("invalid type: %d", q.Type))
	}
}
373544
func (rc *runContainer16) invert() *runContainer16 {
	ni := len(rc.iv)
	var m []interval16
	switch ni {
	case 0:
		return &runContainer16{iv: []interval16{newInterval16Range(0, MaxUint16)}}
	case 1:
		return &runContainer16{iv: rc.invertlastInterval(0, 0)}
	}
	var invstart int64
	ult := ni - 1
	for i, cur := range rc.iv {
		if i == ult {
			// invertlastInteval will add both intervals (b) and (c) in
			// diagram below.
			m = append(m, rc.invertlastInterval(uint16(invstart), i)...)
			break
		}
		// INVAR: i and cur are not the last interval, there is a next at i+1
		//
		// ........[cur.start, cur.last] ...... [next.start, next.last]....
		//    ^                             ^                           ^
		//   (a)                           (b)                         (c)
		//
		// Now: we add interval (a); but if (a) is empty, for cur.start==0, we skip it.
		if cur.start > 0 {
			m = append(m, newInterval16Range(uint16(invstart), cur.start-1))
		}
		invstart = int64(cur.last() + 1)
	}
	return &runContainer16{iv: m}
}
1081873
func (dc *Context) SetMask(mask *image.Alpha) error {
	if mask.Bounds().Size() != dc.im.Bounds().Size() {
		return errors.New("mask size must match context size")
	}
	dc.mask = mask
	return nil
}
106411
func Invert() Filter {
	return &colorchanFilter{
		fn: func(x float32) float32 {
			return 1 - x
		},
		lut: false,
	}
}
788051
func (e *EMECipher) Encrypt(tweak []byte, inputData []byte) []byte {
	return Transform(e.bc, tweak, inputData, DirectionEncrypt)
}
452961
func Unmask(cipher Trits, length uint64, c *curl.Curl) (dest Trits) {
	var chunkLength uint64
	dest = make(Trits, length)

	for i := uint64(0); i < length; i += HashTrinarySize {
		if length-i < HashTrinarySize {
			chunkLength = length - i
		} else {
			chunkLength = HashTrinarySize
		}

		for j := uint64(0); j < chunkLength; j++ {
			dest[i+j] = Sum(cipher[i+j], -c.State[j])
		}
		c.Absorb(dest[i : i+chunkLength])
	}
	return dest
}
257687
func (addr DevAddr) Mask(bits int) (masked DevAddr) {
	return empty.WithPrefix(DevAddrPrefix{addr, bits})
}
1088095
func generateMaskingKey() (maskingKey []byte, err error) {
	maskingKey = make([]byte, 4)
	if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil {
		return
	}
	return
}
1252956
func (matrix *Matrix) Invert() error {
	ret := Status(C.cairo_matrix_invert((*C.cairo_matrix_t)(unsafe.Pointer(matrix)))).toError()
	return ret
}
302169
func MaskError(err error) bool {
	_, ok := errors.Cause(err).(*k8serrors.StatusError)
	return ok
}
761225
func UnmaskBlockCryptKey(serverHalf BlockCryptKeyServerHalf,
	tlfCryptKey TLFCryptKey) BlockCryptKey {
	return MakeBlockCryptKey(xorKeys(serverHalf.data, tlfCryptKey.data))
}
1114552
func Invert(src image.Image) *image.RGBA {
	fn := func(c color.RGBA) color.RGBA {
		return color.RGBA{255 - c.R, 255 - c.G, 255 - c.B, c.A}
	}

	img := adjust.Apply(src, fn)

	return img
}
623358
func ReverseSlice(slice interface{}) interface{} {
	switch reflect.TypeOf(slice).Kind() {
	case reflect.Slice, reflect.Ptr:
		values := reflect.Indirect(reflect.ValueOf(slice))
		if values.Len() == 0 {
			return slice
		}

		reversedSlice := reflect.MakeSlice(reflect.SliceOf(reflect.Indirect(values.Index(0)).Type()), values.Len(), values.Len())

		k := 0
		for i := values.Len() - 1; i >= 0; i-- {
			reversedSlice.Index(k).Set(copyElement(values.Index(i)))
			k++
		}

		return reversedSlice.Interface()
	default:
		panic(fmt.Sprintf("Type not allowed: %v", reflect.TypeOf(slice).Kind()))
	}
}
56769
func ConvertMaskDotStringToBits(netmask string) (int, int) {
	return net.ParseIP(netmask).DefaultMask().Size()
}