Draw trapezoid
-
How can I draw a trapezoid in a paint routine?
-
-
@Lindon could I fill that in?
-
@mmprod said in Draw trapezoid:
@Lindon could I fill that in?
depends on the complexity of your shape - or you can use a path....if your shape is predefined.
-
@Lindon hmm- I want to be able to adjust the width and height of the trapezoid- can I stretch a path like that perhaps?
-
@mmprod maybe read the documentation?
https://docs.hise.dev/scripting/scripting-api/graphics/index.html#fillpath
-
@mmprod Maybe something like this?
HiseSnippet 1044.3ocsV8taaaCDmxIpqwacXEXO.B8S1qdtRw+IoHaXs1IdyXMoFydECvHnfVhxhHxjBhTMyqnOK60YON6MX6HojkbSVZqAl9fft69c79w6NdTSR49DgfmhrpOacBAY8E1SWyjQCivTFZ7oHquz9brPRRcLpFrNAKDj.jk0d+nRg0A6izO+8OL.GiY9jRUHzq3TexKnqnxRsSd1OSiiGgCHynqpft6yF6yYC4w7LfO6Y6hRv9WgWRt.qfUyF8SXQDx5ar66+zdtKHt85cb2NG2sa+t864F51Ibww86tnyQc6DzsmmeGj08NKfJ4oSkXIQ.K5.dv5oQ7qYl.7JpftHlnD7PSgHaTiFFQiClTjbDHj09SJSU6YRUes84z.5F8koruRavozipIMqZ2Ek79DnjUEJsugROzdpeJMQVZQwmO2dLCpfgXn1TkJFrnZ+4d1C4.Blr8J7UjQofvFOZbnqaKG3UySpWGpOBoyavoNSvLRry26T33RhbHeUBmABMdj15iTd7jm3LkHcxRbjQDvKJS9K7LIkQpqA0VPjU01HLi4KobVikMq+15NviJb3TBFhlLhJTg5Ebeb7.dFKPzX9kPbT3V1ND5qddbbCSOjn80QTIo4IN.IL70XntFNnbVJNg7GbZfSBGnfXS3LhP.mqUodl2CRCd8burk10Aboju5aiIgxRHdkXJgjRWFUEyg8Z4rYYlwSde.GYrWPQ.vlfb4I0y2oBU5VsW1rWWDmkuUK2U+ma2IXYT4lEDpTI8gTsjnPzHOwpeoP0VHwoxKHWOMagFfIOM28x4pMTojWQMIjm5zfBqt2INTmuKGR6XBaoLBT83G2Ti6sa1+53DCcBy3EKOcqkmVY4eWI07i4BRAuZtIQoZILTEd0R2GYxRi.C5dRkg5uC7nnyygytfKIuj0P0AdPcHHuuovva0lJElxiiIo2pY03tz6xwFrrUKHosfxhpZV.DNdu8Li68wMyv2TQq.jyFynxWlPxkGwiCTyBTeeyILn7VB3qec7oXIVMzIWGfKgjJoJ5XcJ4MvXdyHnCrOkHtRxSzXymH.TVps9fhATpiiHJD5Oy178uW8Zi0UEtlFHgw91V+EHDQTmVJjP2bDHL7kGjEikaOQVcWUtAHku0XP0nNlfJWW8trOgwzt24X5OVJ9P6IToezsywZ2BGghw+GbL+xsGXeVXHwWVRv8sG8a65MYefval8u7brLkB8A1WjsZJL3xm.QmAMGBU8tlpgzH6pjUYfoDVfV3efmbidJYqbidEFQqv9o7W6aNnot979ZM.mX5eu3.3+b.YGOj9vW077J317W66u8RcCGObWcryt5X2c0wd6pi82UGOZWc73Oripe154YvUsliMHz4SNSOsxx5LFF5.0cqn+EfMoevb
If you need a stroke style for it you would need to refer to the documentation:
https://docs.juce.com/master/classPathStrokeType.html#af1cf21018ccb9aa84572c1da4ae513b8
https://docs.hise.audio/scripting/scripting-api/graphics/index.html#drawpath -
@Lindon thanks!
-
@HISEnberg @Lindon @mmprod I've added a
Path.addQuadrilateral()
method some times ago. This leverages the need for a loop by allowing to set the 4 points directly.Panel.setPaintRoutine(function(g) { g.fillAll(Colours.white); var p = [ [50, 150], // Bottom-left [150, 150], // Bottom-right [125, 50], // Top-right [75, 50] // Top-left ]; var path = Content.createPath(); path.addQuadrilateral(p[0], p[1], p[2], p[3]); g.setColour(Colours.blue); g.fillPath(path, path.getBounds(1.0)); });
-
@ustk very nice this is a much better method.