Untitled
unknown
plain_text
a year ago
2.1 kB
12
Indexable
; IOs const $pivot_io = 9 const $scanner_io = 8 const $scanner_pivot_phase = 0 ; Can be set to 0, -pi/2, +pi/2 or +pi for orientation correction var $screen = screen(0, 0) ; dashboard on IO 2, screen on channel 0 var $color = color( 0, 0, 0, 0) var $blue = 0 var $green = 0 var $red = 0 ; Scan Settings const $max_distance = 10000 ; meters const $ore = "Ti" init $screen.blank() update ; Rotate the pivot output_number($pivot_io, 0, -0.1) ; Gradually clear the screen to black $screen.draw(0, 0, color(0, 0, 0, 1), $screen.width, $screen.height) ; Useful values var $half_width = $screen.width / 2 var $half_height = $screen.height / 2 var $steps = $half_height ; Compute a normalized position given the current angle of the pivot var $angle = input_number($pivot_io, 0) * 2pi + $scanner_pivot_phase var $x = sin($angle) var $y = cos($angle) ; Loop through steps repeat $steps ($i) var $step = ($i + 1) / $steps var $distance = $step * $max_distance ; Send the scan distance to the pivot on the appropriate channel output_number($scanner_io, $i, $distance) ; Get the scanned composition from the scanner var $composition = input_text($scanner_io, $i) ; If we detected the ore, draw a pixel based on its density if $composition.$ore $blue = 0 $green = 0 $red = 0 var $density_color = color(0, 0, 0, 255) ; black ;y = ((205 * x) / 255) + 50 if $composition.$ore <= 0.02 $blue = ((225 * 12700 * $composition.$ore) / 255) + 30 if $composition.$ore >= 0.001 and $composition.$ore <= 0.15 $green = ((225 * 1700 * $composition.$ore) / 255) + 30 if $composition.$ore >= 0.05 and $composition.$ore <= 1 $red = ((205 * 255 * $composition.$ore) / 255) + 50 print ($composition.$ore) print ($red, $green, $blue) $density_color = color($red, $green, $blue) ; gradient map from black to red/green var $xx = (1 - $x * $step) * $half_width var $yy = (1 - $y * $step) * $half_height $screen.draw_point($xx, $yy, $density_color) ; Draw a red dot at our current location (center of the screen) $screen.draw_point($half_width, $half_height, red)
Editor is loading...
Leave a Comment