erase

How to erase path area from canvas (Android)

前提是你 提交于 2019-12-05 15:12:41
I need to crop corners on ImageView . Not to round them but erase triangles from each corner. Seems like the only way to do that is to override onDraw method and erase these areas from canvas using Path . The problem is I have not solid color background, so I need ERASE these areas but not to fill them with some color. I use following code for that: @Override protected void onDraw(Canvas canvas) { Path path = new Path(); path.moveTo(0, 0); path.lineTo(20, 0); path.lineTo(0, 20); path.close(); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setXfermode(new PorterDuffXfermode

C++ remove certain elements of vector

☆樱花仙子☆ 提交于 2019-12-05 07:32:40
问题 I am new to C++ and want to do vector element elimination. My vectors are like: <vector<vector>> objPoints; <vector<vector>> delPoints; <vector<vector>> objPoints2; each objPoints has size 1000x3 and has all points. From objPoints i want to remove delPoints i.e. the (X,Y,Z) values that reside in each row. Can anyone please tell me syntax? 回答1: I interpret your questions as follows: You have two vectors objPoints and delPoints which contain 1000 three-dimensional points. I would encode this as

Blending a texture to erase alpha values softly with OpenGL

余生颓废 提交于 2019-12-04 19:05:45
问题 I have a little paint application which was based on the GLPaint sample code. It is working fine. My Problem is that I need to implement a "brush" that erases the textures which were already drawn. My goal is to have an eraser which has soft edges. Right now I just took the same texture which I used for drawing but switched the blending functions from glBlendFunc(GL_SRC_ALPHA, GL_ONE); to glBlendFunc(GL_ZERO, GL_ZERO); The result is a square rectangular eraser. That is ok but it's not what I

Problem with invalidation of STL iterators when calling erase

柔情痞子 提交于 2019-12-04 11:29:40
The STL standard defines that when an erase occurs on containers such as std::deque, std::list etc iterators are invalidated. My question is as follows, assuming the list of integers contained in a std::deque, and a pair of indicies indicating a range of elements in the std::deque, what is the correct way to delete all even elements? So far I have the following, however the problem here is that the assumed end is invalidated after an erase: #include <cstddef> #include <deque> int main() { std::deque<int> deq; for (int i = 0; i < 100; deq.push_back(i++)); // range, 11th to 51st element std:

vector::erase() not working as expected

人盡茶涼 提交于 2019-12-04 04:35:10
问题 for(it1=prime.begin();it1<prime.end();it1++){ for(it2=it1+1;it2<prime.end();it2++){ if(*it2%*it1==0){ prime.erase(it2); } } if(*it1<1000) prime.erase(it1); } In above code snippet i am removing numbers that are multiples of number already existing in prime vector 2 to 9999(sieve of Eratosthenes).also I only what numbers that are more then 1000, but somehow these are not getting erased. can someone please explain me why? Thanks in advance. 回答1: Calling erase() invalidates the iterator. You

Remove Duplicate Entries in a C++ Vector

好久不见. 提交于 2019-12-04 04:25:46
Just want to remove duplicates. Pool is vector<pair<string, int>> but I seem to miss some elements at the start of the vector somehow. Can anyone verify the logic of the removal? Thanks :) Pool Master::eliminateDuplicates(Pool generation) { for(int i = 0; i < generation.size(); i++) { string current = generation.at(i).first; for(int j = i; j < generation.size(); j++) { if(j == i) { continue; } else { string temp = generation.at(j).first; if(current.compare(temp) == 0) { Pool::iterator iter = generation.begin() + j; generation.erase(iter); } } } } return generation; } This is a very common

C++ Segmentation when using erase on std::list

青春壹個敷衍的年華 提交于 2019-12-04 04:07:43
I'm trying to remove items from a C++ linked list using erase and a list iterator: #include <iostream> #include <string> #include <list> class Item { public: Item() {} ~Item() {} }; typedef std::list<Item> list_item_t; int main(int argc, const char *argv[]) { // create a list and add items list_item_t newlist; for ( int i = 0 ; i < 10 ; ++i ) { Item temp; newlist.push_back(temp); std::cout << "added item #" << i << std::endl; } // delete some items int count = 0; list_item_t::iterator it; for ( it = newlist.begin(); count < 5 ; ++it ) { std::cout << "round #" << count << std::endl; newlist

C++ remove certain elements of vector

冷暖自知 提交于 2019-12-03 21:42:35
I am new to C++ and want to do vector element elimination. My vectors are like: <vector<vector>> objPoints; <vector<vector>> delPoints; <vector<vector>> objPoints2; each objPoints has size 1000x3 and has all points. From objPoints i want to remove delPoints i.e. the (X,Y,Z) values that reside in each row. Can anyone please tell me syntax? I interpret your questions as follows: You have two vectors objPoints and delPoints which contain 1000 three-dimensional points. I would encode this as std::vector<std::array<int,3> > objPoints; where I assumed you have some raster such that you can desribe

C++ Erasing from list of pairs

老子叫甜甜 提交于 2019-12-03 18:17:55
问题 Very simple: I have the following code and the method erase is not working. I do not see any problem there because if I go to http://www.cplusplus.com/reference/list/list/erase/ , syntax is: iterator erase (iterator position); list<pair<string,int>> l0 { { "name1", 20 }, { "name2", 30 }, { "name3", 40 } }; for( auto &it : l0 ) l0 . erase( it ); May there be a problem that there is a list of pair<string,int> and not a list of a basic data types? EDIT: The problem is that the code is not

Blending a texture to erase alpha values softly with OpenGL

和自甴很熟 提交于 2019-12-03 13:16:02
I have a little paint application which was based on the GLPaint sample code. It is working fine. My Problem is that I need to implement a "brush" that erases the textures which were already drawn. My goal is to have an eraser which has soft edges. Right now I just took the same texture which I used for drawing but switched the blending functions from glBlendFunc(GL_SRC_ALPHA, GL_ONE); to glBlendFunc(GL_ZERO, GL_ZERO); The result is a square rectangular eraser. That is ok but it's not what I actually want. I need soft edges. I want to make a round eraser not a square rectangular. Do you have