Search Results

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

Page 8/37 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Converting between square and rectangular pixel co-ordinates

    - by FlyboyUtah
    I'm new at using transforms and this type of math, and would appreciate some direction solving my coding problem. I'm writing in XCode for the iphone, and am working with CGraphics. Problem: In Xcode, I want to draw curves, lines and so on it's screen of of square pixels. Then convert those points, as close as possible, into non-square pixel sysem. For example if the original coordinate system is 500 x 500 pixels that are displayed on square screen of 10 by 10 inchs I draw a round circle with the circle formula. It looks round, and all is well. Now, I draw the same circle on a second 10 x 10 inch screen that is 850 pixels by 500 pixels. Without changing the coordinates, the same circle formual displays something that looks like an egg. How can I draw the circle on the second screen in a different coordinate system? And in addition, I need to access the set of points x,y system individually. s

    Read the article

  • Wrapping text and div as a unit

    - by mathee
    I have the following that I would like wrapped as units. <div class='tag-box'> <a href=#>Axe Committee</a> <div class='circle'><a href=#>x</a></div> </div> The CSS for these classes are: .tag-box { display:inline; } .circle { display:inline; padding-left:4px; padding-right:4px; background:rgb(196,15,24); /*dark red*/ -moz-border-radius:10px; -webkit-border-radius:10px; } .circle a { font-size:10px; text-decoration:none; color:#fff; position:relative; top:-2px; } I can have upwards of 20 or 30 of these tag-boxes displayed inline. The problem is that the wrapping will break the words from each other or even break the red circle from the link. This makes it hard to differentiate which circle belongs to which link. (In the future, each circle corresponds to a different action with respect to the link.) See below. How do I prevent this kind of wrapping from occurring?

    Read the article

  • AvoidXferMode Tolerance

    - by kayahr
    I have a problem with the following code: protected void onDraw(Canvas canvas) { Paint paint = new Paint(); // Draw a blue circle paint.setColor(Color.BLUE); canvas.drawCircle(100, 100, 50, paint); // Draw a red circle where it collides with the blue one paint.setXfermode(new AvoidXfermode(Color.BLUE, 0, Mode.TARGET)); paint.setColor(Color.RED); canvas.drawCircle(50, 50, 50, paint); } According to the API documentation of AvoidXfermode the tolerance value 0 means that it looks for an EXACT color match. This should work here because I specify the same color as I used for drawing the first circle. But the result is that the red circle is not drawn at all. When I use a tolerance value of 255 instead then it works (red circle is drawn where it collides with the blue one) but that sounds wrong because with such a high tolerance I think it should draw the circle EVERYWHERE. So what's wrong here? API Documentation? Android? Me?

    Read the article

  • viewing data using php and mysql

    - by circle
    hello, i'm circle.very new in php and mysql.i need to develop a website include with database.but i have a problem with this. i'm using php and sql to develop it.my task is: i have two table, investor and commission. investor have three level which is coordinator, consultant and participant.what should i do is, only coordinator can add consultant and participant in their profile.and only coordinator can add participant in their profile. so here, when investor was login, and they go to view commission, they only can see their owned coordinator and participant. but i'm stuck when they want to view the commission.maybe it only a simple thing, but i cannot solved it. help me..:(

    Read the article

  • Best pathfinding for a 2D world made by CPU Perlin Noise, with random start- and destinationpoints?

    - by Mathias Lykkegaard Lorenzen
    I have a world made by Perlin Noise. It's created on the CPU for consistency between several devices (yes, I know it takes time - I have my techniques that make it fast enough). Now, in my game you play as a fighter-ship-thingy-blob or whatever it's going to be. What matters is that this "thing" that you play as, is placed in the middle of the screen, and moves along with the camera. The white stuff in my world are walls. The black stuff is freely movable. Now, as the player moves around he will constantly see "monsters" spawning around him in a circle (a circle that's larger than the screen though). These monsters move inwards and try to collide with the player. This is the part that's tricky. I want these monsters to constantly spawn, moving towards the player, but avoid walls entirely. I've added a screenshot below that kind of makes it easier to understand (excuse me for my bad drawing - I was using Paint for this). In the image above, the following rules apply. The red dot in the middle is the player itself. The light-green rectangle is the boundaries of the screen (in other words, what the player sees). These boundaries move with the player. The blue circle is the spawning circle. At the circumference of this circle, monsters will spawn constantly. This spawncircle moves with the player and the boundaries of the screen. Each monster spawned (shown as yellow triangles) wants to collide with the player. The pink lines shows the path that I want the monsters to move along (or something similar). What matters is that they reach the player without colliding with the walls. The map itself (the one that is Perlin Noise generated on the CPU) is saved in memory as two-dimensional bit-arrays. A 1 means a wall, and a 0 means an open walkable space. The current tile size is pretty small. I could easily make it a lot larger for increased performance. I've done some path algorithms before such as A*. I don't think that's entirely optimal here though.

    Read the article

  • What is a useful pattern to maintaining an object state in a one to many relationship?

    - by ahenderson
    I am looking for a design for my application, here are the players(classes) involved. struct Transform { // Uses a matrix to transform the position. // Also acts acts as the state of a Dialog. Position transform(Position p); //other methods. }; struct Dialog { // There are multiple dialog for the user to transform the output. Transform& t; void ChangeTranformation(){t.rotate(360);} } struct Algorithm { //gives us a position based on an implementation. For example this can return points on a circle or line. Transform& t; Position m_p; Dialog& d; Position GetCurrentPosition(){ return t.transform(m_p);} //other methods. } Properties I need: Each algorithms has one dialog and each dialog can have many algorithms associated with it. When the user selects an algorithm a dialog associated with that algorithm is displayed. If the user selects a different algorithm then re-selects back the state is restored in the dialog. Basically I want a good design pattern to maintain the state of the dialog given that many algorithms use it and they can be switched back and forth. Does anyone have any suggestions? Here is a use case: Dialog1 has a single edit box to control the radius. Algorithm1 generates points on a unit circle. Algorithm2 is the same as Algorithm1. The user has selected Algorithm1 and entered 2 into the edit box. This will generate points on a circle of radius 2. The user then selects Algorithm2 and enters 10 into the edit box of Dialog1. This will generate points on a circle of radius 10. Finally Algorithm1 is selected again. The edit box of Dialog1 should show 2 and points on a circle of radius 2 should be generated.

    Read the article

  • How to change circular icon to indicate chosen session in unity-greeter?

    - by Chan-Ho Suh
    In Precise (12.04), when I login to lightdm, using the unity-greeter, there's a white circle by my name. For the standard DEs like Unity or XFCE, the circle has a representative icon (Ubuntu symbol or little mouse resp.). I have a session for Awesome window manager which was added when I installed Awesome, but it just shows a blank white circle. I'd like to know how to add an icon to it, or at least some indicator, as unity-greeter doesn't show you what session is set until you click on the circle. I found another question about changing the session names. The answer for it said to change the names in the desktop files in /usr/share/xsessions. Unfortunately, while there is an icon field in those desktop files, they are all blank (Caveat: I no longer have Unity installed, so maybe the Unity one would not be blank. But the Xubuntu desktop file has it blank even though the icon shows in unity-greeter). Update: Here's the png I use as a badge for Awesome. It's not great, but looks reasonably nice: []

    Read the article

  • Control convention for circular movement?

    - by Christian
    I'm currently doing a kind of training project in Unity (still a beginner). It's supposed to be somewhat like Breakout, but instead of just going left and right I want the paddle to circle around the center point. This is all fine and dandy, but the problem I have is: how do you control this with a keyboard or gamepad? For touch and mouse control I could work around the problem by letting the paddle follow the cursor/finger, but with the other control methods I'm a bit stumped. With a keyboard for example, I could either make it so that the Left arrow always moves the paddle clockwise (it starts at the bottom of the circle), or I could link it to the actual direction - meaning that if the paddle is at the bottom, it goes left and up along the circle or, if it's in the upper hemisphere, it moves left and down, both times toward the outer left point of the circle. Both feel kind of weird. With the first one, it can be counter intuitive to press Left to move the paddle right when it's in the upper area, while in the second method you'd need to constantly switch buttons to keep moving. So, long story short: is there any kind of existing standard, convention or accepted example for this type of movement and the corresponding controls? I didn't really know what to google for (control conventions for circular movement was one of the searches I tried, but it didn't give me much), and I also didn't really find anything about this on here. If there is a Question that I simply didn't see, please excuse the duplicate.

    Read the article

  • Spritegroups and colorkeys

    - by Fristi
    I have a problem using spritegroups in pygame. In my situation I have 2 spritegroups, one for humans, one for "infected". A human is represented by a blue circle: image = pygame.Surface((32,32)) image.fill((255,255,255)) pygame.draw.circle(image,(0,0,255),(16,16),16) image = image.convert() image.set_colorkey((255,255,255)) An infected by a red one (same code, different color). I update my spritegroups as follows: self.humans.clear(self.screen, self.bg) self.humans.update(time_passed) self.humans.draw(self.screen) self.infected.clear(self.screen, self.bg) self.infected.update(time_passed) self.infected.draw(self.screen) Self.bg is defined: self.bg = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT)) self.bg.fill((255,255,255)) self.bg.convert() This all works, except that when a red circle overlaps with a blue one, you can see the white corners of the bounding box around the actual circle. Within a spritegroup it works, using the set_colorkey function. This does not happen with overlapping blue circles or overlapping red circles. I tried adding a colorkey to self.bg but that did not work. Same for adding a colorkey to self.screen.

    Read the article

  • Collision detection with curves

    - by paldepind
    I'm working on a 2D game in which I would like to do collision detection between a moving circle and some kind of static curves (maybe Bezier curves). Currently my game features only straight lines as the static geometry and I'm doing the collision detection by calculating the distance from the circle to the lines, and projecting the circle out of the line in case the distance is less than the circles radius. How can I do this kind of collision detection in a relative straightforward way? I know for instance that Box2D features collision detection with Bezier curves. I don't need a full featured collision detection mechanism, just something that can do what I've described.

    Read the article

  • Cocos2d and Body with few collision shapes using chipmunk

    - by Eimantas
    I'm using Cocos2d (0.99.5) with chipmunk physics engine. Currently I'm trying to place a body into space which is combined from few circle shapes. Let's say I have a corresponding sprite image with displays atom (nucleus + 3 electrons around it. Something like this without orbit lines). In it's simplest form - only one circle shape at the center should be enough which would detect collisions from other objects with nucleus. Now I'd like to add other circle shapes for each electron. How can I do that? Now when I add those shapes to the body and add the body into chipmunk space - the shapes (together with the body/sprite) start flickering and spinning with no recognizable pattern (or reason for that matter).

    Read the article

  • 2D wave-like sprite movement XNA

    - by TheBroodian
    I'm trying to create a particle that will 'circle' my character. When the particle is created, it's given a random position in relation to my character, and a box to provide boundaries for how far left or right this particle should circle. When I use the phrase 'circle', I'm referring to a simulated circling, i.e., when moving to the right, the particle will appear in front of my character, when passing back to the left, the particle will appear behind my character. That may have been too much context, so let me cut to the chase: In essence, the path I would like my particle to follow would be akin to a sine wave, with the left and right sides of the provided rectangle being the apexes of the wave. The trouble I'm having is that the position of the particle will be random, so it will never be produced at the same place within the wave twice, but I have no idea how to create this sort of behavior procedurally.

    Read the article

  • javaf, problem...plz help someone...urgent [closed]

    - by innovative_aj
    i have made a word guessing game, when i click myButton to check if the guessed word is right or wrong, ball1 is moved into the "container" if its right, i want that when i click the button again and if the typed word is right, the 2nd ball should move into the container too... means one ball per correct answer...plz help me someone and provide me with the code that i can implement, its quite urgent... controller class coding /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package project3; import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.StackPane; import javafx.scene.shape.Circle; /** * FXML Controller class * * @xxx */ public class MyFxmlController implements Initializable { @FXML // fx:id="ball1" private Circle ball1; // Value injected by FXMLLoader @FXML // fx:id="ball2" private Circle ball2; // Value injected by FXMLLoader @FXML // fx:id="ball3" private Circle ball3; // Value injected by FXMLLoader @FXML // fx:id="ball4" private Circle ball4; // Value injected by FXMLLoader @FXML // fx:id="container" private Circle container; // Value injected by FXMLLoader @FXML // fx:id="myButton" private Button myButton; // Value injected by FXMLLoader @FXML // fx:id="myLabel1" private Label myLabel1; // Value injected by FXMLLoader @FXML // fx:id="myLabel2" private Label myLabel2; // Value injected by FXMLLoader @FXML // fx:id="pane" private StackPane pane; // Value injected by FXMLLoader @FXML // fx:id="txt" private TextField txt; // Value injected by FXMLLoader @Override // This method is called by the FXMLLoader when initialization is complete public void initialize(URL fxmlFileLocation, ResourceBundle resources) { assert ball1 != null : "fx:id=\"ball1\" was not injected: check your FXML file 'MyFxml.fxml'."; assert ball2 != null : "fx:id=\"ball2\" was not injected: check your FXML file 'MyFxml.fxml'."; assert ball3 != null : "fx:id=\"ball3\" was not injected: check your FXML file 'MyFxml.fxml'."; assert ball4 != null : "fx:id=\"ball4\" was not injected: check your FXML file 'MyFxml.fxml'."; assert container != null : "fx:id=\"container\" was not injected: check your FXML file 'MyFxml.fxml'."; assert myButton != null : "fx:id=\"myButton\" was not injected: check your FXML file 'MyFxml.fxml'."; assert myLabel1 != null : "fx:id=\"myLabel1\" was not injected: check your FXML file 'MyFxml.fxml'."; assert myLabel2 != null : "fx:id=\"myLabel2\" was not injected: check your FXML file 'MyFxml.fxml'."; assert pane != null : "fx:id=\"pane\" was not injected: check your FXML file 'MyFxml.fxml'."; assert txt != null : "fx:id=\"txt\" was not injected: check your FXML file 'MyFxml.fxml'."; // initialize your logic here: all @FXML variables will have been injected myButton.setOnAction(new EventHandler<ActionEvent>(){ @Override public void handle(ActionEvent event) { int count = 0; String guessed=txt.getText(); boolean result; result=MyCode.check(guessed); if(result) { ball1.setTranslateX(600); ball1.setTranslateY(250-container.getRadius()); //ball2.setTranslateX(600); // ball2.setTranslateY(250-container.getRadius()); } else System.out.println("wrong"); } }); } } word guessing logic public class MyCode { static String x="Netbeans"; static String y[]={"net","beans","neat","beat","bet"}; //static int counter; // public MyCode() { // counter++; //} static boolean check(String guessed) { int count=0; boolean result=false; //counter++; //System.out.println("turns"+counter); for(count=0;count<5;count++) { if(guessed.equals(y[count])) { result=true; break; } } if(result) System.out.println("Right"); else System.out.println("Wrong"); return result; } }

    Read the article

  • Improving Click and Drag with C++

    - by Josh
    I'm currently using SFML 2.0 to develop a game in C++. I have a game sprite class that has a click and drag method. The method works, but there is a slight problem. If the mouse moves too fast, the object the user selected can't keep up and is left behind in the spot where the mouse left its bounds. I will share the class definition and the given function implementation. Definition: class codePeg { protected: FloatRect bounds; CircleShape circle; int xPos, yPos, xDiff, yDiff, once; int xBase, yBase; Vector2i mousePos; Vector2f circlePos; public: void init(RenderWindow& Window); void draw(RenderWindow& Window); void drag(RenderWindow& Window); void setPegPosition(int x, int y); void setPegColor(Color pegColor); void mouseOver(RenderWindow& Window); friend int isPegSelected(void); }; Implementation of the "drag" function: void codePeg::drag(RenderWindow& Window) { mousePos = Mouse::getPosition(Window); circlePos = circle.getPosition(); if(Mouse::isButtonPressed(Mouse::Left)) { if(mousePos.x > xPos && mousePos.y > yPos && mousePos.x - bounds.width < xPos && mousePos.y - bounds.height < yPos) { if(once) { xDiff = mousePos.x - circlePos.x; yDiff = mousePos.y - circlePos.y; once = 0; } xPos = mousePos.x - xDiff; yPos = mousePos.y - yDiff; circle.setPosition(xPos, yPos); } } else { once = 1; xPos = xBase; yPos = yBase; xDiff = 0; yDiff = 0; circle.setPosition(xBase, yBase); } Window.draw(circle); } Like I said, the function works, but to me, the code is very ugly and I think it could be improved and could be more efficient. The only thing I can think of as to why the object cannot keep up with the mouse is that there are too many function calls and/or checks. The user does not really have to mouse the mouse "fast" for it to happen, I would say at an average pace the object is left behind. How can I improve the code so that the object remains with the mouse when it is selected? Any help improving this code or giving advice is greatly appreciated.

    Read the article

  • Understanding ServiceKnownType in WCF

    - by SLC
    I am having a little trouble understanding ServiceKnownType in WCF. Taken from this blog, the following code does not work: [DataContract(Namespace = “http://mycompany.com/”)] public class Shape{…} [DataContract(Namespace = “http://mycompany.com/”)] public class Circle : Shape {…} [ServiceContract] public interface IMyServer { [OperationContract] bool AddShape(Shape shape); } . IMyServer client = new ChannelFactory<IMyServer>(binding, endPoint).CreateChannel(); client.AddShape(new Circle()); The reason it doesn't work is because you are trying to add a circle, but the servicecontract only allows a Shape. You are supposed to do something with knowntypes, but I am a bit confused about how that works. Since that code is in the service, why doesn't it know automatically that a Circle is derived from Shape? Additionally, what does ServiceKnownType actually do? When ServiceKnownType is put below the DataContract, apparently that makes it work. I am guessing it says hey, this particular object type called Shape can also be a Circle. I am having trouble understanding why it would do it this way around, because if you add a new type like Square you are going to have to add that too, wouldn't it make sense if it cannot infer it, to put the KnownType onto the Square rather than the Shape? So the Square says hey, I am a Shape, and you don't have to fiddle with the Shape class?

    Read the article

  • Why does Raphael's framerate slow down on this code?

    - by Bob
    So I'm just doing a basic orbit simulator using Raphael JS, where I draw one circle as the "star" and another circle as the "planet". It seems to be working just fine, with the one snag that as the simulation continues, its framerate progressively slows down until the orbital motion no longer appears fluid. Here's the code (note: uses jQuery only to initialize the page): $(function() { var paper = Raphael(document.getElementById('canvas'), 640, 480); var star = paper.circle(320, 240, 10); var planet = paper.circle(320, 150, 5); var starVelocity = [0,0]; var planetVelocity = [20.42,0]; var starMass = 3.08e22; var planetMass = 3.303e26; var gravConstant = 1.034e-18; function calculateOrbit() { var accx = 0; var accy = 0; accx = (gravConstant * starMass * ((star.attr('cx') - planet.attr('cx')))) / (Math.pow(circleDistance(), 3)); accy = (gravConstant * starMass * ((star.attr('cy') - planet.attr('cy')))) / (Math.pow(circleDistance(), 3)); planetVelocity[0] += accx; planetVelocity[1] += accy; planet.animate({cx: planet.attr('cx') + planetVelocity[0], cy: planet.attr('cy') + planetVelocity[1]}, 150, calculateOrbit); paper.circle(planet.attr('cx'), planet.attr('cy'), 1); // added to 'trace' orbit } function circleDistance() { return (Math.sqrt(Math.pow(star.attr('cx') - planet.attr('cx'), 2) + Math.pow(star.attr('cy') - planet.attr('cy'), 2))); } calculateOrbit(); }); It doesn't appear, to me anyway, that any part of that code would cause the animation to gradually slow down to a crawl, so any help solving the problem will be appreciated!

    Read the article

  • Android: Get the X and Y coordinates of a TextView?

    - by Jep Knopz
    I am working now on a project. I have 2 draggable textView in a circle. I want to add those value inside the circle when the circle is drag over the other circle. the first option that I have is to get the X and Y of the circle, but I get it. Can anyone fix my code? Here is the Code: MainActivity public class MainActivity extends Activity { int windowwidth; int windowheight; TextView bola; TextView bola2; private float x; private float y; private android.widget.RelativeLayout.LayoutParams layoutParams; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); windowwidth = getWindowManager().getDefaultDisplay().getWidth(); windowheight = getWindowManager().getDefaultDisplay().getHeight(); bola = (TextView) findViewById(R.id.ball); bola2 = (TextView) findViewById(R.id.ball2); bola2.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub layoutParams = (RelativeLayout.LayoutParams) bola2 .getLayoutParams(); switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: int x_cord = (int) event.getRawX(); int y_cord = (int) event.getRawY(); if (x_cord > windowwidth) { x_cord = windowwidth; } if (y_cord > windowheight) { y_cord = windowheight; } layoutParams.leftMargin = x_cord - 25; layoutParams.topMargin = y_cord - 75; bola2.setLayoutParams(layoutParams); break; default: break; } return true; } }); bola.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { layoutParams = (RelativeLayout.LayoutParams) bola .getLayoutParams(); switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: int x_cord = (int) event.getRawX(); int y_cord = (int) event.getRawY(); if (x_cord > windowwidth) { x_cord = windowwidth; } if (y_cord > windowheight) { y_cord = windowheight; } layoutParams.leftMargin = x_cord - 25; layoutParams.topMargin = y_cord - 75; bola.setLayoutParams(layoutParams); break; default: break; } // TODO Auto-generated method stub return true; } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; }} Activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id= "@+id/ball" android:background="@drawable/bgshape" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" tools:context=".MainActivity" /> <TextView android:id= "@+id/ball2" android:background="@drawable/bgshape" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="2" tools:context=".MainActivity" android:layout_x="60dp" android:layout_y="20dp" /> The bgshape.xml(for the circle) <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <padding android:bottom="20dp" android:left="25dp" android:right="25dp" android:top="20dp" /> <stroke android:width="2dp" android:color="#000000" /> <solid android:color="#ffffff" /> <corners android:bottomLeftRadius="30dp" android:bottomRightRadius="30dp" android:topLeftRadius="30dp" android:topRightRadius="30dp" /> This code works well. Could anyone fix this so that I can add the value inside the circle when they hit each other?

    Read the article

  • JavaScript (SVG drawing): Positioning x amount of points in an area

    - by Jack
    I'm using http://raphaeljs.com/ to try and draw multiple small circles. The problem I'm having is that the canvas has a fixed width, and if I want to draw, say, 1000 circles, they don't wrap onto a 'new line' (because you have to specify the xy position of each circle). E.g. I want this: .................................................. to look like this: ............................ ...................... At the moment I'm doing this: for ( var i = 0; i < 1000; i++ ) { var multiplier = i*3; if ( i <= 50 ) { paper.circle((2*multiplier),2,2); } else if ( i >= 51 && i <= 101 ) { paper.circle((2*multiplier) - 304,8,2); } else if ( i >= 152 && i <= 202 ) { paper.circle((2*multiplier) - 910,14,2); } } For reference: circle(x co-ord, y co-ord, radius) This is messy. I have to add an if statement for every new line I want. Must be a better way of doing it..?

    Read the article

  • wxpython: adding panel to wx.Frame disables/conflicts with wx.Frame's OnPaint?!

    - by sdaau
    Hi all, I just encountered this strange situation: I found an example, where wx.Frame's OnPaint is overridden, and a circle is drawn. Funnily, as soon as I add even a single panel to the frame, the circle is not drawn anymore - in fact, OnPaint is not called at all anymore ! Can anyone explain me if this is the expected behavior, and how to correctly handle a wx.Frame's OnPaint, if the wx.Frame has child panels ? Small code example is below.. Thanks in advance for any answers, Cheers! The code: #!/usr/bin/env python # http://www.linuxquestions.org/questions/programming-9/wxwidgets-wxpython-drawing-problems-with-onpaint-event-703946/ import wx class MainWindow(wx.Frame): def __init__(self, parent, title, size=wx.DefaultSize): wx.Frame.__init__(self, parent, wx.ID_ANY, title, wx.DefaultPosition, size) self.circles = list() self.displaceX = 30 self.displaceY = 30 circlePos = (self.displaceX, self.displaceY) self.circles.append(circlePos) ## uncommenting either only first, or both of ## the commands below, causes OnPaint *not* to be called anymore! #~ self.panel = wx.Panel(self, wx.ID_ANY) #~ self.mpanelA = wx.Panel(self.panel, -1, size=(200,50)) self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint(self, e): print "OnPaint called" dc = wx.PaintDC(self) dc.SetPen(wx.Pen(wx.BLUE)) dc.SetBrush(wx.Brush(wx.BLUE)) # Go through the list of circles to draw all of them for circle in self.circles: dc.DrawCircle(circle[0], circle[1], 10) def main(): app = wx.App() win = MainWindow(None, "Draw delayed circles", size=(620,460)) win.Show() app.MainLoop() if __name__ == "__main__": main()

    Read the article

  • How do I use Django to insert a Geometry Field into the database?

    - by alex
    class LocationLog(models.Model): user = models.ForeignKey(User) utm = models.GeometryField(spatial_index=True) This is my database model. I would like to insert a row. I want to insert a circle at point -55, 333. With a radius of 10. How can I put this circle into the geometry field? Of course, then I would want to check which circles overlap a given circle. (my select statement)

    Read the article

  • Raphael.js: Adding a new custom element

    - by Claudia
    I would like to create a custom Raphael element, with custom properties and functions. This object must also contain predefined Raphael objects. For example, I would have a node class, that would contain a circle with text and some other elements inside it. The problem is to add this new object to a set. These demands are needed because non-Raphael objects cannot be added to sets. As a result, custom objects that can contain Raphael objects cannot be used. The code would look like this: var Node = function (paper) { // Coordinates & Dimensions this.x = 0, this.y = 0, this.radius = 0, this.draw = function () { this.entireSet = paper.set(); var circle = paper.circle(this.x, this.y, this.radius); this.circleObj = circle; this.entireSet.push(circle); var text = paper.text(this.x, this.y, this.text); this.entireSet.push(text); } // other functions } var NodeList = function(paper){ this.nodes = paper.set(), this.populateList = function(){ // in order to add a node to the set // the object must be of type Raphael object // otherwise the set will have no elements this.nodes.push(// new node) } this.nextNode = function(){ // ... } this.previousNode = function(){ // ... } }

    Read the article

  • Loop colours from variables for graphics.py [Python 3.2]

    - by user1056548
    I am creating a graphics program that draws 100 x 100 squares next to each other depending on the user-specified grid size. The user also inputs 4 colours for the squares to be coloured (e.g. if they enter red,green,blue,yellow the squares will be coloured in that order, repeating the colours). Is it possible to loop the colours from the variables the user has given? Here is what I have so far: def main(): print ("Please enter four comma seperated colours e.g.: 'red,green,blue,yellow'\n\ Allowed colours are: red, green, blue, yellow and cyan") col1, col2, col3, col4 = input("Enter your four colours: ").split(',') win = GraphWin ("Squares", 500, 500) colours = [col1, col2, col3, col4] drawSquare (win, col1, col2, col3, col4, colours) win.getMouse() win.close() def drawSquare(win, col1, col2, col3, col4, colours): for i in range (4): for j in range (len(colours)): colour = colours[j] x = 50 + (i * 50) circle = Circle (Point (x,50), 20) circle.setFill(colour) circle.draw(win) I think I should be using a list in some way, but can't work out exactly how to do it. Can anybody help?

    Read the article

  • google maps clicking inside a polygon

    - by amarsh-anand
    The following javascript snippet is supposed to do the following: As the user clicks on the map, initialize headMarker and draw a circle (polygon) around it As the user clicks inside the circle, initialize tailMarker and draw the path between these two markers 1 is happening as expected. But as the user clicks inside the circle, overlay is non-null while point is null in the function(overlay,point) . Can someone tell me a way out. GEvent.addListener(map, "click", function(overlay,point) { if (isCreateHeadPoint) { // add the head marker headMarker = new GMarker(point,{icon:redIcon,title:'0'}); map.addOverlay(headMarker); isCreateHeadPoint = false; // draw the circle drawMapCircle(point.lat(),point.lng(),1,'#cc0000',2,0.8,'#0',0.1); } else { // add the tail marker tailMarker = new GMarker(point,{icon:greenIcon,title:''}); map.addOverlay(tailMarker); isCreateHeadPoint = true; // load thes path from head to tail direction.load("from:" + headMarker.getPoint().lat()+ ", " + headMarker.getPoint().lng()+ " to:" + tailMarker.getPoint().lat() + "," + tailMarker.getPoint().lng(), {getPolyline:true}); } });

    Read the article

  • d3: Coloring Multiple Lines from Nested Data

    - by diet_coke
    I'm currently assembling some line graphs with circles at the datapoints from arrays of JSON objects formatted like so: var data = [{ "name": "metric1", "datapoints": [ [10.0, 1333519140], [48.0, 1333519200] ] }, { "name": "metric2", "datapoints": [ [48.0, 1333519200], [12.0, 1333519260] ] }] I want to have a color for each metric, so I'm trying to color them based on the index of the object within the array data. The code I have currently for just placing the circles looks like: // We bind an svg group to each metric. var metric_groups = this.vis.selectAll("g.metric_group") .data(data).enter() .append("g") .attr("class", "metric_group"); // Then bind a circle for each datapoint. var circles = metric_groups.selectAll("circle") .data(function(d) { return d.datapoints; }); circles.enter().append("circle") .attr("r", 3.5); Now if I change that last bit to something like: circles.enter().append("circle") .attr("r", 3.5); .style("fill", function(d,i) { return i%2 ? "red" : "blue"; } I get alternating red and blue circles, as could be expected. Taking some advice from Nested Selections : 'Nesting and Index', I tried: circles.enter().append("circle") .attr("r", 3.5); .style("fill", function(d,i,j) { return j%2 ? "red" : "blue"; } Which doesn't work (j is undefined), presumably because we are in the named property datapoints, rather than an array element. How might I go about doing the coloring that I want without changing my data structure? Thanks!

    Read the article

  • UIComponent's width and height have no effect on Sprite

    - by flexwheel
    Given this code: var circle:Sprite = new Sprite(); circle.graphics.beginFill(0xFFCC00); circle.graphics.drawCircle(0, 0, 20); var uiComp:UIComponent = new UIComponent(); uiComp.x = 100; uiComp.y = 100; uiComp.measuredHeight = 0; uiComp.measuredWidth = 0; uiComp.addChild(circle); addChild(uiComp); Why does changing the width and height of uiComp not affect the Sprite? Wouldn't UIComponent provide Sprite with a Graphics object, which limits that area where Sprite can draw?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >