def local_normal_at(self, local_point, hit=None): if self.smoothed: return add( multiply(self.n2, hit.u), add(multiply(self.n3, hit.v), multiply(self.n1, (1 - hit.u - hit.v)))) return self.normal
def __init__(self, corner, full_uvec, usteps, full_vvec, vsteps, intensity): self.corner = corner self.uvec = multiply(full_uvec, 1 / usteps) self.usteps = usteps self.vvec = multiply(full_vvec, 1 / vsteps) self.vsteps = vsteps self.samples = usteps * vsteps self.position = add(add(corner, multiply(full_uvec, 1 / 2)), multiply(full_vvec, 1 / 2)) self.intensity = intensity self.jitter_by = DeterministicSequence([0.5])
def shade_hit(self, hit, remaining=5): surface = color(0, 0, 0) for light in self.lights: light_intensity = light.intensity_at(hit.over_point, self) surface = add( surface, lighting(hit.object.material, hit.object, light, hit.point, hit.eyev, hit.normalv, light_intensity)) reflected = self.reflected_color(hit, remaining) refracted = self.refracted_color(hit, remaining) material = hit.object.material if material.reflective > 0 and material.transparency > 0: reflectance = hit.schlick() return add(add(surface, multiply(reflected, reflectance)), multiply(refracted, (1 - reflectance))) return add(add(surface, reflected), refracted)
def step_impl(context): assert add(context.c1, context.c2) == color(1.6, 0.7, 1.0)
def add(task_name: str): """Add a task (it will be added to the "Dont" list).""" new_task_data = core.add(task_name) if new_task_data: new_task_data['metadata'][TO_DONT_METADTA_KEY] = {'list': 'dont'} return core.update(task_name, new_task_data)
def point_on_light(self, u, v): return add(self.corner, \ add(multiply(self.uvec, (u + self.jitter_by.next())), \ multiply(self.vvec, (v + self.jitter_by.next()))))
def tick(env, proj): position = add(proj['position'], proj['velocity']) velocity = add(add(proj['velocity'], env['gravity']), env['wind']) return dict(position=position, velocity=velocity)
def pattern_at(self, point): distance = subtract(self.color_b, self.color_a) fraction = point[0] - floor(point[0]) return add(self.color_a, multiply(distance, fraction))
def add(path, name): ''' Create a repository. ''' core.add(path, name)
# We already have the values of these two, even if they are 0 dev.draw_ap(len(bssid_db)) # dev.draw_ssid(len(unique_ssid_db)) while True: cycles += 1 try: dev.draw_dot_scan("yellow") current_scan = sta.scan() # dev.draw_status("scanned") dev.draw_dot_scan("black") except Exception as e: dev.draw_status("scan error " + str(cycles)) dev.draw_dot_scan("red") err = format_error(e, cycles) dev.add(err_log_filename, err) dev.draw_cycle(str(cycles)) for i, station in enumerate(current_scan): dev.draw_bssid_loop(str(i + 1) + "/" + str(len(current_scan))) # dev.draw_status("looping " + str(i + 1) + " of " + str(len(current_scan))) bssid = ubinascii.hexlify(station[1]).decode() ssid = station[0].decode() channel = str(station[2]) authmode = authmode_choices.get(station[4]) hidden = str(station[5]) if bssid not in bssid_db: # dev.draw_status(str(bssid)) bssid_db.add(bssid) dev.draw_ap(len(bssid_db))