|
Page 1 of 1
|
[ 4 posts ] |
|
| Author |
Message |
|
dieter
Joined: Tue Aug 19, 2008 3:47 pm Posts: 83
|
 need scripting help
Hi, I will build a effect script with an min and max slider for build a range. What I must do? Value for min are never higher then max value and max value never lower then min value automatic. How program that? Here my not perfect script test. Code: @scriptname="SliderMinMaxRange"; @author="Dieter"; @version="1.0"; @description="11/14/2011";
int maxX=GetMatrixWidth(); int maxY=GetMatrixHeight();
ctrlslider sliderMin={"Min",1,maxX*1/4,maxX}; ctrlslider sliderMax={"Max",1,maxX*3/4,maxX};
void InitEffect(){ // get size maxX=GetMatrixWidth(); maxY=GetMatrixHeight(); }
void RenderEffect(){ Clear(); // clear screen // get value of slider int maxValue=sliderMax.value; int minValue=sliderMin.value; // check range if(maxValue<minValue)maxValue=minValue; if(minValue>maxValue)minValue=maxValue; // set value of slider sliderMax.value=maxValue; sliderMin.value=minValue; // draw rectangle FillPixelRect(WHITE,0,minValue-1,maxX,maxValue-minValue+1); DrawPixelRect(RED, 0,minValue-1,maxX,maxValue-minValue+1); }
void MatrixSizeChanged(){ InitEffect(); }
Can anyone help me?
|
| Thu Nov 17, 2011 10:43 pm |
|
 |
|
Wissmann
Developer
Joined: Fri Feb 23, 2007 3:36 pm Posts: 338 Location: Germany
|
 Re: need scripting help
try this Code: @scriptname="SliderMinMaxRange"; @author="Dieter"; @version="1.0"; @description="11/14/2011";
int maxX,maxY; ctrlslider sliderMin={"Min",1,100,100,"Min"}; ctrlslider sliderMax={"Max",1,100,100,"Max"};
void InitEffect() { // get size maxX=GetMatrixWidth(); maxY=GetMatrixHeight();
//Init Slider ranges int sMin = (int)((float)maxY*0.25); sliderMin.rangeMax = sMin; sliderMin.value = sMin; int sMax = (int)((float)maxY*0.75); sliderMax.rangeMax = sMax; sliderMax.value = sMax; }
void RenderEffect() { Clear(); // clear screen //check range if(sliderMax.value < sliderMin.value) sliderMax.value = sliderMin.value; if(sliderMin.value > sliderMax.value) sliderMin.value = sliderMax.value;
// draw rectangle FillPixelRect(WHITE,0,sliderMin.value-1,maxX,sliderMax.value-sliderMin.value+1); DrawPixelRect(RED, 0,sliderMin.value-1,maxX,sliderMax.value-sliderMin.value+1); }
void MatrixSizeChanged() { InitEffect(); }
_________________ LED´s are nothing without control
|
| Fri Nov 18, 2011 9:56 am |
|
 |
|
dieter
Joined: Tue Aug 19, 2008 3:47 pm Posts: 83
|
 Re: need scripting help
Hi wissmann, sorry but you don't understand my problem. I don't will limit the range of slider or output.
I want: If I slide the max slider lower the min slider then also move the min slider lower. If I slider the min slider higher the max slider then also move the max slider higher.
If you test my script you see one direction running fine but the inverse way running not really good.
|
| Fri Nov 18, 2011 9:57 pm |
|
 |
|
Pinzer
Developer
Joined: Thu Feb 15, 2007 2:47 pm Posts: 24 Location: Dresden, Germany
|
 Re: need scripting help
Hi dieter, maybe this is what you are looking for. Code: @scriptname="SliderMinMaxRange"; @author="Dieter"; @version="1.0"; @description="11/14/2011";
int maxX=GetMatrixWidth(); int maxY=GetMatrixHeight();
ctrlslider sliderMin={"Min",1,maxX*1/4,maxX}; ctrlslider sliderMax={"Max",1,maxX*3/4,maxX};
void InitEffect(){ // get size maxX=GetMatrixWidth(); maxY=GetMatrixHeight(); }
void RenderEffect(){ Clear(); // clear screen // get value of slider int maxValue=sliderMax.value; int minValue=sliderMin.value; int newmaxValue=maxValue; int newminValue=minValue; // check range if(minValue>maxValue)newmaxValue=minValue; if(maxValue<minValue)newminValue=maxValue; // set value of slider sliderMax.value=newmaxValue; sliderMin.value=newminValue; // draw rectangle FillPixelRect(WHITE,0,minValue-1,maxX,newmaxValue-newminValue+1); DrawPixelRect(RED, 0,minValue-1,maxX,newmaxValue-newminValue+1); }
void MatrixSizeChanged(){ InitEffect(); }
|
| Mon Nov 21, 2011 1:52 pm |
|
 |
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
|
|