Advertisement
Zouzaka

Dessin lignes

Mar 22nd, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.94 KB | None | 0 0
  1. class Bitmap
  2.   def creat_ligne(x_1,y_1,x_2,y_2)
  3.     largeur_rec = x_2 - x_1
  4.     longeur_rec = y_2 - y_1
  5.     distance = Math.sqrt(largeur_rec**2 + longeur_rec**2)
  6.     largest_dis = largeur_rec if largeur_rec >= longeur_rec
  7.     largest_dis = longeur_rec if longeur_rec >= largeur_rec
  8.     for i in 0..distance
  9.       x = (x_1 + (largeur_rec*i)/distance)
  10.       y = (y_1 + (longeur_rec*i)/distance)
  11.       color = Color.new(0, 0, 0, 255)
  12.       self.set_pixel(x, y, color)
  13.     end
  14.   end
  15. end
  16. #===============================================================================
  17. class Scene_design < Scene_Base
  18.   def start
  19.     @window = Window_Base.new(50,50,200,200)
  20.     @window.contents.creat_ligne(0,0,150,0)
  21.     @window.contents.creat_ligne(0,0,0,150)
  22.     @window.contents.creat_ligne(0,150,150,150)
  23.     @window.contents.creat_ligne(150,0,150,150)
  24.     @window.contents.creat_ligne(150,0,0,150)
  25.     @window.contents.creat_ligne(0,0,150,150)
  26.   end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement