Why I need add empty ccclippingnode between each slice part? - cocos2d-x

I split a ball into two part with ccclipingnode. but I found that I need create empty ccclipingnode or will cliping strange.
if(new1VecsCount>=3)addChild(Box2dItemSlice::createSliceBody(box->box2dBody->GetPosition(), box->box2dBody->GetAngle(), new1VecsSorted, new1VecsCount,pRot1));
addChild(CCClippingNode::create(CCNode::create()));
if(new2VecsCount>=3)addChild(Box2dItemSlice::createSliceBody(box->box2dBody->GetPosition(), box->box2dBody->GetAngle(), new2VecsSorted, new2VecsCount,pRot2));
addChild(CCClippingNode::create(CCNode::create()));

here is the solution: http://blog.csdn.net/jusnxie/article/details/9277121
goto CCClippingNode::visit function, find "ccDrawSolidRect" line and modify :
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(!m_bInverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); winSize]), ccc4f(1, 1, 1, 1));
ccDrawSolidRect(CCPointZero, ccpFromSize(CCDirector::sharedDirector()->getWinSize()), ccc4f(1, 1, 1, 1));
change to :
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glClearStencil(!m_bInverted ? 0 : ~0);
glStencilOp(!m_bInverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); winSize]), ccc4f(1, 1, 1, 1));
ccDrawSolidRect(CCPointZero, ccpFromSize(CCDirector::sharedDirector()->getWinSize()), ccc4f(1, 1, 1, 1));
glClear(GL_STENCIL_BUFFER_BIT);
You just need add "glClearStencil(!m_bInverted ? 0 : ~0);" and "glClear(GL_STENCIL_BUFFER_BIT);" to the right position.

Related

Values from a Range not coming up as an array

I am unable to obtain an array from a getRange.getValues call to some data on a sheet, i.e. no brackets []. If I just create an array in the code I am OK. I am trying to use indexOf to locate a specific date. In my real code the date to match is also plucked from the sheet.
In the following test code the vars are global and not shown here.
function testArray() {
var rowTwoDates = playgroundSheet.getRange(2, 59, 1, 5).getValues();
var strippedRowTwoDates = rowTwoDates[0].map(stripTime);
Logger.log('array: ' + strippedRowTwoDates);
Logger.log('indexOf: ' + strippedRowTwoDates[0].indexOf("06/09/2022"));
var scores = [10, 20, 30, 10, 40, 20];
Logger.log(scores); // 2
Logger.log(scores.indexOf(30)); // 2
}
9:38:23 AM Notice Execution started
9:38:24 AM Info array: 06/07/2022,06/08/2022,06/09/2022,06/10/2022,06/11/2022
9:38:24 AM Info indexOf: -1
9:38:24 AM Info [10.0, 20.0, 30.0, 10.0, 40.0, 20.0]
9:38:24 AM Info 2.0
9:38:24 AM Notice Execution completed
You're only checking indexOf for the first value in the array here:
Logger.log('indexOf: ' + strippedRowTwoDates[0].indexOf("06/09/2022"));
I think you want to do this:
Logger.log('indexOf: ' + strippedRowTwoDates.indexOf("06/09/2022"));

Datatables - where with two conditions

I used the following statement to filter records by subject ids. (Here subject_id=5)
$this->datatables->where('letter_letter.subject_id', 5);
That is working perfectly. Further I want to filter records in subject_id range like 1 to 10. Then I changed my code as follows :
$this->datatables->where('letter_letter.subject', 10, '<');
But did not get the desired output. How can I edit my code to get expected result ? Can anyone help me ?
Just use two calls to where() to define the range:
$this->datatables->where('letter_letter.subject_id >= ', 1);
$this->datatables->where('letter_letter.subject_id <=', 10);
This is one way you can make a where query with two conditions:
$this->datatables->where("letter_letter.subject_id IS ? AND letter_letter.subject BETWEEN ? AND ?", 5, 1, 10)

Javascript. Is there an easier way to replace text if certain strings are found?

