loadImage - use in inline function
-
I was previously loading this image via LAF but now I have to draw my knob in an inline function so how do I get the image back in? The below results in the image being undefined.... Obviously it's expecting a string
const var HaloSlider = Engine.loadImageIntoPool("{PROJECT_FOLDER}H3 KB BACK 1.png"); inline function drawModSlider(g, obj) { g.drawImage(HaloSlider, obj.area, 10, 0);
-
@DanH If this is a paint routine you load the image into the panel, if it's a look and feel function you load the image into the laf object.
-
@d-healey Is it either of those though? I'm drawing a Slider, so not a panel, and I'm not using LAF (I don't think?!)
-
@DanH I'll need to see more code to know what you're doing
-
I'm pretty sure you'll be passing
inline function drawModSlider(g, obj)
into aregisterFunction()
call of a a LAF object, otherwise it won't do anything. -
//KnobLaf3.loadImage("{PROJECT_FOLDER}H3 KB BACK 1.png", "H3KBBK"); const var HaloSlider = Engine.loadImageIntoPool("{PROJECT_FOLDER}H3 KB BACK 1.png"); inline function drawModSlider(g, obj) { local ar = Rectangle(obj.area).reduced(THICKNESS/2 + 2); local n = Rectangle(0.0, 0.0, 1.0, 1.0); local track = Content.createPath(); track.setBounds(n); track.addArc(n, START-0.05, START + ARC_WIDTH+0.05); if(obj.modulationDragState) { if(obj.modulationDragState == 2) { g.setColour(obj.itemColour1); } else { g.setColour(0x44FFFFFF); } g.fillEllipse(ar.reduced(-THICKNESS/2 - 1)); } g.setColour(0x77000000); g.drawPath(track, ar, THICKNESS); local modRange = Content.createPath(); modRange.setBounds(n); modRange.addArc(n, START + obj.modMinValue * ARC_WIDTH, START + obj.modMaxValue * ARC_WIDTH); g.setColour(0x22FFFFFF); g.drawPath(modRange, ar, THICKNESS - 2); local value = Content.createPath(); value.setBounds(n); value.addArc(n, START + obj.valueNormalized * ARC_WIDTH, START + Math.range(obj.scaledValue + obj.addValue, 0.0, 1.0) * ARC_WIDTH); g.setColour(obj.itemColour1); g.drawPath(value, ar, THICKNESS - 4); local thumb = Content.createPath(); thumb.setBounds(n); thumb.addArc(n, START + obj.valueNormalized * ARC_WIDTH - 0.01, START + obj.valueNormalized * ARC_WIDTH + 0.01); g.setColour(Colours.white); g.drawPath(thumb, ar, p); g.drawAlignedText(obj.valueAsText, ar, "centred"); g.setColour(0x55FFFFFF); g.drawAlignedText(obj.text, ar, "centredBottom"); }
-
@DanH I don't see anywhere that you're applying the function to a component, but 99% sure it's going to be laf.
-
@Christoph-Hart said in loadImage - use in inline function:
registerFunction()
ah ok that makes more sense
I can see it now