Search Results

Search found 54159 results on 2167 pages for 'system drawing color'.

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

  • UIView: how to do non-destructive drawing?

    - by Caffeine Coma
    My original question: I'm creating a simple drawing application and need to be able to draw over existing, previously drawn content in my drawRect. What is the proper way to draw on top of existing content without entirely replacing it? Based on answers received here and elsewhere, here is the deal. You should be prepared to redraw the entire rectangle whenever drawRect is called. You cannot prevent the contents from being erased by doing the following: [self setClearsContextBeforeDrawing: NO]; This is merely a hint to the graphics engine that there is no point in having it pre-clear the view for you, since you will likely need to re-draw the whole area anyway. It may prevent your view from being automatically erased, but you cannot depend on it. To draw on top of your view without erasing, do your drawing to an off-screen bitmap context (which is never cleared by the system.) Then in your drawRect, copy from this off-screen buffer to the view. Example: - (id) initWithCoder: (NSCoder*) coder { if (self = [super initWithCoder: coder]) { self.backgroundColor = [UIColor clearColor]; CGSize size = self.frame.size; drawingContext = [self createDrawingBufferContext: size]; } return self; } - (CGContextRef) createOffscreenContext: (CGSize) size { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, size.width, size.height, 8, size.width*4, colorSpace, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpace); CGContextTranslateCTM(context, 0, size.height); CGContextScaleCTM(context, 1.0, -1.0); return context; } - (void)drawRect:(CGRect) rect { UIGraphicsPushContext(drawingContext); CGImageRef cgImage = CGBitmapContextCreateImage(drawingContext); UIImage *uiImage = [[UIImage alloc] initWithCGImage:cgImage]; UIGraphicsPopContext(); CGImageRelease(cgImage); [uiImage drawInRect: rect]; [uiImage release]; } TODO: can anyone optimize the drawRect so that only the (usually tiny) modified rectangle region is used for the copy?

    Read the article

  • Optimize a views drawing code

    - by xon1c
    Hi, in a simple drawing application I have a model which has a NSMutableArray curvedPaths holding all the lines the user has drawn. A line itself is also a NSMutableArray, containing the point objects. As I draw curved NSBezier paths, my point array has the following structure: linePoint, controlPoint, controlPoint, linePoint, controlPoint, controlPoint, etc... I thought having one array holding all the points plus control points would be more efficient than dealing with 2 or 3 different arrays. Obviously my view draws the paths it gets from the model, which leads to the actual question: Is there a way to optimize the following code (inside the view's drawRect method) in terms of speed? int lineCount = [[model curvedPaths] count]; // Go through paths for (int i=0; i < lineCount; i++) { // Get the Color NSColor *theColor = [model getColorOfPath:[[model curvedPaths] objectAtIndex:i]]; // Get the points NSArray *thePoints = [model getPointsOfPath:[[model curvedPaths] objectAtIndex:i]]; // Create a new path for performance reasons NSBezierPath *path = [[NSBezierPath alloc] init]; // Set the color [theColor set]; // Move to first point without drawing [path moveToPoint:[[thePoints objectAtIndex:0] myNSPoint]]; int pointCount = [thePoints count] - 3; // Go through points for (int j=0; j < pointCount; j+=3) { [path curveToPoint:[[thePoints objectAtIndex:j+3] myNSPoint] controlPoint1:[[thePoints objectAtIndex:j+1] myNSPoint] controlPoint2:[[thePoints objectAtIndex:j+2] myNSPoint]]; } // Draw the path [path stroke]; // Bye stuff [path release]; [theColor release]; } Thanks, xonic

    Read the article

  • jQuery color change or CSS?

    - by Josh
    I've tried achieving a hover/selected color change for a particular field, but I'm thinking jQuery is the answer. I've looked into some button click tutorials, but maybe I'm not just seeing it or doing it correctly. The idea here is that when a user hovers over a Headline, the background color changes, when they click the headline to expand it, the background color remains constant (selected), however as it stands right now the background color of the expanded fields do not change. Here is the demo: http://www.notedls.com/demo

    Read the article

  • How to show Windows System Reserved partition using Ubuntu live dvd?

    - by Veeggon
    All questions in this site ask how to "hide"! I want to fix my boot (fix mrb wont work, I have GPT Disk) by changing some files at Windows System Reserved. GParted shows the following partitions (but Nautilus doesn't): **/dev/sda1 - file system: Unknown - 128Mb - flags: msftres** (this one shows *"Warning: Unable to detect file system! Possible reasons: -file system is damaged -file system is unknown to GParted -there is no file system available (unformated -the device entry /dev/sda1 is missing)"*) **/dev/sda2 - file system: fat32 -100Mb - flags: boot** **/dev/sda3 - file system: ntfs - 500Gb**

    Read the article

  • Graph paper like drawing software

    - by Algorist
    Hi, I have a college assignment, where I have to draw diagrams of voronoi, delaunay, minimum spanning tree etc for the college. I want to do that in computer. I searched in google with no luck. Is there any good graph drawing software you are aware of? Thank you Bala

    Read the article

  • Java MVC project - either I can't update the drawing, or I can't see it

    - by user1881164
    I've got a project based around the Model-View-Controller paradigm, and I've been having a lot of trouble with getting it to work properly. The program has 4 panels, which are supposed to allow me to modify an oval drawn on the screen in various ways. These seem to work fine, and after considerable trouble I was able to get them to display in the JFrame which holds the whole shebang. I've managed to get them to display by breaking away from the provided instructions, but when I do that, I can't seem to get the oval to update. However, if I follow the directions to the letter, I only ever see an empty frame. The project had pretty specific directions, which I followed up to a point, but some of the documentation was unclear. I think what I'm missing must be something simple, since nothing is jumping out at me as not making sense. I have to admit though that my Java experience is limited and my experience with GUI design/paradigms is even more so. Anyway, I've been searching the web and this site extensively trying to figure out what's wrong, but this is a somewhat specific example and honestly I just don't know enough about this to generalize any of the answers I've found online and figure out what's missing. I've been poring over this code for far too long now so I'm really hoping someone can help me out. public class Model { private Controller controller; private View view; private MvcFrame mvcFrame; private int radius = 44; private Color color = Color.BLUE; private boolean solid = true; //bunch of mutators and accessors for the above variables public Model() { controller = new Controller(this); view = new View(this); mvcFrame = new MvcFrame(this); } } Here's the model class. This seems to be fairly simple. I think my understanding of what's going on here is solid, and nothing seems to be wrong. Included mostly for context. public class Controller extends JPanel{ private Model model; public Controller(Model model) { this.model = model; setBorder(BorderFactory.createLineBorder(Color.GREEN)); setLayout(new GridLayout(4,1)); add(new RadiusPanel(model)); add(new ColorPanel(model)); add(new SolidPanel(model)); add(new TitlePanel(model)); } } This is the Controller class. As far as I can tell, the setBorder, setLayout, and series of adds do nothing here. I had them commented out, but this is the way that the instructions told me to do things, so either there's a mistake there or something about my setup is wrong. However, when I did it this way, I would get an empty window (JFrame) but none of the panels would show up in it. What I did to fix this is put those add functions in the mvcFrame class: public class MvcFrame extends JFrame { private Model model; public MvcFrame(Model model){ this.model = model; //setLayout(new GridLayout(4,1)); //add(new RadiusPanel(model)); //add(new ColorPanel(model)); //add(new SolidPanel(model)); //add(new TitlePanel(model)); //add(new View(model)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setSize(800,600); setVisible(true); } } So here's where things kind of started getting weird. The first block of commented out code is the same as what's in the Controller class. The reason I have it commented out is because that was just a lucky guess - it's not supposed to be like that according to the instructions. However, this did work for getting the panels to show up - but at that point I was still tearing my hair out trying to get the oval to display. The other commented line ( add(new View(model)); ) was a different attempt at making things work. In this case, I put those add functions in the View class (see commented out code below). This actually worked to display both the oval and the panels, but that method wouldn't allow me to update the oval. Also, though I just had the oval displaying, I can't seem to figure out what exactly made that happen, and I can't seem to make it come back. public class View extends JPanel{ private Model model; public View(Model model) { this.model = model; //setLayout(new GridLayout(4,1)); //add(new RadiusPanel(model)); //add(new ColorPanel(model)); //add(new SolidPanel(model)); //add(new TitlePanel(model)); repaint(); } @Override protected void paintComponent(Graphics g){ super.paintComponent(g); //center of view panel, in pixels: int xCenter = getWidth()/2; int yCenter = getHeight()/2; int radius = model.getRadius(); int xStart = xCenter - radius; int yStart = yCenter - radius; int xWidth = 2 * radius; int yHeight = 2 * radius; g.setColor(model.getColor()); g.clearRect(0, 0, getWidth(), getHeight()); if (model.isSolid()){ g.fillOval(xStart, yStart, xWidth, yHeight); } else { g.drawOval(xStart, yStart, xWidth, yHeight); } } } Kinda same idea as before - the commented out code is stuff I added to try to get things working, but is not based on the provided directions. In the case where that stuff was uncommented, I had the add(new View(model)); line from the mvcFrame line uncommented as well. The various panel classes (SolidPanel, ColorPanel, etc) simply extend a class called ControlPanel which extends JPanel. These all seem to work as expected, not having much issue with them. There is also a driver which launches the GUI. This also seems to work as expected. The main problem I'm having is that I can't get the oval to show up, and the one time I could make it show up, none of the options for changing it seemed to work. I feel like I'm close but I'm just at a loss for other things to try out at this point. Anyone who can help will have my sincerest gratitude.

    Read the article

  • Drawing connected lines with OpenGL

    - by user146780
    I'm drawing convex polygons with OpenGL. I then do the same thing but use GL_LINE_LOOP. The problem I have is the lines are not always connected. How could I ensure that the lines are always connected? In the photo below, Iv highlighted in green, the corners that are connected and in red, those that are not. I would like for them to be all like the green ones. http://img249.imageshack.us/i/notconnected.png/ Thanks

    Read the article

  • XNA 2D/3D Drawing method?

    - by Adir
    What would be a better parctice, writing the drawing method inside the GameObject class or in the Game class? GameObject obj = new GameObject(); obj.Draw(); Or GameObject obj = new GameObject(); DrawGameObject(obj);

    Read the article

  • UISegmentedControl selected segment color

    - by Mike
    Is there any way to customize color of selected segment in UISegmentedControl? I've found segmentedController.tintColor property, which lets me customize color of the whole segmented control. The problem is, when I select bright color for tintColor property, selected segment becomes almost unrecognizable (its color is almost the same as the rest of segmented control, so its hard to distinguish selected and unselected segments). So I cannot use any good bright colors for segmented control. The solution would be some separate property for selected segment color but I cannot find it. Did anyone solve this?

    Read the article

  • CSS "color" vs. "font-color"

    - by Fred Wilson
    Anyone know why CSS provides "color:" for text, but does not have "font-color:" or "text-color:"? Seems very counter-intuitive.. kind of like "text-decoration: bold" rather than "font-style: ". I must be new here. :o) Seriously, does anyone know why/how the w3c came up with such a wide array of CSS names like this?

    Read the article

  • Latex font color

    - by Pieter
    I'm trying to typeset a document I'm working on. Currently I'm trying to format a piece of text such that the text consists of two colors: a fill color and a line color. In this way the header should pop out more. I found \psset with options such as linecolor and fillcolor, but I can't get it to work. Can someone provide an example of how I could do this? Just providing a color using the color-package is no problem, but also not what I want because using this package I can only provide a single color for a piece of text.

    Read the article

  • How do I invert a colour?

    - by ThePower
    I know that this won't directly invert a colour, it will just 'oppose' it. I was wondering if anyone knew a simple way (a few lines of code) to invert a colour from any given colour? At the moment I have this (which isn't exactly the definition of an invert): const int RGBMAX = 255; Color InvertMeAColour(Color ColourToInvert) { return Color.FromArgb(RGBMAX - ColourToInvert.R, RGBMAX - ColourToInvert.G, RGBMAX - ColourToInvert.B); }

    Read the article

  • Java - Set Color by switch case function

    - by user369150
    I want to set the color of the TextView by the function getcolorss. I tried a lot of different ways but i cant get in it. Please help me i think the solution is easy. import java.awt.*; import android.graphics.Color; public class test extends Activity { TextView text1 = (TextView) findViewById(R.id.text1); text1.setTextColor(getcolorss(1)); public Color getcolorss(int x) { switch(x) { case 1: return Color.BLUE; case 2: return Color.RED; } } }

    Read the article

  • Introducing Oracle System Assistant

    - by B.Koch
    by Josh Rosen One of the challenges with today's servers is getting the server up and running and understanding what all of the steps are once you plug the server in for the first time. So many different pieces come into play: installing drivers, updating firmware, configuring RAID, and provisioning the operating system. All of these steps must be done before you can even start using the server. Finding the latest firmware and drivers, making sure you have the right versions, and knowing that all the different software and firmware components work together properly can be a real challenge. If not done correctly, such as if you separately downloading disk firmware or controller firmware that doesn't match the existing OS drivers, you could experience bugs, performance problems, and incompatibilities. Gone are the days of having to locate the tools and drivers media that shipped with the server only to find out that newer versions of software and firmware are available on the web. Oracle has solved these challenges in the new X3-2 family of servers by introducing Oracle System Assistant. Oracle System Assistant is an innovative tool that is built-in to every new x86 server. It provides step-by-step assistance with configuring the server, updating firmware and drivers, and provisioning the operating system. Once you have completed all of the steps in the Oracle System Assistant tool, the server is ready to use. Oracle System Assistant was designed to be easy and straightforward. Starting it is as simple as pressing F9 when the server is booting. You'll need a keyboard, monitor, and mouse or you can use the remote console feature of Oracle ILOM (Integrated Lights Out Manager) to access a virtual KVM to the server from any machine. From there Oracle System Assistant will walk you through each of the steps necessary to set up your server. After configuring the network settings for Oracle System Assistant, the next step is to check for any new software or firmware for the server. Oracle System Assistant connects back to Oracle using your My Oracle Support account and downloads any updates that were made available to you for this specific server. This is where you really start to see the innovation that went into Oracle System Assistant. Firmware for Oracle ILOM and BIOS, operating system drivers, and other system firmware (including for option cards and disk drivers) come as a single bundle, downloading as a single unit, that has been engineered and tested to work together by Oracle. Oracle System Assistant figures out the right combination for your server, so you don't have to. Now that the server has the latest firmware, Oracle System Assistant will next walk you through configuring the hardware. From Oracle System Assistant, you can configure many Oracle ILOM settings, including the network settings and initial user accounts. This ensures that ILOM is accessible and ready to use. Oracle System Assistant is where all parts of the server come together. In addition to communicating with Oracle ILOM and interacting with BIOS, Oracle System Assistant understands and can configure the storage subsystem. Before installing the operating system, Oracle System Assistant can detect the storage configuration and configure RAID for all disks in the system. At this point, the server is ready to be provisioned with the host operating system. You can use Oracle System Assistant to provision a supported OS, including Oracle Linux, Oracle VM, RHEL, SuSe Linux, and Windows. And by using Oracle System Assistant, you can be sure that the proper OS drivers are installed for each of the installed hardware components. With Oracle System Assistant, initial setup of the server has never been easier. If we can innovate around problems and find solutions to make our servers easier to manage, this reduces IT costs and makes managing servers simpler. I think with Oracle System Assistant we have done just that. Josh Rosen is a Principal Product Manager at Oracle and previously spent more than a decade as a developer and architect of system management software. Josh has worked on system management for many of Oracle's hardware products ranging from the earliest blade systems to the latest Oracle x86 servers.

    Read the article

  • Run the system configuration once the system has been installed

    - by dierre
    Hi guys, the problem is the following. I have an old computer that mounts a SATA Dvd Burner. The old MoBo (an AsRock P4VT8+) is not able to recognize the freaking burner when booting. So I had to convert my IDE HD to USB HD and mount it on my laptop and install Ubuntu from there. The problem now is that I'm obviously getting kernel panic every now and then so I was wondering if it is possibile to rerun only the system and the hardware configuration.

    Read the article

  • Texture switching with a entity system

    - by GameDev-er
    I'm using thinking of using an entity system in my game. So far I've been using Artemis with success. However, I have a question about texture switching. I read that switching textures too often is bad. So I load all the textures when the game loads like so: import org.newdawn.slick.opengl.TextureLoader; ... public HashMap<String, Texture> Textures; ... Then for each texture I do this: Texture tex = TextureLoader.getTexture("PNG", this.getClass().getResourceAsStream(texturePath)); Textures.put(textureName, tex); Then when drawing entities I do this: drawEntity() { glBindTexture(GL_TEXTURE_2D, Textures.get(entityTexture).getTextureID()); ... } Say I have 50 entities, using 10 different 3D models, each with their own texture. When the drawEntity system runs, it doesn't group by which entities use which texture. So I could be switching textures before drawing each entity! Is there a more efficient way to switch textures between entities? Or is glBindTexture() a good option?

    Read the article

  • Ubuntu 14.04: After login, top- and sidepanel don't load and system settings don't open

    - by Löwe Simon
    I have Ubuntu 14.04 on a Medion Erazer with the Nvidia GTX570M card. At first, while I had not installed the last nvidia driver, each time I would try to suspend my pc it would freeze frame on the login. Once I managed to install the nvidia drivers, everything seemed to work up until I noticed that suddenly the system settings would not open anymore. I then rebooted my pc, but when I logged in I just end up with my cursor but no top panel or side pannel. Thankfully, I had installed the gnome desktops which works, except for the fact the system settings do not open also in the gnome desktop. I have tried following: Problems after upgrading to 14.04 (only background and pointer after login) except for reinstalling nvidia, since then I would be back at square one with suspend not working. When I try to launch system settings through the terminal, I get: simon@simon-X681X:~$ unity-control-center libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast (unity-control-center:2806): Gdk-ERROR **: The program 'unity-control-center' received an X Window System error. This probably reflects a bug in the program. The error was 'BadLength (poly request too large or internal Xlib length erro'. (Details: serial 229 error_code 16 request_code 155 (GLX) minor_code 1) (Note to programmers: normally, X errors are reported asynchronously; that is, you will receive the error a while after causing it. To debug your program, run it with the GDK_SYNCHRONIZE environment variable to change this behavior. You can then get a meaningful backtrace from your debugger if you break on the gdk_x_error() function.) Trace/breakpoint trap (core dumped) I know the 2 problems seem unrelated, but since they occured together, I am wondering if that is really the case. Your help is much appreciated, Simon

    Read the article

  • Entity system and rendering types

    - by Papi75
    I would like to implement entity system in my game and I've got some question about entity system and rendering. Currently, my renderer got two types of elements: Current design Mesh : A default renderable with a Material, a Geometry and a Transformable Sprite : A type of mesh with some methods like "flip" and "setRect" methods and a rect member (With an imposed geometry, a quad) This objects inherit from "Spacial" class. Questions: How can I handle this two types in an entity system? I'm thinking about using "MeshComponent" and "SpriteComponent", but if I do that, an entity could have a Mesh and a Sprite at the same type, it's look stupid, right? I thought the idea to have a parent "rendering" component : "RenderableComponent" for "MeshComponent" and "SpriteComponent" but it will be difficult to handle "cast" in the game (ex: did I need to ask entity-getComponent or SpineComponent, …) Thanks a lot for reading me! My entity system work like that: --------------------------------------------------------------------------- Entity* entity = world->createEntity(); MeshComponent* mesh = entity->addComponent<MeshComponent>(material); mesh->loadFromFile("monkey.obj"); PhysicComponent* physic = entity->addComponent<PhysicComponent>(); physic->setMass(5.4f); physic->setVelocity( 0.5f, 2.f ); --------------------------------------------------------------------------- class RenderingSystem { private: Scene scene; public: void onEntityAdded( Entity* entity ) { scene.addMesh( entity->getComponent<MeshComponent>() ); } } class PhysicSystem { private: World world; public: void onEntityAdded( Entity* entity ) { world.addBody( entity->getComponent<PhysicComponent>()->getBody() ); } void process( Entity* entity ) { PhysicComponent* physic = entity->getComponent<PhysicComponent>(); } } ---------------------------------------------------------------------------

    Read the article

  • Executing Components in an Entity Component System

    - by John
    Ok so I am just starting to grasp the whole ECS paradigm right now and I need clarification on a few things. For the record, I am trying to develop a game using C++ and OpenGL and I'm relatively new to game programming. First of all, lets say I have an Entity class which may have several components such as a MeshRenderer,Collider etc. From what I have read, I understand that each "system" carries out a specific task such as calculating physics and rendering and may use more that one component if needed. So for example, I would have a MeshRendererSystem act on all entities with a MeshRenderer component. Looking at Unity, I see that each Gameobject has, by default, got components such as a renderer, camera, collider and rigidbody etc. From what I understand, an entity should start out as an empty "container" and should be filled with components to create a certain type of game object. So what I dont understand is how the "system" works in an entity component system. http://docs.unity3d.com/ScriptReference/GameObject.html So I have a GameObject(The Entity) class like class GameObject { public: GameObject(std::string objectName); ~GameObject(void); Component AddComponent(std::string name); Component AddComponent(Component componentType); }; So if I had a GameObject to model a warship and I wanted to add a MeshRenderer component, I would do the following: warship->AddComponent(new MeshRenderer()); In the MeshRenderers constructor, should I call on the MeshRendererSystem and "subscribe" the warship object to this system? In that case, the MeshRendererSystem should probably be a Singleton("shudder"). From looking at unity's GameObject, if each object potentially has a renderer or any of the components in the default GameObject class, then Unity would iterate over all objects available. To me, this seems kind of unnecessary since some objects might not need to be rendered for example. How, in practice, should these systems be implemented?

    Read the article

  • OpenGL-ES: Change (multiply) color when using color arrays?

    - by arberg
    Following the ideas in OpenGL ES iPhone - drawing anti aliased lines, I am trying to draw stroked anti-aliased lines and I am successful so far. After line is draw by the finger, I wish to fade the path, that is I need to change the opacity (color) of the entire path. I have computed a large array of vertex positions, vertex colors, texture coordinates, and indices and then I give these to opengl but I would like reduce the opacity of all the drawn triangles without having to change each of the color coordinates. Normally I would use glColor4f(r,g,b,a) before calling drawElements, but it has no effect due to the color array. I am working on Android, but I believe it shouldn't make the big difference, as long as it is OpenGL-ES 1.1 (or 1.0). I have the following code : gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glEnable(GL10.GL_TEXTURE_2D); // Should set rgb to greyish, and alpha to half-transparent, the greyish is // just there to make the question more general its the alpha i'm interested in gl.glColor4f(.75f, .75f, .75f, 0.5f); gl.glVertexPointer(mVertexSize, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexCoordBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indexCount, GL10.GL_UNSIGNED_SHORT, mIndexBuffer.position(startIndex)); If I disable the color array gl.glEnableClientState(GL10.GL_COLOR_ARRAY);, then the glColor4f works, if I enable the color array it does nothing. Is there any way in OpenGl-ES to change the coloring without changing all the color coordinates? I think that in OpenGl one might use a fragment shader, but it seems OpenGL does not have a fragment shader (not that I know how to use one).

    Read the article

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