I'm working with Google Sheets Script Editor and I'm trying to do a check to see if a cell contains the text DROPPED, DENIED, WEBSITE, POTENTIAL, SELECTED, TESTING, INACTIVE, or ACTIVE. If it contains DROPPED or DENIED, I need it to say "DENIED", if it says SELECTED/TESTING/INACTIVE/ACTIVE, it needs to say "ACCEPTED", and if it says WEBSITE/POTENTIAL it needs to say "INCOMPLETE".
My code looks roughly like this. I don't have any formal training so it's probably a mess, but hopefully there's an easier way to do it.
if (('' + data1[i][1]).trim().toUpperCase() == "DROPPED" ||
('' + data1[i][1]).trim().toUpperCase() == "DENIED") {
sh2.getRange(j + 1, 11, 1, 1).setValue("DENIED");
}else if (('' + data1[i][1]).trim().toUpperCase() == "SELECTED" ||
('' + data1[i][1]).trim().toUpperCase() == "TESTING" ||
('' + data1[i][1].trim().toUpperCase() == "INACTIVE" ||
('' + data1[i][1].trim().toUpperCase() == "INACTIVE" ||
('' + data1[i][1].trim().toUpperCase() == "ACTIVE") {
sh2.getRange(j + 1, 11, 1, 1).setValue("ACCEPTED");
}else if (('' + data1[i][1]).trim().toUpperCase() == "WEBSITE" ||
('' + data1[i][1]).trim().toUpperCase() == "POTENTIAL") {
sh2.getRange(j + 1, 11, 1, 1).setValue("INCOMPLETE");
I'm pulling this from a "Cross Check" script that's comparing cell contents between two different sheets, which is why it's using sh2.getRange. Mostly I'm just wondering if there's an easier way to write it than that huge if/elseif. If not, that's fine, it's just going to need to run a couple thousand checks so if I can do it in a way that minimizes the amount of legwork the script does, that would be better.
The only thing I can think of is just forcing the cell to be upper case before it does the checks, and then putting it back to proper case when the checks are done. I don't know if continuing to do toUpperCase is going to take more time or not. Honestly I don't know entirely how that even works, I just know it does. We contracted out the original script and I don't know exactly what he did, he didn't comment anything so I had to figure it out myself.
sh2.getRange(j + 1, 11, 1, 1).setValue(ParseData(data1[i][1]));
function ParseData(data) {
switch (('' + data).trim().toUpperCase()) {
case "SELECTED":
case "TESTING":
case "INACTIVE":
case "ACTIVE":
{
return "ACCEPTED";
}
case "DROPPED":
case "DENIED":
{
return "DENIED";
}
case "WEBSITE":
case "POTENTIAL":
{
return "INCOMPLETE";
}
default:
{
return "";
}
}
}
Create 3 arrays of groupings
Then you can simply check if value is in one of the arrays then print the respective value.
eg: using one array grouping to get the value denied.
let deniedArray = ['DENIED','DROPPED'];
let value = data1[i][1]).trim().toUpperCase();
if( deniedArray.includes(value) ){
sh2.getRange(j + 1, 11, 1, 1).setValue("DENIED");
}

NetSuite - Creating PO with line items

Using Restlets I can create any records in NetSuite. However, how do we create records with line items? I know we can use the getLineItemCount, loop through these items and use the setLineItemValue to set the line item.
What I'm not sure about is how we would pass such data to start with. So, we expect an external system to submit some data which I would then need to create POs with line items using my Restlet.
I would ideally like to test this using fire fox Poster, but not sure how to model the data. Something like this works fine to create a normal record using poster by passing data like:
{ "subsidiary" : 2, "entity" : 1084,"currency" : 2,"approvalstatus" : 2}
But how would we send line item data?
My JSon Object looks like this:
{"subsidiary" : 2,
"entity" : 1275,
"currency" : 2,
"approvalstatus" : 2,
"item": [{"item" : -3, "taxrate": 6},
{"item" : -3, "taxrate": 6}]
}
I tried getting the data out of the nested jason object with the below code but doesn't quite work...the itemid is blank
for (var x = 1; x <= jsonobject.item.length; x++)
{
var itemid = record.getLineItemValue('item', jsonobject.item['item'], x);
nlapiLogExecution('DEBUG', 'itemid', itemid)
record.setLineItemValue('item', itemid, x);
}
You could try using an array within your JSON to encapsulate the line items such as:
{"subsidiary" : 2,
"entity" : 1084,
"currency" : 2,
"approvalstatus" : 2,
"items": [{name:"item1", price: "100"},
{name:"item2", price:"200"}]
}
Your RESTlet code would have to then digest this, and call the relevant NS functions you mention.
As TonyH mentioned, your code has a bug wherein you should be getting the array index first. In addition, your index should start at 0, not 1, since you are going through a JS array, not a NetSuite sublist:
for (var x = 0; x < jsonobject.item.length; x++)
{
var itemid = jsonobject.item[x]['item'];
}
The same would go if you want to get the tax rate:
for (var x = 0; x < jsonobject.item.length; x++)
{
var taxrate = jsonobject.item[x]['taxrate'];
}

How to remove bars for those bars with zero value in Chartjs bar chart?

Even if the bars have value of zero in bar chart created using chartjs, they still show a visible bar. This is misleading for my purpose and I would like to have it removed and show nothing there (meaning that, I still want to show labels with zero value but not the bar). I tried changing min value of y-axis but it doesn't make a difference. The image below shows this problem for columns 56, 60 and 78. Is there a way to get rid of this? Thanks!
And here is my script:
<div>
<canvas id="canvas_bar" height="250", width = "300" ></canvas>
</div>
<script>
var barChartData = {
labels : [56, 60, 78, 90],
datasets : [
{ fillColor : "rgba(139,0,0,0.5)",
strokeColor : "rgba(220,220,220,0.8)",
data : [20.0, 0, 0, 50] },
{ fillColor : "rgba(1,187,205,0.5)",
strokeColor : "rgba(151,187,205,0.8)",
data : [0, 0.0, 40.0, 10] }
]
}
window.onload = function(){
var ctx = document.getElementById("canvas_bar").getContext("2d");
window.myBar = new Chart(ctx).Bar(barChartData, {
animation: false,
responsive : false,
barValueSpacing : 15,
scaleShowVerticalLines: false,
});
}
</script>
By default the barStrokeWidth value is 2.
Just add this :
barStrokeWidth:0,
or :
barShowStroke : false,
In your options.
http://www.chartjs.org/docs/#bar-chart-chart-options
//Boolean - If there is a stroke on each bar
barShowStroke : true,
//Number - Pixel width of the bar stroke
barStrokeWidth : 2,
update December 2021:
barStrokeWidth is deprecated.
I used inflateAmount: 0 (default value is auto) and it fixed the issue for me
docs: https://www.chartjs.org/docs/latest/charts/bar.html#dataset-properties
if barShowStroke : true
not working try to
barRadius: 0
I found that you can add skipNull property to dataset objects. And bars where value is null or undefined won't take any space.
https://www.chartjs.org/docs/3.2.0/charts/bar.html