Search Results

Search found 716 results on 29 pages for 'rect'.

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

  • RubyQT QGraphicsview scale images to fit window

    - by shadowskill
    I'm trying to make an image scale inside of a QGraphicsView and having zero success. I did find this C++ question with what seemed to be the same problem:http://stackoverflow.com/questions/2489754/qgraphicsview-scrolling-and-image-scaling-cropping I borrowed the approach of overriding the drawback/foreground. However when I run the script I'm greeted with a method_missing error: method_missing: undefined method drawPixmap for #<Qt::Painter:0x7ff11eb9b088> QPaintDevice: Cannot destroy paint device that is being painted What should I be doing to get the QGraphicsView to behave the way I want? class Imageview < Qt::GraphicsView attr_reader :pixmap def initialize(parent=nil) # @parent=parent super() @pixmap=pixmap Qt::MetaObject.connectSlotsByName(self) end def loadimage(pixmap) @pixmap=pixmap end def drawForeground(painter, rect) #size=event.size() #item= self.items()[0] #Qt::GraphicsPixmapItem.new #pixmap=@pixmap #painter=Qt::Painter.new [email protected](Qt::Size.new(rect.width,rect.height),Qt::KeepAspectRatio, Qt::SmoothTransformation) # painter.begin(self) painter.drawPixmap(rect,sized,Qt::Rect.new(0.0, 0.0, sized.width,sized.height)) #painter.end() # item.setPixmap(sized) #painter.end self.centerOn(1.0,1.0) #item.scale() # item.setTransformationMode(Qt::FastTransformation) # self.fitInView(item) end def updateSceneRect painter=Qt::Painter.new() drawForeground(painter,self.sceneRect) end end app=Qt::Application.new(ARGV) #grview=Imageview.new pic=Qt::Pixmap.new('pic') grview=Imageview.new() grview.loadimage(pic) scene=Qt::GraphicsScene.new #scene.addPixmap(pic) grview.setScene(scene) #grview.fitInView(scene) grview.renderHint=Qt::Painter::Antialiasing | Qt::Painter::SmoothPixmapTransform grview.backgroundBrush = Qt::Brush.new(Qt::Color.new(230, 200, 167)) grview.show app.exec

    Read the article

  • Problem with my whiteboard application

    - by swift
    I have to develop a whiteboard application in which both the local user and the remote user should be able to draw simultaneously, is this possible? If possible then any logic? I have already developed a code but in which i am not able to do this, when the remote user starts drawing the shape which i am drawing is being replaced by his shape and co-ordinates. This problem is only when both draw simultaneously. any idea guys? Here is my code class Paper extends JPanel implements MouseListener,MouseMotionListener,ActionListener { static BufferedImage image; int bpressed; Color color; Point start; Point end; Point mp; Button elipse=new Button("elipse"); Button rectangle=new Button("rect"); Button line=new Button("line"); Button empty=new Button(""); JButton save=new JButton("Save"); JButton erase=new JButton("Erase"); String selected; int ex,ey;//eraser DatagramSocket dataSocket; JButton button = new JButton("test"); Client client; Point p=new Point(); int w,h; public Paper(DatagramSocket dataSocket) { this.dataSocket=dataSocket; client=new Client(dataSocket); System.out.println("paper"); setBackground(Color.white); addMouseListener(this); addMouseMotionListener(this); color = Color.black; setBorder(BorderFactory.createLineBorder(Color.black)); //save.setPreferredSize(new Dimension(100,20)); save.setMaximumSize(new Dimension(75,27)); erase.setMaximumSize(new Dimension(75,27)); } public void paintComponent(Graphics g) { try { g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; g2.setPaint(Color.black); if(selected==("elipse")) g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); } catch(Exception e) {} } //Function to draw the shape on image public void draw() { Graphics2D g2 = image.createGraphics(); g2.setPaint(color); if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); if(selected=="elipse") g2.drawOval(start.x, start.y, (end.x-start.x),(end.y-start.y)); if(selected=="rect") g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); repaint(); g2.dispose(); start=null; } //To add the point to the board which is broadcasted by the server public synchronized void addPoint(Point ps,String varname,String shape,String event) { try { if(end==null) end = new Point(); if(start==null) start = new Point(); if(shape.equals("elipse")) selected="elipse"; else if(shape.equals("line")) selected="line"; else if(shape.equals("rect")) selected="rect"; else if(shape.equals("erase")) { selected="erase"; erase(); } if(end!=null && start!=null) { if(varname.equals("end")) end=ps; if(varname.equals("mp")) mp=ps; if(varname.equals("start")) start=ps; if(event.equals("drag")) repaint(); else if(event.equals("release")) draw(); } } catch(Exception e) { e.printStackTrace(); } } //To set the size of the image public void setWidth(int x,int y) { System.out.println("("+x+","+y+")"); w=x; h=y; image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setPaint(Color.white); g2.fillRect(0,0,w,h); g2.dispose(); } //Function which provides the erase functionality public void erase() { Graphics2D pic=(Graphics2D) image.getGraphics(); pic.setPaint(Color.white); pic.fillRect(start.x, start.y, 10, 10); } //Function to add buttons into the panel, calling this function returns a panel public JPanel addButtons() { JPanel buttonpanel=new JPanel(); JPanel row1=new JPanel(); JPanel row2=new JPanel(); JPanel row3=new JPanel(); JPanel row4=new JPanel(); buttonpanel.setPreferredSize(new Dimension(80,80)); //buttonpanel.setMinimumSize(new Dimension(150,150)); row1.setLayout(new BoxLayout(row1,BoxLayout.X_AXIS)); row1.setPreferredSize(new Dimension(150,150)); row2.setLayout(new BoxLayout(row2,BoxLayout.X_AXIS)); row3.setLayout(new BoxLayout(row3,BoxLayout.X_AXIS)); row4.setLayout(new BoxLayout(row4,BoxLayout.X_AXIS)); buttonpanel.setLayout(new BoxLayout(buttonpanel,BoxLayout.Y_AXIS)); elipse.addActionListener(this); rectangle.addActionListener(this); line.addActionListener( this); save.addActionListener( this); erase.addActionListener( this); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row1.add(elipse); row1.add(Box.createRigidArea(new Dimension(5,0))); row1.add(rectangle); buttonpanel.add(row1); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row2.add(line); row2.add(Box.createRigidArea(new Dimension(5,0))); row2.add(empty); buttonpanel.add(row2); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row3.add(save); buttonpanel.add(row3); buttonpanel.add(Box.createRigidArea(new Dimension(10,10))); row4.add(erase); buttonpanel.add(row4); return buttonpanel; } //To save the image drawn public void save() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos); JFileChooser fc = new JFileChooser(); fc.showSaveDialog(this); encoder.encode(image); byte[] jpgData = bos.toByteArray(); FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()+".jpeg"); fos.write(jpgData); fos.close(); //add replce confirmation here } catch (IOException e) { System.out.println(e); } } public void mouseClicked(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { if(selected=="line"||selected=="erase") { start=e.getPoint(); client.broadcast(start,"start", selected,"press"); } else if(selected=="elipse"||selected=="rect") { mp = e.getPoint(); client.broadcast(mp,"mp", selected,"press"); } } public void mouseReleased(MouseEvent e) { if(start!=null) { if(selected=="line") { end=e.getPoint(); client.broadcast(end,"end", selected,"release"); } else if(selected=="elipse"||selected=="rect") { end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); client.broadcast(end,"end", selected,"release"); } draw(); } //start=null; } public void mouseDragged(MouseEvent e) { if(end==null) end = new Point(); if(start==null) start = new Point(); if(selected=="line") { end=e.getPoint(); client.broadcast(end,"end", selected,"drag"); } else if(selected=="erase") { start=e.getPoint(); erase(); client.broadcast(start,"start", selected,"drag"); } else if(selected=="elipse"||selected=="rect") { start.x = Math.min(mp.x,e.getX()); start.y = Math.min(mp.y,e.getY()); end.x = Math.max(mp.x,e.getX()); end.y = Math.max(mp.y,e.getY()); client.broadcast(start,"start", selected,"drag"); client.broadcast(end,"end", selected,"drag"); } repaint(); } @Override public void mouseMoved(MouseEvent arg0) { // TODO Auto-generated method stub } public void actionPerformed(ActionEvent e) { if(e.getSource()==elipse) selected="elipse"; if(e.getSource()==line) selected="line"; if(e.getSource()==rectangle) selected="rect"; if(e.getSource()==save) save(); if(e.getSource()==erase) { selected="erase"; erase(); } } } class Button extends JButton { String name; public Button(String name) { this.name=name; Dimension buttonSize = new Dimension(35,35); setMaximumSize(buttonSize); } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //g2.setStroke(new BasicStroke(1.2f)); if (name == "line") g.drawLine(5,5,30,30); if (name == "elipse") g.drawOval(5,7,25,20); if (name== "rect") g.drawRect(5,5,25,23); } }

    Read the article

  • Android Canvas.drawString display problem

    - by Arkaha
    Hello everyone! I encounter this problem when displaying text on SurfaceView, some chars can climb up on others, code is here: private static void fakeDraw(Canvas c) { Paint mPaint = new Paint(); int color = 0xff000000; mPaint.setColor(color); mPaint.setStrokeWidth(2); mPaint.setStyle(Style.FILL); mPaint.setAntiAlias(true); FontMetricsInt fm = mPaint.getFontMetricsInt(); int fh = Math.abs(fm.top); int left = 0; int top = 100; Rect smallClip = new Rect(left, top-fh, left + 200, top + 30); Rect bigClip = new Rect(0, 0, getW(), getH()); c.drawRect(bigClip, mPaint); String text1 = "Evi"; String text2 = ">>"; String text3 = "Tom"; color = 0xff303030; mPaint.setColor(color); c.drawRect(smallClip, mPaint); color = 0xffffffff; mPaint.setColor(color); c.drawText(text1, left, top, mPaint); Rect bounds = new Rect(); mPaint.getTextBounds(text1, 0, text1.length(), bounds); left += bounds.width(); c.drawText(text2, left, top, mPaint); left -= bounds.width(); top += 12; c.drawText(text3, left, top, mPaint); mPaint.getTextBounds(text3, 0, text3.length(), bounds); left += bounds.width(); c.drawText(text2, left, top, mPaint); } In the case of a second text Tom all displayed correctly, but the first text Evi not. The problem is that the chars draws in Evi draw space(last char "i")!! It is possible to see if you zoom the picture, what am I doing wrong and how to fix this? screen shot can be found here:

    Read the article

  • Java IndexOutOfBoundsException

    - by Meko
    Hi all ... I made an little shoot em up game..It works normal but I want also implement if fires intersects they will disappear. I have two list for Player bullets and for computer bullets ...But if I have more bullets from computer or reverse .Here my loop for (int i = 0; i < cb.size(); i++) { for (int j = 0; j < b.size(); j++) { if (b.get(j).rect.intersects(cb.get(i).rect)) { cb.remove(i); b.remove(j); continue; } if (cb.get(i).rect.intersects(b.get(j).rect)) { b.remove(j); cb.remove(i); continue; } } }

    Read the article

  • Resize a UITableView to accomodate a translucent header before it becomes visible

    - by scotru
    I have a UITableView inside a UINavigationController. The navigation controller uses a translucent navigation bar--as a result, my table view is displayed behind the navigation bar and it's height includes the height of the navigation bar. However, I want the table view to appear below the navigation bar (as it would if it were not translucent). I'm working in MonoTouch, but I think the principles are language independent. Here's the code I'm using to resize the UITableView frame: RectangleF rect = tableView.Frame; tableView.Frame = new RectangleF (rect.Left, rect.Top + 44, rect.Width, rect.Height - 44); tableView.ContentInset = new UIEdgeInsets (0, 0, 0, 0); This works fine if I place it in the viewDidAppear method, but will not work in the viewWillAppear method. In the viewDidAppear method, however I can see the resize occurring briefly in the form of a flicker. I want to do the resize before the frame appears. But if I put this code in viewWillAppear or viewDidLoad, it has no effect. Thanks in advance for any help!

    Read the article

  • Deadlock problem

    - by DoomStone
    Hello i'm having a deadlock problem with the following code. It happens when i call the function getMap(). But i can't reealy see what can cause this. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Drawing.Imaging; using System.Threading; using AForge; using AForge.Imaging; using AForge.Imaging.Filters; using AForge.Imaging.Textures; using AForge.Math.Geometry; namespace CDIO.Library { public class Polygon { List<IntPoint> hull; public Polygon(List<IntPoint> hull) { this.hull = hull; } public bool inPoly(int x, int y) { int i, j = hull.Count - 1; bool oddNodes = false; for (i = 0; i < hull.Count; i++) { if (hull[i].Y < y && hull[j].Y >= y || hull[j].Y < y && hull[i].Y >= y) { try { if (hull[i].X + (y - hull[i].X) / (hull[j].X - hull[i].X) * (hull[j].X - hull[i].X) < x) { oddNodes = !oddNodes; } } catch (DivideByZeroException e) { if (0 < x) { oddNodes = !oddNodes; } } } j = i; } return oddNodes; } public Rectangle getRectangle() { int x = -1, y = -1, width = -1, height = -1; foreach (IntPoint item in hull) { if (item.X < x || x == -1) x = item.X; if (item.Y < y || y == -1) y = item.Y; if (item.X > width || width == -1) width = item.X; if (item.Y > height || height == -1) height = item.Y; } return new Rectangle(x, y, width-x, height-y); } public Point[] getMap() { List<Point> points = new List<Point>(); lock (hull) { Rectangle rect = getRectangle(); for (int x = rect.X; x <= rect.X + rect.Width; x++) { for (int y = rect.Y; y <= rect.Y + rect.Height; y++) { if (inPoly(x, y)) points.Add(new Point(x, y)); } } } return points.ToArray(); } public float calculateArea() { List<IntPoint> list = new List<IntPoint>(); list.AddRange(hull); list.Add(hull[0]); float area = 0.0f; for (int i = 0; i < hull.Count; i++) { area += list[i].X * list[i + 1].Y - list[i].Y * list[i + 1].X; } area = area / 2; if (area < 0) area = area * -1; return area; } } }

    Read the article

  • UIPageControl bug: showing one bullet first and then showing everything

    - by user313551
    I have some strange behavior using a UIPageControl: First it appears showing only one bullet, then when I move the scroll view all the bullets appear correctly. Is there something I'm missing before I add it as a subview? Here is my code imageScrollView.h : @interface ImageScrollView : UIView <UIScrollViewDelegate> { NSMutableDictionary *photos; BOOL *pageControlIsChangingPage; UIPageControl *pageControl; } @property (nonatomic, copy) NSMutableDictionary *photos; @property (nonatomic, copy) UIPageControl *pageControl; @end Here is the code for imageScrollView.m: #import "ImageScrollView.h" @implementation ImageScrollView @synthesize photos, pageControl; - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Initialization code NSLog(@"%@",pageControl); } return self; } - (void) drawRect:(CGRect)rect { [self removeAllSubviews]; UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,self.frame.size.width,self.frame.size.height)]; [scroller setDelegate:self]; [scroller setBackgroundColor:[UIColor grayColor]]; [scroller setShowsHorizontalScrollIndicator:NO]; [scroller setPagingEnabled:YES]; NSUInteger nimages = 0; CGFloat cx= 0; for (NSDictionary *myDictionaryObject in photos) { if (![myDictionaryObject isKindOfClass:[NSNull class]]) { NSString *photo =[NSString stringWithFormat:@"http://www.techbase.com.mx/blog/%@", [myDictionaryObject objectForKey:@"filepath"]]; NSDictionary *data = [myDictionaryObject objectForKey:@"data"]; UIView *imageContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30)]; TTImageView *imageView = [[TTImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30)]; imageView.urlPath=photo; [imageContainer addSubview:imageView]; UILabel *caption = [[UILabel alloc] initWithFrame:CGRectMake(0,imageView.frame.size.height,imageView.frame.size.width,10)]; [caption setText:[NSString stringWithFormat:@"%@",[data objectForKey:@"description"]]]; [caption setBackgroundColor:[UIColor grayColor]]; [caption setTextColor:[UIColor whiteColor]]; [caption setLineBreakMode:UILineBreakModeWordWrap]; [caption setNumberOfLines:0]; [caption sizeToFit]; [caption setFont:[UIFont fontWithName:@"Georgia" size:10.0]]; [imageContainer addSubview:caption]; CGRect rect = imageContainer.frame; rect.size.height = imageContainer.size.height; rect.size.width = imageContainer.size.width; rect.origin.x = ((scroller.frame.size.width - scroller.size.width) / 2) + cx; rect.origin.y = ((scroller.frame.size.height - scroller.size.height) / 2); imageContainer.frame=rect; [scroller addSubview:imageContainer]; [imageView release]; [imageContainer release]; [caption release]; nimages++; cx +=scroller.frame.size.width; } } [scroller setContentSize:CGSizeMake(nimages * self.frame.size.width, self.frame.size.height)]; [self addSubview:scroller]; pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(self.frame.size.width/2, self.frame.size.height -20, (self.frame.size.width/nimages)/2, 20)]; pageControl.numberOfPages=nimages; [self addSubview:pageControl]; [scroller release]; } -(void)dealloc { [pageControl release]; [super dealloc]; } -(void)scrollViewDidScroll:(UIScrollView *)_scrollView{ if(pageControlIsChangingPage){ return; } CGFloat pageWidth = _scrollView.frame.size.width; int page = floor((_scrollView.contentOffset.x - pageWidth /2) / pageWidth) + 1; pageControl.currentPage = page; } -(void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView{ pageControlIsChangingPage = NO; } @end

    Read the article

  • How do I implement AABB ray cast hit checking for opengl es on the iPhone

    - by Big Fizzy
    Basically, I draw a 3D cube, I can spin it around but I want to be able to touch it and know where on my cube's surface the user touched. I'm using for setting up, generating and spinning. Its based on the Molecules code and NeHe tutorial #5. Any help, links, tutorials and code would be greatly appreciated. I have lots of development experience but nothing much in the way of openGL and 3d. // // GLViewController.h // NeHe Lesson 05 // // Created by Jeff LaMarche on 12/12/08. // Copyright Jeff LaMarche Consulting 2008. All rights reserved. // #import "GLViewController.h" #import "GLView.h" @implementation GLViewController - (void)drawBox { static const GLfloat cubeVertices[] = { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,-1.0f, 1.0f, -1.0f,-1.0f, 1.0f, -1.0f, 1.0f,-1.0f, 1.0f, 1.0f,-1.0f, 1.0f,-1.0f,-1.0f, -1.0f,-1.0f,-1.0f }; static const GLubyte cubeNumberOfIndices = 36; const GLubyte cubeVertexFaces[] = { 0, 1, 5, // Half of top face 0, 5, 4, // Other half of top face 4, 6, 5, // Half of front face 4, 6, 7, // Other half of front face 0, 1, 2, // Half of back face 0, 3, 2, // Other half of back face 1, 2, 5, // Half of right face 2, 5, 6, // Other half of right face 0, 3, 4, // Half of left face 7, 4, 3, // Other half of left face 3, 6, 2, // Half of bottom face 6, 7, 3, // Other half of bottom face }; const GLubyte cubeFaceColors[] = { 0, 255, 0, 255, 255, 125, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 0, 0, 255, 255, 255, 0, 255, 255 }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, cubeVertices); int colorIndex = 0; for(int i = 0; i < cubeNumberOfIndices; i += 3) { glColor4ub(cubeFaceColors[colorIndex], cubeFaceColors[colorIndex+1], cubeFaceColors[colorIndex+2], cubeFaceColors[colorIndex+3]); int face = (i / 3.0); if (face%2 != 0.0) colorIndex+=4; glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, &cubeVertexFaces[i]); } glDisableClientState(GL_VERTEX_ARRAY); } //move this to a data model later! - (GLfixed)floatToFixed:(GLfloat)aValue; { return (GLfixed) (aValue * 65536.0f); } - (void)drawViewByRotatingAroundX:(float)xRotation rotatingAroundY:(float)yRotation scaling:(float)scaleFactor translationInX:(float)xTranslation translationInY:(float)yTranslation view:(GLView*)view; { glMatrixMode(GL_MODELVIEW); GLfixed currentModelViewMatrix[16] = { 45146, 47441, 2485, 0, -25149, 26775,-54274, 0, -40303, 36435, 36650, 0, 0, 0, 0, 65536 }; /* GLfixed currentModelViewMatrix[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65536 }; */ //glLoadIdentity(); //glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -10.0f, 4.0f); // Reset rotation system if (isFirstDrawing) { //glLoadIdentity(); glMultMatrixx(currentModelViewMatrix); [self configureLighting]; isFirstDrawing = NO; } // Scale the view to fit current multitouch scaling GLfixed fixedPointScaleFactor = [self floatToFixed:scaleFactor]; glScalex(fixedPointScaleFactor, fixedPointScaleFactor, fixedPointScaleFactor); // Perform incremental rotation based on current angles in X and Y glGetFixedv(GL_MODELVIEW_MATRIX, currentModelViewMatrix); GLfloat totalRotation = sqrt(xRotation*xRotation + yRotation*yRotation); glRotatex([self floatToFixed:totalRotation], (GLfixed)((xRotation/totalRotation) * (GLfloat)currentModelViewMatrix[1] + (yRotation/totalRotation) * (GLfloat)currentModelViewMatrix[0]), (GLfixed)((xRotation/totalRotation) * (GLfloat)currentModelViewMatrix[5] + (yRotation/totalRotation) * (GLfloat)currentModelViewMatrix[4]), (GLfixed)((xRotation/totalRotation) * (GLfloat)currentModelViewMatrix[9] + (yRotation/totalRotation) * (GLfloat)currentModelViewMatrix[8]) ); // Translate the model by the accumulated amount glGetFixedv(GL_MODELVIEW_MATRIX, currentModelViewMatrix); float currentScaleFactor = sqrt(pow((GLfloat)currentModelViewMatrix[0] / 65536.0f, 2.0f) + pow((GLfloat)currentModelViewMatrix[1] / 65536.0f, 2.0f) + pow((GLfloat)currentModelViewMatrix[2] / 65536.0f, 2.0f)); xTranslation = xTranslation / (currentScaleFactor * currentScaleFactor); yTranslation = yTranslation / (currentScaleFactor * currentScaleFactor); // Grab the current model matrix, and use the (0,4,8) components to figure the eye's X axis in the model coordinate system, translate along that glTranslatef(xTranslation * (GLfloat)currentModelViewMatrix[0] / 65536.0f, xTranslation * (GLfloat)currentModelViewMatrix[4] / 65536.0f, xTranslation * (GLfloat)currentModelViewMatrix[8] / 65536.0f); // Grab the current model matrix, and use the (1,5,9) components to figure the eye's Y axis in the model coordinate system, translate along that glTranslatef(yTranslation * (GLfloat)currentModelViewMatrix[1] / 65536.0f, yTranslation * (GLfloat)currentModelViewMatrix[5] / 65536.0f, yTranslation * (GLfloat)currentModelViewMatrix[9] / 65536.0f); // Black background, with depth buffer enabled glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); [self drawBox]; } - (void)configureLighting; { const GLfixed lightAmbient[] = {13107, 13107, 13107, 65535}; const GLfixed lightDiffuse[] = {65535, 65535, 65535, 65535}; const GLfixed matAmbient[] = {65535, 65535, 65535, 65535}; const GLfixed matDiffuse[] = {65535, 65535, 65535, 65535}; const GLfixed lightPosition[] = {30535, -30535, 0, 0}; const GLfixed lightShininess = 20; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glMaterialxv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmbient); glMaterialxv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiffuse); glMaterialx(GL_FRONT_AND_BACK, GL_SHININESS, lightShininess); glLightxv(GL_LIGHT0, GL_AMBIENT, lightAmbient); glLightxv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse); glLightxv(GL_LIGHT0, GL_POSITION, lightPosition); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glEnable(GL_NORMALIZE); } -(void)setupView:(GLView*)view { const GLfloat zNear = 0.1, zFar = 1000.0, fieldOfView = 60.0; GLfloat size; glMatrixMode(GL_PROJECTION); glEnable(GL_DEPTH_TEST); size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0); CGRect rect = view.bounds; glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar); glViewport(0, 0, rect.size.width, rect.size.height); glScissor(0, 0, rect.size.width, rect.size.height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glTranslatef(0.0f, 0.0f, -6.0f); isFirstDrawing = YES; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)dealloc { [super dealloc]; } @end

    Read the article

  • Grouping rectangles (getting the bounding boxes of rects)

    - by hyn
    What is a good, fast way to get the "final" bounding boxes of a set of random (up to about 40, not many) rectangles? By final I mean that all bounding boxes don't intersect with any other. Brute force way: in a double for loop, for each rect, test for intersection against every other rect. The intersecting rects become a new rect (replaced), indicating the bounding box. Start over and repeat until no intersection is detected. Because the rects are random every time, and the rect count is relatively small, collision detection using spatial hashing seems like overkill. Is there a way to do this more effectively?

    Read the article

  • How can I eliminate an element in a vector if a condition is met

    - by michael
    Hi, I have a vector of Rect: vector<Rect> myRecVec; I would like to remove the ones which are overlapping in the vector: So I have 2 nested loop like this: vector<Rect>::iterator iter1 = myRecVec.begin(); vector<Rect>::iterator iter2 = myRecVec.begin(); while( iter1 != myRecVec.end() ) { Rectangle r1 = *iter1; while( iter2 != myRecVec.end() ) { Rectangle r2 = *iter1; if (r1 != r2) { if (r1.intersects(r2)) { // remove r2 from myRectVec } } } } My question is how can I remove r2 from the myRectVect without screwing up both my iterators? Since I am iterating a vector and modifying the vector at the same time? I have thought about putting r2 in a temp rectVect and then remove them from the rectVect later (after the iteration). But how can I skip the ones in this temp rectVect during iteration?

    Read the article

  • How can I draw a Rectangle on a PictureBox?

    - by TooFat
    I am trying to just draw a Rectangle on a PictureBox that is on a Form. Writing text like shown here works fine. private void pictureBox1_Paint(object sender, PaintEventArgs e) { using (Font myFont = new Font("Arial", 14)) { e.Graphics.DrawString("Hello .NET Guide!", myFont, Brushes.Green, new Point(2, 2)); } } but when I try to draw a rectangle like so nothing shows up. private void pictureBox1_Paint(object sender, PaintEventArgs e) { Rectangle rect = new Rectangle(); rect.Location = new Point(25, 25); rect.Width = 50; using (Pen pen = new Pen(Color.Red, 2)) { e.Graphics.DrawRectangle(pen, rect); } } What am I missing?

    Read the article

  • unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "public: bool

    - by numerical25
    Having trouble creating my swap chain. I receive the following error. DX3dApp.obj : error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "public: bool __thiscall DX3dApp::InitDirect3D(void)" (?InitDirect3D@DX3dApp@@QAE_NXZ) Below is the code ive done so far. #include "DX3dApp.h" bool DX3dApp::Init(HINSTANCE hInstance, int width, int height) { mhInst = hInstance; mWidth = width; mHeight = height; if(!WindowsInit()) { return false; } if(!InitDirect3D()) { return false; } } int DX3dApp::Run() { MSG msg = {0}; while (WM_QUIT != msg.message) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE) { TranslateMessage(&msg); DispatchMessage(&msg); } Render(); } return (int) msg.wParam; } bool DX3dApp::WindowsInit() { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = mhInst; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = TEXT("DirectXExample"); wcex.hIconSm = 0; RegisterClassEx(&wcex); // Resize the window RECT rect = { 0, 0, mWidth, mHeight }; AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); // create the window from the class above mMainhWnd = CreateWindow(TEXT("DirectXExample"), TEXT("DirectXExample"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, mhInst, NULL); if (!mMainhWnd) { return false; } ShowWindow(mMainhWnd, SW_SHOW); UpdateWindow(mMainhWnd); return true; } bool DX3dApp::InitDirect3D() { DXGI_SWAP_CHAIN_DESC scd; ZeroMemory(&scd, sizeof(scd)); scd.BufferCount = 1; scd.BufferDesc.Width = mWidth; scd.BufferDesc.Height = mHeight; scd.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; scd.BufferDesc.RefreshRate.Numerator = 60; scd.BufferDesc.RefreshRate.Denominator = 1; scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; scd.OutputWindow = mMainhWnd; scd.SampleDesc.Count = 1; scd.SampleDesc.Quality = 0; scd.Windowed = TRUE; HRESULT hr = D3D10CreateDeviceAndSwapChain(NULL,D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &scd, &mpSwapChain, &mpD3DDevice); if(!hr != S_OK) { return FALSE; } ID3D10Texture2D *pBackBuffer; return TRUE; } void DX3dApp::Render() { } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { // Allow the user to press the escape key to end the application case WM_KEYDOWN: switch(wParam) { // Check if the user hit the escape key case VK_ESCAPE: PostQuitMessage(0); break; } break; // The user hit the close button, close the application case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); }

    Read the article

  • Cocoa -- getting a simple NSImageView to work

    - by William Jockusch
    I am confused about why this code does not display any image: In the app delegate: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSRect rect = window.frame; rect.origin.x = 0; rect.origin.y = 0; BlueImageView *blueImageView = [[BlueImageView alloc]initWithFrame:rect]; window.contentView = blueImageView; // also tried [window.contentView addSubview: blueImageView]; } BlueImageView.h: @interface BlueImageView : NSImageView { } @end BlueImageView.m: @implementation BlueImageView - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { [self setImage: [NSImage imageNamed:@"imagefile.png"]]; NSAssert(self.image, @""); NSLog (@"Initialized"); } return self; } - (void)drawRect:(NSRect)dirtyRect { } @end The file imagefile.png exists. The NSAssert is not causing an exception. The NSLog is firing. But no image shows up in the window.

    Read the article

  • Artifacts when trying to draw background grid without anti-aliasing in a QGraphicsScene

    - by estan
    Hi folks, I'm trying to draw a background grid in the drawBackground() function of my QGraphicsScene subclass: void Scene::drawBackground(QPainter *painter, const QRectF &rect) { const int gridSize = 50; const int realLeft = static_cast<int>(std::floor(rect.left())); const int realRight = static_cast<int>(std::ceil(rect.right())); const int realTop = static_cast<int>(std::floor(rect.top())); const int realBottom = static_cast<int>(std::ceil(rect.bottom())); // Draw grid. const int firstLeftGridLine = realLeft - (realLeft % gridSize); const int firstTopGridLine = realTop - (realTop % gridSize); QVarLengthArray<QLine, 100> lines; for (qreal x = firstLeftGridLine; x <= realRight; x += gridSize) lines.append(QLine(x, realTop, x, realBottom)); for (qreal y = firstTopGridLine; y <= realBottom; y += gridSize) lines.append(QLine(realLeft, y, realRight, y)); //painter->setRenderHint(QPainter::Antialiasing); painter->setPen(QPen(QColor(220, 220, 220), 0.0)); painter->drawLines(lines.data(), lines.size()); // Draw axes. painter->setPen(QPen(Qt::lightGray, 0.0)); painter->drawLine(0, realTop, 0, realBottom); painter->drawLine(realLeft, 0, realRight, 0); } However, unless I turn on anti-aliasing, moving items around will sometimes leave artifacts in the grid (areas where it's not drawn). It seems it mostly happens at low zoom levels, when the view is zoomed out a bit. Any ideas what I might be doing wrong here? I'd really don't want to turn anti-aliasing on since the lines are strictly horizontal and vertical, and I'd like them to be as crisp as possible. Any help is much appriciated, Regards, Elvis

    Read the article

  • Android: How to invalidate multiple parts of screen

    - by user342731
    I need to be able to selectively invalidate multiple (about 20) rectangles on the screen for performance reasons, so tried the following: Vector<Rect> myRects = new Vector<Rect>(); // ... add some Rects to myRects for (Rect r : myRects) { invalidate(r); } However this seems to invalidates a union of all the Rect's, forming one large rectangle which covers all of small ones I'm trying to invalidate. How can one invalidate multiple areas on the screen, and only those areas?

    Read the article

  • How to get spacing between characters printed using TextOut ?

    - by life-warrior
    I'm trying to calcuate size of each cell (containing text like "ff" or "a0"), so that 32 cells will fit into window by width. However, charWidth*2 doesn' represent the width of a cell, since it doesn't take spacing between characters in the account. How can I obtain size of a font so that 32 cells each is two chars like "ff" fit exactly into window's client area ? Curier is fixed-width font. RECT rect; ::GetClientRect( hWnd, &rect ); LONG charWidth = (rect.right-rect.left)/BLOCK_SIZE/2-2; int oldMapMode = ::SetMapMode( hdc, MM_TEXT ); HFONT font = CreateFont( charWidth*2, charWidth, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, FF_ROMAN, _T("Courier") ); HGDIOBJ oldFont = ::SelectObject( hdc, font ); for( int i = 0; i < BLOCK_SIZE; ++i ) { CString str; str.Format( _T("%.2x"), (unsigned char)*(g_memAddr+i) ); SIZE size; ::TextOut( hdc, (size.cx+2)*i+1, 1, str, _tcslen((LPCTSTR)str) ); }

    Read the article

  • iphone - grouping UIImageViews x blocking elements

    - by Mike
    I have to rotate several UIImageViews around a specific center. To accomplish this I am using the famous trick of putting these views as subviews of a larger one and rotating that one. The problem is that these subviews have to detect touches, because each one has buttons on it. The hierarchy is like this LARGE_VIEW | |_____ imageView1 | |_________ button1 | |_________ button2 | |_________ button3 | |_____ imageView2 |_________ button4 |_________ button5 |_________ button6 etc So, to make buttons respond to tap, I had to make this; [LARGE_VIEW setUserInteractionEnabled:YES]; [imageView1 setUserInteractionEnabled:YES]; [imageView2 setUserInteractionEnabled:YES]; ImageView1 and 2 are two vertical rows of buttons on each side of the screen. The problem is that there's another view below LARGE_VIEW and this view is not receiving the taps, because LARGE_VIEW is intercepting them first. I don't need LARGE_VIEW to detect any taps except on the two areas where imageView 1 and 2 are. LARGE_VIEW must let pass taps on the area defined by this rect (52, 0, 768-2*52, 1024). ImageView1 and 2 have this size: 52 pixels wide and 1024 pixels high (iPad). ImageView1's rect is: (0, 0, 52, 1024) and ImageView2's rect is: (768-52, 0, 52, 1024) LARGE_VIEW must let pass taps on the area defined by this rect (52, 0, 768-2*52, 1024). How to solve that? I need LARGE_VIEW detect taps on each rect defined on my previous paragraph and pass these taps to its subviews and just let pass taps outside these rects to the app, so other views BELOW, can detect taps too. thanks.

    Read the article

  • What is the wrong of this converted code?

    - by Gum Slashy
    I'm developing shape identification project using javacv and I have found some opencv code to identify U shapes in particular image and I have try to convert it in to javacv but it doesn't provide same out put. Can you please help me to convert this opencv code into javacv? This is Opencv code import cv2 import numpy as np img = cv2.imread('sofud.jpg') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) ret,thresh = cv2.threshold(gray,127,255,1) contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) for cnt in contours: x,y,w,h = cv2.boundingRect(cnt) if 10 < w/float(h) or w/float(h) < 0.1: cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2) cv2.imshow('res',img) cv2.waitKey(0) cv2.destroyAllWindows() This is the expected output This is the code that I have converted import com.googlecode.javacpp.Loader; import com.googlecode.javacv.CanvasFrame; import static com.googlecode.javacpp.Loader.*; import static com.googlecode.javacv.cpp.opencv_core.*; import static com.googlecode.javacv.cpp.opencv_imgproc.*; import static com.googlecode.javacv.cpp.opencv_highgui.*; import java.io.File; import javax.swing.JFileChooser; public class TestBeam { public static void main(String[] args) { CvMemStorage storage=CvMemStorage.create(); CvSeq squares = new CvContour(); squares = cvCreateSeq(0, sizeof(CvContour.class), sizeof(CvSeq.class), storage); JFileChooser f=new JFileChooser(); int result=f.showOpenDialog(f);//show dialog box to choose files File myfile=null; String path=""; if(result==0){ myfile=f.getSelectedFile();//selected file taken to myfile path=myfile.getAbsolutePath();//get the path of the file } IplImage src = cvLoadImage(path);//hear path is actual path to image IplImage grayImage = IplImage.create(src.width(), src.height(), IPL_DEPTH_8U, 1); cvCvtColor(src, grayImage, CV_RGB2GRAY); cvThreshold(grayImage, grayImage, 127, 255, CV_THRESH_BINARY); CvSeq cvSeq=new CvSeq(); CvMemStorage memory=CvMemStorage.create(); cvFindContours(grayImage, memory, cvSeq, Loader.sizeof(CvContour.class), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE); System.out.println(cvSeq.total()); for (int i = 0; i < cvSeq.total(); i++) { CvRect rect=cvBoundingRect(cvSeq, i); int x=rect.x(),y=rect.y(),h=rect.height(),w=rect.width(); if (10 < (w/h) || (w/h) < 0.1){ cvRectangle(src, cvPoint(x, y), cvPoint(x+w, y+h), CvScalar.RED, 1, CV_AA, 0); //cvSeqPush(squares, rect); } } CanvasFrame cnvs=new CanvasFrame("Beam"); cnvs.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); cnvs.showImage(src); //cvShowImage("Final ", src); } } This is the out put that I got please can some one help me to solve this problem ?

    Read the article

  • Custom UIProgressView drawing weirdness

    - by Werner
    I am trying to create my own custom UIProgressView by subclassing it and then overwrite the drawRect function. Everything works as expected except the progress filling bar. I can't get the height and image right. The images are both in Retina resolution and the Simulator is in Retina mode. The images are called: "[email protected]" (28px high) and "[email protected]" (32px high). CustomProgressView.h #import <UIKit/UIKit.h> @interface CustomProgressView : UIProgressView @end CustomProgressView.m #import "CustomProgressView.h" @implementation CustomProgressView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, 16); UIImage *progressBarTrack = [[UIImage imageNamed:@"progressBarTrack"] resizableImageWithCapInsets:UIEdgeInsetsZero]; UIImage *progressBar = [[UIImage imageNamed:@"progressBar"] resizableImageWithCapInsets:UIEdgeInsetsMake(4, 4, 5, 4)]; [progressBarTrack drawInRect:rect]; NSInteger maximumWidth = rect.size.width - 2; NSInteger currentWidth = floor([self progress] * maximumWidth); CGRect fillRect = CGRectMake(rect.origin.x + 1, rect.origin.y + 1, currentWidth, 14); [progressBar drawInRect:fillRect]; } @end The resulting ProgressView has the right height and width. It also fills at the right percentage (currently set at 80%). But the progress fill image isn't drawn correctly. Does anyone see where I go wrong?

    Read the article

  • I don't like Python functions that take two or more iterables. Is it a good idea?

    - by Xavier Ho
    This question came from looking at this question on Stackoverflow. def fringe8((px, py), (x1, y1, x2, y2)): Personally, it's been one of my pet peeves to see a function that takes two arguments with fixed-number iterables (like a tuple) or two or more dictionaries (Like in the Shotgun API). It's just hard to use, because of all the verbosity and double-bracketed enclosures. Wouldn't this be better: >>> class Point(object): ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> class Rect(object): ... def __init__(self, x1, y1, x2, y2): ... self.x1 = x1 ... self.y1 = y1 ... self.x2 = x2 ... self.y2 = y2 ... >>> def fringe8(point, rect): ... # ... ... >>> >>> point = Point(2, 2) >>> rect = Rect(1, 1, 3, 3) >>> >>> fringe8(point, rect) Is there a situation where taking two or more iterable arguments is justified? Obviously the standard itertools Python library needs that, but I can't see it being pretty in maintainable, flexible code design.

    Read the article

  • Collision Detection (Ground & Slopes) in 2D Platform Game using Pygame Rects

    - by RedCap
    Hi, First off, I am not after any instructions on logic for collision detection; I get it. What I am trying to work out is the least complicated way to do this with Pygame using Sprites & Rects. I want to be able to check collisions for the Player against ground, walls & slopes. In theory it is quite straight forward, but I'm having difficulty because it seems like you cannot do this with one Rect. One Rect is simple enough to get you collisions in the X plane against walls. The same Rect could be used also be used in the Y plane against solids, but not with slopes - since with the collision routines in Pygame it checks the whole Rect (or mask), rather than perhaps just the bottom middle of the Rect. It seems in addition you need to have a number of "sprites" to check collisions with, that are 1x1 pixel in various places around the Player. What's the easiest way to do this, without having a bunch of 3, 4, or more separate "collision pixels" to check against slopes? Geoff

    Read the article

  • How to return a 'read-only' copy of a vector

    - by michael
    Hi, I have a class which has a private attribute vector rectVec; class A { private: vector<Rect> rectVec; }; My question is how can I return a 'read-only' copy of my Vector? I am thinking of doing this: class A { public: const vect<Rect>& getRectVec() { return rectVect; } } Is that the right way? I am thinking this can guard against the callee modify the vector(add/delete Rect in vector), what about the Rect inside the vector?

    Read the article

  • Is it possible to access the SMIL timer from javascript?

    - by Will
    I'm trying to use SMIL to animate the typing of text into a field embedded in a SVG. I tried the following code in both Chrome and a SMIL-enable Firefox nightly, but it has no effect: <svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml"> <foreignObject> <html:input type="text" value=""> <set attributeName="value" to="Hello World" begin="0" dur="10s" fill="freeze" /> </html:input> </foreignObject> </svg> The text field appears, but remains empty. So, I thought I would register for the beginEvent and do the substitution manually. To test the events, I added: <rect id="rect" x="0" y="0" width="10" height="10"> <animate id="dx" attributeName="x" attributeType="XML" begin="0s" dur="1s" fill="freeze" from="0" to="-10" /> </rect> As well as the javascript that made sense from the event model: window.addEventListener( 'load', function() { function listen( id ) { var elem = document.getElementById( id ) elem.addEventListener( 'beginEvent', function() { console.log( 'begin ' + id ) }, false ) elem.addEventListener( 'endEvent', function() { console.log( 'end ' + id ) }, false ) } listen( 'rect' ) listen( 'dx' ) }) But there's no events fired on either the rect or the animate in either browser. The next logical step seems to be to simulate the animation (ala. FakeSmile), but I want to use the browser's animation timer if at all possible.

    Read the article

  • EXC_BAD_ACCESS when returning a CGRect in iPhone

    - by pabloruiz55
    I have a class which must return a CGRect from one of its methods: -(CGRect)myRect { CGRect rect = CGRectMake(self.mySprite.position.x,self.mySprite.position.y,self.mySprite.textureRect.size.width, self.mySprite.textureRect.size.height); return rect; } I get an exc_bad_access as soon as i try to access the mySprite ivar. Thing is if i call it, the instance variable mySprite is full of garbage. BUT if i change the function to return void, self.mySprite does contain the correct data. -(void)myRect { CGRect rect = CGRectMake(self.mySprite.position.x,self.mySprite.position.y,self.mySprite.textureRect.size.width, self.mySprite.textureRect.size.height); return rect; } that does not crash when accessing mySprite...

    Read the article

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