Hello everyone. First time post, so I hope I'm abidding by the rules.
I have a six position sprite 'film strip' of a knob that I'd like to implement as the visual element for a Slider object. But before I do that, I need to figure out how to 'subdivide' the source image for use.
From what I've seen in the forums and the API docs, my best approach would be to define a frame representing the dimensions to view a portion of the image, and then use RectanglePlacement to move the underlying image within the frame. However, I'm a bit confused of how to properly use RectanglePlacement. Currently I have the asset stored as a BinaryImage object in the project, and it's source dimensions are 96x762
Let's say my DrawableImage is defined in my editor constructor as:
bass_cut_1 = (DrawableImage*)DrawableImage::createFromImageData(BinaryData::Bass_Cut_png, BinaryData::Bass_Cut_pngSize);
And my paint() method my frame size is defined as:
juce::Rectangle<float> frameDim (96, 127);
Generic RetanglePlacement Object:
(The 'pileOFlags' is a stand-in for my lack of understanding of how to properly implement the flags for RectanglePlacement.)
And I attempt to draw the portion of the image I want using this:
bass_cut_1->drawWithin(g, frameDim, framePosition, 1);
My questions are three-fold:
- Does this seem like a reasonable approach?
- If so, what would be the proper flags to set to show only a portion of the source image, while preserving aspect ratio?
- Is there perhaps a better class/method to do this with?
Edit: I see now that the enum flags in the constructor are simply bitwise operators to be combined into a single argument. However, I still have a lack of understanding of the flags themselves, and whether or not I am considering this problem properly.