require 'sdl' require 'bizzieLibrary' require 'bizzieSDL' require 'bizzieMatrix' require 'bizzieRandom' SDL.init SDL::INIT_VIDEO $SDLscreen = SDL::set_video_mode 640, 480, 24, SDL::SRCALPHA puts $black.distance($originNd[4]) BGCOLOR = $SDLscreen.format.mapRGB 0, 0, 0 LINECOLOR = $SDLscreen.format.mapRGB 255, 255, 255 a = SDL::Surface.load("testPic4.bmp") puts a.w puts a.h puts a.getPixel(100, 100) puts getColor(a.getPixel(100, 100)) puts getPixelValue(getColor(a.getPixel(100,100))) $eps = 0.1 colorMatrix = SimpleMatrix.new(a.w, a.h) (0..a.w - 1).each do |x| (0..a.h - 1).each do |y| minVal = 10.0 minStep = 1.0 $whiteBlackPath.doPath($eps) {|pt, val| dist = pt.distance(getColor(a.getPixel(x,y))) if dist < minVal minVal = dist minStep = val end } colorMatrix.put(x, y, minStep) index = x * a.h + y if (index % 1000 == 0) puts index end end end $jitter = 0.0 running = true while (running) puts "starting!" while event = SDL::Event2.poll case event when SDL::Event2::Quit running = false when SDL::Event2::MouseMotion x = event.x y = event.y end end str = gets if str == "a\n" $usedPath = $rainbowPath elsif str == "b\n" $usedPath = $revRainbowPath elsif str == "c\n" $usedPath = $redBlackPath elsif str == "d\n" $usedPath = $redWhitePath elsif str == "e\n" $usedPath = $whiteCyanBluePath elsif str == "f\n" $usedPath = BezierPath.new([randomColor, randomColor, randomColor, randomColor]) elsif str == "g\n" $usedPath = BezierPath.new([$white, randomColor, randomColor, $white]) elsif str == "h\n" $usedPath = BezierPath.new([$black, randomColor, randomColor, $black]) elsif str == "i\n" $usedPath = BezierPath.new([$black, randomColor, randomColor, $white]) elsif str == "j\n" $jitter += 0.05 puts "jitter = " + $jitter.to_s elsif str == "k\n" $jitter -= 0.05 puts "jitter = " + $jitter.to_s else $usedPath = $rainbowPath end puts "doing!" #puts "jitter is: " + jitterNum.to_s $SDLscreen.fill_rect 0, 0, 640, 480, BGCOLOR $origin3d = $originNd[3] if $jitter == 0.0 (0..a.w - 1).each do |x| (0..a.h - 1).each do |y| pt = $usedPath.doPathPoint(colorMatrix.get(x, y)) color = pt * (colorMatrix.get(x, y) / (pt.project(3).distance($origin3d))) $SDLscreen.putPixel(x, y, getPixelValue(color)) end end else (0..a.w - 1).each do |x| (0..a.h - 1).each do |y| $SDLscreen.putPixel(x, y, getPixelValue(jitter($usedPath.doPathPoint(colorMatrix.get(x, y)), $jitter))) end end end $SDLscreen.flip end