Search Results

Search found 902 results on 37 pages for 'circle'.

Page 4/37 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to paints a transparent circle like using CGContextClearRect to draw a transparent rectangle

    - by user177946
    Hello All, Do anyone know how I can draw a transparent circle on a CALayer just like using CGContextClearRect to draw a transparent rectangle? My requirements is that I need to draw a mask on a picture, in some cases, I need to erase it, but CGContextClearRect only allow to draw a rectangle, I wonder if there is another way to do the same thing and draw a tranparent circle. Regards, Anto

    Read the article

  • drawing circle without floating point calculation

    - by zaharpopov
    This is common interview question (according to some interview sites) but I can find no normal answers in Internet - some are wrong and some point to complex theory I expect not looked for in interview (like Bressenham algorithm). The question is simple: The circle equation is: x^2 + y^2 = R^2. Given R, draw 0,0-centered circle as best as possible without using any floating point (no trigo, square roots, and so on, only integers)

    Read the article

  • How to attach an object to a rotating circle in box2d cocos2d?

    - by armands
    I am trying to make an object get attached on a collision point to a circle that is rotating, but the player needs to get attached with a constant point on the player. For example the player is moving back and forth and when the user touches the screen and the player jumps up but what I need is that when the player collides with the circle it attaches it's legs to it and continues rotating with the circle. So I wanted to know how to make this kind of collision joint in cocos2d box2d?

    Read the article

  • Attempted to render a circle in opengl es 1.1, renders as oval

    - by eipxen
    Hi all, I attempted to render a circle in opengl es 1.1 as a test before building a larger program, but it renders as an oval. Here is the code I use to generate and render my vertices: static const int numVerts = 40; static GLfloat myFirstCircle[82]; myFirstCircle[0] = 0.0f; myFirstCircle[1] = 0.0f; for (int i = 2; i < (numVerts+1)*2; i+=2) { myFirstCircle[i] = .5 * cosf(i*2*3.14159/numVerts); myFirstCircle[i+1] = .5 * sinf(i*2*3.14159/numVerts); } glVertexPointer(2, GL_FLOAT, 0, myFirstCircle); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_TRIANGLE_FAN, 0, 22); I'm still somewhat new to this system, so I may have a silly error that I do not see, but it seems to me like this should generate 40 vertices on a circle of radius .5. When it renders, the shape on screen appears to be an oval, significantly taller than it is wide. My question is thus: why is my circle rendering this way, and what could I do to fix it? This is the first question on stackoverflow, so I'm not sure how to share an image of my output.

    Read the article

  • OpenGL circle rotation

    - by user350632
    I'm using following code to draw my circles: double theta = 2 * 3.1415926 / num_segments; double c = Math.Cos(theta);//precalculate the sine and cosine double s = Math.Sin(theta); double t; double x = r;//we start at angle = 0 double y = 0; GL.glBegin(GL.GL_LINE_LOOP); for(int ii = 0; ii < num_segments; ii++) { float first = (float)(x * scaleX + cx) / xyFactor; float second = (float)(y * scaleY + cy) / xyFactor; GL.glVertex2f(first, second); // output Vertex //apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; } GL.glEnd(); The problem is that when scaleX is different from scaleY then circles are transformed in the right way except for the rotation. In my code sequence looks like this: circle.Scale(tmp_p.scaleX, tmp_p.scaleY); circle.Rotate(tmp_p.rotateAngle); My question is what other calculations should i perform for circle to rotate properly when scaleX and scaleY are not equal?

    Read the article

  • Center text inside a circle on a canvas

    - by jax
    I have the coordinates of the center of a circle where I need to draw some text. The circle may be larger or smaller depending on the attributes I have specified. I have set the center horizontally using mTextBrush.setTextAlign(Align.CENTER);. The problem is that I can't figure out a way to center the text vertically. (See "Draw the counter" below) //Text Brush setup mTextBrush = new Paint(Paint.ANTI_ALIAS_FLAG); mTextBrush.setColor(Color.BLACK); mTextBrush.setTextSize(1/10*mMaxSize); mTextBrush.setTextAlign(Align.CENTER); mTextBrush.setStyle(Paint.Style.STROKE); private void drawSmallTimer(Canvas canvas) { //Variable cache int radiusLocalCache = this.mRadius; int cx = radiusLocalCache+(radiusLocalCache/2); int cy = radiusLocalCache-(radiusLocalCache/2); int radius = radiusLocalCache/3; //Draw the background circle canvas.drawCircle(cx, cy, radius, mBackgroundBrush); //Draw the outline stroke canvas.drawCircle(cx, cy, radius, mStrokeBrush); //Draw the counter String text = String.valueOf(mCounter); canvas.drawText(text, cx, cy, mTextBrush); }

    Read the article

  • The text in a circle.

    - by kalininew
    Prompt how to solve a problem, please. There is a block with the text of the unknown sizes. It is necessary to spin (with pouring inside) round this block that the text was in a circle (without dependence from the sizes of the text). At change of the sizes of the text (at window compression) the circle should vary dynamically. It is necessary to make it in browser. From what to me to start to solve the given problem? Can be methods javascript (on a site it is connected jQuery)? P.S. The decision should be ???????????????.

    Read the article

  • LWJGL Circle program create's an oval-like shape

    - by N1ghtk1n9
    I'm trying to draw a circle in LWJGL, but when I draw I try to draw it, it makes a shape that's more like an oval rather than a circle. Also, when I change my circleVertexCount 350+, the shape like flips out. I'm really not sure how the code works that creates the vertices(I have taken Geometry and I know the basic trig ratios). I haven't really found that good of tutorials on creating circles. Here's my code: public class Circles { // Setup variables private int WIDTH = 800; private int HEIGHT = 600; private String title = "Circle"; private float fXOffset; private int vbo = 0; private int vao = 0; int circleVertexCount = 300; float[] vertexData = new float[(circleVertexCount + 1) * 4]; public Circles() { setupOpenGL(); setupQuad(); while (!Display.isCloseRequested()) { loop(); adjustVertexData(); Display.update(); Display.sync(60); } Display.destroy(); } public void setupOpenGL() { try { Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); Display.setTitle(title); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(-1); } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } public void setupQuad() { float r = 0.1f; float x; float y; float offSetX = 0f; float offSetY = 0f; double theta = 2.0 * Math.PI; vertexData[0] = (float) Math.sin(theta / circleVertexCount) * r + offSetX; vertexData[1] = (float) Math.cos(theta / circleVertexCount) * r + offSetY; for (int i = 2; i < 400; i += 2) { double angle = theta * i / circleVertexCount; x = (float) Math.cos(angle) * r; vertexData[i] = x + offSetX; } for (int i = 3; i < 404; i += 2) { double angle = Math.PI * 2 * i / circleVertexCount; y = (float) Math.sin(angle) * r; vertexData[i] = y + offSetY; } FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(vertexData.length); vertexBuffer.put(vertexData); vertexBuffer.flip(); vao = glGenVertexArrays(); glBindVertexArray(vao); vbo = glGenBuffers(); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER,vertexBuffer, GL_STATIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } public void loop() { glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexData.length / 2); glDisableVertexAttribArray(0); glBindVertexArray(0); } public static void main(String[] args) { new Circles(); } private void adjustVertexData() { float newData[] = new float[vertexData.length]; System.arraycopy(vertexData, 0, newData, 0, vertexData.length); if(Keyboard.isKeyDown(Keyboard.KEY_W)) { fXOffset += 0.05f; } else if(Keyboard.isKeyDown(Keyboard.KEY_S)) { fXOffset -= 0.05f; } for(int i = 0; i < vertexData.length; i += 2) { newData[i] += fXOffset; } FloatBuffer newDataBuffer = BufferUtils.createFloatBuffer(newData.length); newDataBuffer.put(newData); newDataBuffer.flip(); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, newDataBuffer); glBindBuffer(GL_ARRAY_BUFFER, 0); } } 300 Vertex Count(This is my main problem) 400 Vertex Count - I removed this image, it's bugged out, should be a tiny sliver cut out from the right, like a secant 500 Vertex Count Each 100, it removes more and more of the circle, and so on.

    Read the article

  • How to draw a filled circle in Java?

    - by Roman
    I have a JPanel with a Grid Layout. In the "cells" of the grid I can put different elements (for example JButtons). There is no problems with that. But now I want to put a filled circle in some of the cells. I also would like to relate an ActionListener with these circles. In more details, if I click the circle it disappears from the current cell and appears in another one. How can I do it in Java? I am using Swing.

    Read the article

  • Adapter for circle page indicator in android

    - by Charles LAU
    I am currently working on an android application which have multiple pages. I am trying to use Circle page indicator to allow users view multiple pages by flipping over the screen. Each page has seperate XML file for the view and each page has a button which is bind to a java method in the Activity. I would like to know how to initalise all the buttons in the Activity for multiple pages. Because at the moment, I can only initalise the button for the first page of the views. I cannot initalise the button for second and third page. Does anyone know how to achieve this. I have placed all the jobs to be done for all the buttons in a single activity. I am currently using this indicator : http://viewpagerindicator.com/ Here is my adapter for the circle page indicator: @Override public Object instantiateItem(View collection, int position) { inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); int resid = 0; //View v = null;// inflater.inflate( R.layout.gaugescreen, (ViewPager)collection, false ); switch( position ) { case 0: resid = R.layout.gaugescreen; break; case 1: resid= R.layout.liveworkoutstatisticsscreen; break; case 2: resid = R.layout.mapscreen; break; default: resid = R.layout.gaugescreen; break; } View view = inflater.inflate(resid, null); ((ViewPager) collection).addView(view,0); return view; } Does anyone know how to achieve this? Thanks for any help in advance

    Read the article

  • Circle values that don't match any of the ones in a dropdown list

    - by Robert4242
    I created a dropdown list with values and assigned them to one of the columns in a table. When I changed a few, then changed the name of items in the list and removed some I accidentally did some key combination somewhere around Ctrl+Z or Ctrl+Y and Excel highlighted cells in the table that had a value not on the list. The highlighting looks like a red oval around each such cell. How can I toggle it on and off?

    Read the article

  • Mapping a BigInteger to a circle

    - by Martin
    I have a C# system using 160 bit numbers, stored in a BigInteger. I want to display these things on a circle, which means mapping the 0-2^160 range into the 0-2Pi range. How would I do this? The approach that jumps instantly to mind is angle = (number / pow(2, 160)) * TwoPi; However, that has complexities because the division will truncate the result into an integer.

    Read the article

  • how to subtract circle from an arbitrary polygon

    - by George
    Given an arbitary polygon with vertices stored in either clockwise/counterclockwise fashion (depicted as a black rectangle in the diagram), I need to be able to subtract an arbitrary number of circles (in red on the diagram) from that polygon. Removing a circle could possibly split the polygon into two seperate polygons (as depicted by the second line in the diagram). I'm not sure where to start. http://www.freeimagehosting.net/image.php?89a0276d9d.jpg

    Read the article

  • Spinning a circle in J2ME using a Canvas.

    - by JohnQPublic
    Hello all! I have a problem where I need to make a multi-colored wheel spin using a Canvas in J2ME. What I need to do is have the user increase the speed of the spin or slow the spin of the wheel. I have it mostly worked out (I think) but can't think of a way for the wheel to spin without causing my cellphone to crash. Here is what I have so far, it's close but not exactly what I need. class MyCanvas extends Canvas{ //wedgeOne/Two/Three define where this particular section of circle begins to be drawn from int wedgeOne; int wedgeTwo; int wedgeThree; int spinSpeed; MyCanvas(){ wedgeOne = 0; wedgeTwo = 120; wedgeThree = 240; spinSpeed = 0; } //Using the paint method to public void paint(Graphics g){ //Redraw the circle with the current wedge series. g.setColor(255,0,0); g.fillArc(getWidth()/2, getHeight()/2, 100, 100, wedgeOne, 120); g.setColor(0,255,0); g.fillArc(getWidth()/2, getHeight()/2, 100, 100, wedgeTwo, 120); g.setColor(0,0,255); g.fillArc(getWidth()/2, getHeight()/2, 100, 100, wedgeThree, 120); } protected void keyPressed(int keyCode){ switch (keyCode){ //When the 6 button is pressed, the wheel spins forward 5 degrees. case KEY_NUM6: wedgeOne += 5; wedgeTwo += 5; wedgeThree += 5; repaint(); break; //When the 4 button is pressed, the wheel spins backwards 5 degrees. case KEY_NUM4: wedgeOne -= 5; wedgeTwo -= 5; wedgeThree -= 5; repaint(); } } I have tried using a redraw() method that adds the spinSpeed to each of the wedge values while(spinSpeed0) and calls the repaint() method after the addition, but it causes a crash and lockup (I assume due to an infinite loop). Does anyone have any tips or ideas how I could automate the spin so you do not have the press the button every time you want it to spin? (P.S - I have been lurking for a while, but this is my first post. If it's too general or asking for too much info (sorry if it is) and I either remove it or fix it. Thank you!)

    Read the article

  • How to find 2D grid cells swept by a moving circle?

    - by Nevermind
    I'm making a game based on a 2D grid, with some cells passable and some not. Dynamic objects can move continuously, independent of the grid, but need to collide with impassable cells. I wrote an algorithm to trace a ray against the grid, that gives me all cells that ray intersects. However, actual object are not point-sized; I'm currently representing them as circles. But I can't figure out an effective algorithm to trace a moving circle. Here's a picture of what I need: The numbers show in what order the circle collides with grid cells. Does anybody know the algorithm to find these collisions? Preferably in C#. Update The circle can be bigger than a single grid cell.

    Read the article

  • Moving a sprite around the circumference of a circle in Cocos2d-iPhone

    - by CircleOfLife
    I am new to Cocos2d. I have taken a look at the documentation at it looks pretty simple compared to what you need to do using basic Iphone classes such as UIAnimation etc. I want to move a Sprite (eg. Bird, Plane or Car) around the center of a circle around its circumference, smoothly so that even the sprite rotates accordingly. How is this possible in Cocos2d? It would be very helpful if someone can post some basic code. Thanks.

    Read the article

  • Problem trying to move a CCSprite circle in Cocos2d

    - by thyrgle
    Hi, So I am trying to move a CCSprite (which has the picture of a circle and is 32 by 32 pixels) with ccTouchesBegan. I have tried the following: -(void) ccTouchesBegan:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint location = [touch locationInView:touch.view]; if ((location.x <= L1Circle1.position.x + 32 && location.x >= L1Circle2.position.x - 32) && (location.y <= L1Circle1.position.y + 32 || location.y >= L1Circle2.position.y - 32)) { L1Circle1.position = ccp(location.x, location.y); } } But, when I touch the screen in the simulator nothing happens... What am I doing wrong?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >