twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

devicescale.go (882B)


      1 // Copyright 2018 The Ebiten Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 package devicescale
     16 
     17 import (
     18 	"sync"
     19 )
     20 
     21 type pos struct {
     22 	x, y int
     23 }
     24 
     25 var (
     26 	m     sync.Mutex
     27 	cache = map[pos]float64{}
     28 )
     29 
     30 func GetAt(x, y int) float64 {
     31 	m.Lock()
     32 	defer m.Unlock()
     33 	if s, ok := cache[pos{x, y}]; ok {
     34 		return s
     35 	}
     36 	s := impl(x, y)
     37 	cache[pos{x, y}] = s
     38 	return s
     39 }