用鞋子绘制单个像素:Ruby

时间:2012-03-06 07:16:29

标签: ruby shoes

我正在使用Ruby中的Shoes。我找不到在鞋子窗口中绘制单个像素的方法....任何人都可以帮助我吗?

:)

2 个答案:

答案 0 :(得分:2)

我不认为这是可能的。见Shoes GUI toolkit per pixel manipulation possible?

我认为你能得到的最接近的是2x2平方:

Shoes.app do
  click{|b, x, y|
    rect(x,y,1,1) if b == 1
  }
end

或2x1行:

Shoes.app do
  click{|b, x, y|
    line(x,y,x+1,y) if b == 1
  }
end

答案 1 :(得分:1)

这意味着如果你想在x,y位置绘制像素,你可以做一些类似的事情,假设你知道背景颜色的特定颜色:

def point(x,y,color, bg_color)
 stroke color
 line x,y,x,y+1
 stroke bg_color
 line x,y+1,x+1,y+1
end
Shoes.app do
 background white
 point 40,40,blue,white
end

:)

当然,为了密集地绘制像素,它是无用的,但在某些应用中可能很有用。