如何找到屋顶三角形的坐标?
how to find the coordinates of a triangle for the roof?
我想把图片中的那个蓝色三角形放在我的红房子上。我一直在输入随机数,但我做错了。问题出在 Gosu.draw_triangle 部分。人们说这个网站会有所帮助 https://www.rubydoc.info/github/gosu/gosu/master/Gosu.draw_triangle 但我没有从中得到任何好处。
Picture
def initialize
def initialize
super(800, 600, false)
end
def draw
Gosu.draw_rect(310, 300, 200, 150, Gosu::Color::RED, ZOrder::TOP, mode=:default)
Gosu.draw_rect(385, 380, 50, 70, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
Gosu.draw_rect(460, 335, 35, 35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
Gosu.draw_rect(0, 450, 1000, 400, Gosu::Color::GREEN, ZOrder::TOP, mode=:default)
Gosu.draw_rect(200, 100, 100, 45, Gosu::Color::WHITE, ZOrder::TOP, mode=:default)
Gosu.draw_rect(100 , 350, 45, 120, 0xff_AC5B13 , ZOrder::TOP, mode=:default)
Gosu.draw_triangle(20, 30, Gosu::Color::BLUE, 440, 230, Gosu::Color::BLUE, 50, 345, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
Juts 将号码更改为此。 X1 = 405 y1 = 204 x2 = 290 y2 =300 x3 = 530 y3 = 300 picture
Gosu.draw_triangle(405, 204, Gosu::Color::BLUE, 290, 300, Gosu::Color::BLUE, 530, 300, Gosu::Color::BLUE, ZOrder::TOP, 模式=:默认)
要在房顶放置蓝色三角形,需要使三角形两个顶点的Y坐标与矩形顶相同。
需要矩形顶点:ToplLeft, TopRight
三角形顶点:
X1 = ToplLeft.X - OverhangSize
Y1 = ToplLeft.Y
X2 = ToplRight.X + OverhangSize
Y2 = ToplLeft.Y
X3 = (ToplLeft.X + ToplRight.X) / 2 //average vor symmetric roof
Y3 = ToplLeft.Y - RoofHeight
我想把图片中的那个蓝色三角形放在我的红房子上。我一直在输入随机数,但我做错了。问题出在 Gosu.draw_triangle 部分。人们说这个网站会有所帮助 https://www.rubydoc.info/github/gosu/gosu/master/Gosu.draw_triangle 但我没有从中得到任何好处。
Picture
def initialize
def initialize
super(800, 600, false)
end
def draw
Gosu.draw_rect(310, 300, 200, 150, Gosu::Color::RED, ZOrder::TOP, mode=:default)
Gosu.draw_rect(385, 380, 50, 70, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
Gosu.draw_rect(460, 335, 35, 35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
Gosu.draw_rect(0, 450, 1000, 400, Gosu::Color::GREEN, ZOrder::TOP, mode=:default)
Gosu.draw_rect(200, 100, 100, 45, Gosu::Color::WHITE, ZOrder::TOP, mode=:default)
Gosu.draw_rect(100 , 350, 45, 120, 0xff_AC5B13 , ZOrder::TOP, mode=:default)
Gosu.draw_triangle(20, 30, Gosu::Color::BLUE, 440, 230, Gosu::Color::BLUE, 50, 345, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
Juts 将号码更改为此。 X1 = 405 y1 = 204 x2 = 290 y2 =300 x3 = 530 y3 = 300 picture
Gosu.draw_triangle(405, 204, Gosu::Color::BLUE, 290, 300, Gosu::Color::BLUE, 530, 300, Gosu::Color::BLUE, ZOrder::TOP, 模式=:默认)
要在房顶放置蓝色三角形,需要使三角形两个顶点的Y坐标与矩形顶相同。
需要矩形顶点:ToplLeft, TopRight
三角形顶点:
X1 = ToplLeft.X - OverhangSize
Y1 = ToplLeft.Y
X2 = ToplRight.X + OverhangSize
Y2 = ToplLeft.Y
X3 = (ToplLeft.X + ToplRight.X) / 2 //average vor symmetric roof
Y3 = ToplLeft.Y - RoofHeight