w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to show multiple external svg graphics in a html5 canvas
Using the canvg worked! var ctx = document.getElementById('test').getContext('2d'); ctx.drawSvg('location.svg', 0 , 0 , 100, 100); using above code worked. Earlier I haven't add the javascript files into the html file properly. Adding them to local folder worked <script type="text/javascript" src="rgbcolor.js"></script> <script type="text/javascript" src="StackBlur.js"></script> <script type="text/javascript" src="canvg.js"></script> Still the image quality is not that much but it's better than using an image with drawImage method.

Categories : Javascript

Draw DirectX/OpenGL Graphics on an existing graphics application
Your approach in injecting an DLL is indeed the right way to go. Programs like FRAPS use the same approach. I can't tell you about the method for Direct3D, but for OpenGL you'd do about the following things: First you must Hook into the functions wglMakeCurrent, glFinish and wglSwapBuffers of opengl32.dll so that your DLL notices when a OpenGL context is selected for drawing. Pass their calls through to the OS. When wglMakeCurrent is called use the function GetPixelFormat to find out if the window is double buffered or not. Also use the glGet… OpenGL calls to find out which version of OpenGL context you're dealing with. In case you have a legacy OpenGL context you must use different methods for drawing your overlay, than for a modern OpenGL-3 or later core context. In case of a double

Categories : C++

Netscape Enterprise Server and Server-Side JavaScript (SSJS) vs Node.js
The main difference would be the evolution of Javascript over the the past 15+ years. Node.js uses the V8 Javascript Engine which would be far more optimized for modern computers. Wikipedia has a good list of the differences between various server-side JS solutions. Here is a list of features for Netscape Enterprise Server - provides a good idea of what makes modern SSJS solutions much better. Why did it not gain attention? Realistically, client-side JS has only recently started to become the standard for web development so it was unlikely anybody would have considered using it for server-side development when it wasn't even really widely adopted for it's original purpose. I say widely adopted in that previously it was always difficult to cater JavaScript solutions to all browsers.

Categories : Javascript

Using graphics on a JPanel
Create a subclass of JPanel, and override the paintComponent(Graphics g) method. Only paint from this method, using the Graphics passed as argument to the method, that you can safely cast to Graphics2D: JPanel background = new JPanel() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.BLACK); g2d.drawRect(0, 0, 800, 600); } }

Categories : Java

Updating my Graphics
When doing anything based on a timer in Swing, the javax.swing.Timer class is your best friend. It's JavaDocs explains its usage pretty well, so here's an example. public class GTest extends JFrame implements ActionListener { private Color textColor = Color.BLACK; private Random random = new Random(); @Override public void paint(Graphics g) { super.paint(g); g.setColor(textColor); g.drawString("[Game goes here]", 100, 150); } @Override public void actionPerformed(ActionEvent e) { textColor = new Color(random.nextInt(0x00ffffff)); repaint(); } public GTest() { setSize(Toolkit.getDefaultToolkit().getScreenSize().width / 3, Toolkit.getDefaultToolkit().getScreenSize().width / 3 + 50);

Categories : Java

VCL.Graphics libary to FMX
Start with the documentation for FMX.Types.TCanvas. Note that it says: ... Specifying the type of brush, stroke, and font to use. We recognise brush and font from VCL times, but what about stroke? Click on the Properties link at the top of the documentation link I gave above. Notice the various properties that have stroke in their name: Stroke, StrokeCap, StrokeDash, StrokeJoin, StrokeThickness. Also take a look at the methods by clicking on the Methods link of the TCanvas documentation page. There you will find, amongst many others: DrawRect and FillRect. The documentation for these methods tell you which properties influence the output. For DrawRect, the outline is determined by Stroke, StrokeDash etc. For FillRect, the fill is determined by the Fill property. So, to answer your

Categories : Delphi

2d java Graphics
You need to register a MouseListener for your Board JPanel so that mouseKeyStatus can be called addMouseListener(this); Aside: Override paintComponent rather than paint when implementing custom painting in Swing and remember to invoke super.paintComponent(g).

Categories : Java

3D vector graphics into PDF
In theory you can do this if you have the set of Beziers that describe each line and then set set the dash pattern for the line. The dash pattern will be non-uniform and specified to cover the entire length of each path. The problem I think you will run into is that line thickness cannot vary over the length of a single path, so you can't really get the effect of perspective in the change of line thickness. How to do this without line thickness change - project the 3D path of each curve onto 2D, measure the projected dash and gap lengths and construct the corresponding PDF path.

Categories : Pdf

EPPlus and graphics
It appears that when EPPlus creates the chart, it only stores the cell references for the data series. It doesn't actually store the value of each data point. Microsoft Excel will recalculate the value of each data point (I believe), possibly ignoring any data point cache in the spreadsheet file. OpenOffice/LibreOffice appears to read only the cached data point values in the chart section. This is why the chart doesn't appear in OpenOffice, because there are no data point values written via EPPlus.

Categories : C#

How to set Borders graphics G JAVA
You could calculate the 'future position' for a move, and test for collisions. If a collision occur, dont'move, otherwise you're ok to move. See if this logic can help you: public boolean willCollide(int row, int col, Board map) { return map[row][col] == 1; } public void moveLeft(Hero hero, Board map) { //watch for index out of bounds! int futureCol = hero.y - 1; if (! willCollide(hero.row, futureCol) hero.y = futureCol; }

Categories : Java

How do i get a graphics object in Java?
The idea is that the listeners should change the state of the game (i.e. create a bullet, or change the location of the bullet, or whatever), and then call repaint(). Then Swing will invoke the paintComponent(Graphics g) method, which will paint the updated game state using the Graphics passed as argument.

Categories : Java

Why does this graphics loop freeze my gui?
The problem is that it's infinite. Your condition: canvasY < mapHeight + offsetY && canvasX < mapWidth + offsetX Will always be false, since none of those values ever change. What I believe you want to do is to call these after the draw call. canvasY = offsetY + y; canvasX = offsetX + x;

Categories : Java

2D Graphics Performance Boost
Perhaps you should sort the objects by y value and then render them, this should be faster if you are currently doing a search on each object every time you draw an object. And try not to make the player special. Player should be an "object" as well, then you would sort once back to front and then draw back to front.

Categories : C++

Java graphics isn't repainting
The Event Dispatch Thread contains a queue to which all AWT events are added. Whenever you call repaint, a paint event will be queued on the Event Dispatch Thread. So if you're in an infinite loop while on the Event Dispatch Thread, those paint events will stand in line forever, waiting for the infinite loop to end. That's why paintComponent is never called. The solution would be to replace the infinite loop with a Swing timer. Timer timer = new Timer(1000 / TARGET_FPS, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //... } }); timer.start();

Categories : Java

Core Graphics Error
You don't say where you call drawStartPosition, but that's the problem. Basically, you shouldn't call drawRect: yourself, instead you should call setNeedsDisplay and allow the system to complete all of the appropriate setup before it actually asks your view to draw itself into the supplied context.

Categories : Iphone

Java Drawing Graphics
I am making a game in Java and I have a canvas class, which has the game tick, and I draw the images on the canvas using note public void paint(Graphics g) { for awt.Canvas, awt.Panel public void paintComponent(Graphics g) { for swing.JComponent, swing.JPanel any painting could be done only for J/Component, good practicies couldn't be move this methods outside of J/Component declarations I want to move all the drawing functions to my Engine class. I have this method in my Engine: is good idea to prepare all Object before paint/paintComponent is executed, there to put all Objects to the array inside paint/paintComponent only loop inside arrays of prepared Obects, invoked from Swing Timer, Mouse/Key events all events for paiting, to AWT/Swing GUI must be don

Categories : Java

Graphics BitMapFill TypeError
Use a reference to an HTML Image, and not a Bitmap instance. var image = new Image(); image.srce = "http://nielsvroman.be/twitter/root/easeljs/image.png"; this.graphics.beginBitmapFill(image, "no-repeat"); Note that you have to ensure the image is loaded, otherwise it may not show up on the first stage update. You can either tick the stage, or listen for image onload, and refresh the stage then. image.onload = function() { stage.update(); }

Categories : Javascript

Graphics beginBitmapFill easeljs
It's pretty obvious, you pass a string and not an Image (HTMLImageElement). Try: var img1 = new Image(); img1.src = 'image1.png'; or var img1 = document.createElement('img') img2.src = 'image2.jpg';

Categories : Javascript

Why JFrame is empty after my graphics
You are used to applets, where overriding paint will actually work. In a JFrame, the recommended technique is a little more complicated. Add this code to your constructor: getContentPane().add(new JPanel() { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawString("Hello world!", 75, 75); } }); This creates an anonymous subclass of JPanel which overrides paintComponent to do some painting, then adds the JPanel to the frame. The call to super.paintComponent is important. There are several other things that you should know are different from applets: You need to call setVisible(true) to make the frame appear. This is mandatory for your program to work. You should add setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) if you want the program to

Categories : Java

Android graphics for XXHDPI
Unless you actually need your graphics to be "pixel perfect", scaling up from XHDPI will probably be fine for almost all cases. Pixels are so small the user won't be able to tell the difference. Do you actually have an XXHDPI device you can see your graphics on? You might have to provide XXHDPI resources for some drawables, just like you sometimes have to provide MDPI drawables when the HDPI ones don't scale down well. "do not exclude" in this context means explicitly from the manifest. Some developers target densities in their manifest and that will affect the app not showing in the Play store, this is unrelated to actual graphics. From that same page, it actually says that the density of that device is 440 dpi? - "One of the awesome features you’ll find in the recently announced Sony

Categories : Android

use of buffers in java graphics
Your current loop will likely tie up the Swing Event Dispatch Thread, or EDT, effectively freezing your application since this all important thread is prevented from doing what it must do -- rendering your application and respond to user input. You need to take threading into account by making sure that the loop is run in a background thread. Having said that, I must question the quality, timeliness and relevance of your tutorial if it is recommending that you code with AWT components such as Canvas and if it recommends that you use null layout and absolute positioning of components (i.e., use of setBounds(...)). You will be far better off using all Swing components and Swing graphics as per the tutorials. Please have a look at: The basic Swing Graphics tutorial: Lesson: Performing C

Categories : Java

Clear context graphics
It looks like you don't clear path in the method that clears the whole view (eraseButton ?). So the path would still contain the whole old drawing. Only those parts would show on which you call setNeedsDisplayInRect: (from within touchesMoved:). You can reveal the old drawing by drawing over it again. You should clear path (probably an ivar) by just creating a new one in eraseButton: CGPathRelease(path); path = CGPathCreateMutable();

Categories : Iphone

Graphics, dispose before reuse?
So you're asking if you should call Dispose() on it before you give it a new value? Graphics gmp = panelm.CreateGraphics(); //do work gmp.Dispose(); gmp = panelm.CreateGraphics(); versus Graphics gmp = panelm.CreateGraphics(); //do work gmp = panelm.CreateGraphics(); As good practice, you should call Dispose() when you're done; although it will automatically get cleaned up by the garbage collector sometime if you don't, so you're not leaking resources either way.

Categories : C#

How do you insert your own graphics in Java 7
Taking and manipulating existing images can be done with the Java Image class. First, declare an instance of the class (BufferedImage is a subclass of Image): private BufferedImage img = null; Then, you load the image like this: try { img = ImageIO.read( new File("MyPicture.jpg" )); } catch ( IOException exc ) { //TODO: Handle exception. } Finally, in the paint(Graphics) method of your code, you display the image like this: g.drawImage( img, x, y, this ); Don't forget to write some code to handle the Exception. These things help you find and solve bugs more easily. The official tutorial is here.

Categories : Java

Graphics.Fillrectangle won't update
Storing Graphics instances in global variables is a Very Bad Idea. Make it look like this instead: using (var g = Graphics.FromImage(pictureBox1.Image)) { g.FillRectangle(Brushes.Tomato, MousePosition.X, MousePosition.Y, 50, 100); pictureBox1.Invalidate(); } The Invalidate() call is the one you are looking for. PictureBox can only tell that you changed the Image property, it can't tell that you changed the image content.

Categories : C#

Really flickery graphics even with BufferedImage
Remove the line g2d = (Graphics2D)g; from your update(...) method and all your problems will go away. You already created a backbuffer in the line g2d = backbuffer.createGraphics();. When you assign g to g2d you are making them both refer to the same Graphics object and are throwing away your buffer. You are back to drawing directly to the screen.

Categories : Java

R plotting / graphics guidw
There are several books worth reading. Start with Paul Murrell's R Graphics. Then read Hadley Wickham's ggplot2 book. Then Deepayan Sarkar's lattice book.

Categories : R

Vector Graphics and Quartz 2D iOS
Animations are probably the ticket. You don't need to use low-level quartz stuff, just use the UIView animations. Ray Wenderlich has a good overview here and you can google plenty of others.

Categories : Iphone

pictureBox, graphics and messageBox
When the form is refreshed, the paint event will be called. You could avoid custom drawing at this point by setting a flag. bool updatePictureBox = true; private void pictureBox1_Paint(object sender, PaintEventArgs e) { if(updatePictureBox) pictureBox1.Image = btm; } protected override void OnClosing(CancelEventArgs e) { updatePictureBox = false; DialogResult dr = MessageBox.Show(this,"Exit?", "Exit", MessageBoxButtons.YesNo); if (dr == DialogResult.No) e.Cancel = true; else e.Cancel = false; } However, you can avoid the entire issue by drawing within the Paint event itself. I suggest doing this instead of using the flag method above. private void pictureBox1_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; using (Pen p = new Pe

Categories : C#

Graphics.drawRect being filled
You're use of a Thread and repaint is wrong and unnecessary. Please get rid of that portion of your code and instead simply call repaint in the MouseListener. Use Math.abs(...), Math.min(...) and Math.max(...) to help you draw better behaved rectangles. For example, import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; import javax.swing.*; public class Pie2 extends JPanel { private static final int PREF_W = 500; private static final int PREF_H = 500; private static final Color BACKGROUND = Color.black; private static final Color RECT_COLOR = Color.green; private static final Color RECT_FILL_COLOR

Categories : Java

Convert from GDI32.HDC to awt.Graphics
Your best bet for a compatible bitmap is an array of integer values, although you may have to directly read pixel values from one format and write to the target. JNA does a transfer of pixels from Java Graphics-generated image to windows HDC in WindowUtils.java. As for converting something windows has drawn into a BufferedImage, you would need to extract the Windows image as pixels and then write those into the BufferedImage.

Categories : Java

Graphics on indexed image
Refering to this, it can be solved by creating a blank bitmap with the same dimensions and the correct PixelFormat and the draw on that bitmap. // The original bitmap with the wrong pixel format. // You can check the pixel format with originalBmp.PixelFormat Bitmap originalBmp = new (Bitmap)Image.FromFile("YourFileName.gif"); // Create a blank bitmap with the same dimensions Bitmap tempBitmap = new Bitmap(originalBmp.Width, originalBmp.Height); // From this bitmap, the graphics can be obtained, because it has the right PixelFormat Graphics g = Graphics.FromImage(tempBitmap); // Draw the original bitmap onto the graphics of the new bitmap g.DrawImage(originalBmp, 0, 0); // Use g to do whatever you like g.DrawLine(...); // Use tempBitmap as you would have used originalBmp return tempBitmap

Categories : C#

Can’t load libgd when trying to use Graphics.GD on OS X
I tried to install it, and it works for me, and I have the same setup as you (gd installed via macports). In my ~/.cabal/config file, I have the line: extra-lib-dirs:/opt/local/lib If you don't have that, try reinstalling the library (cabal install gd --reinstall) after adding it in. Other than that, I don't know.

Categories : Osx

Core Graphics - Shadow not seen
Try this: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGColorRef colorRef = [[UIColor blueColor] CGColor]; CGContextSetStrokeColorWithColor(context, colorRef); CGContextSetFillColorWithColor(context, [[UIColor blueColor] CGColor]); CGRect buttonRect = CGRectInset(rect, 3, 3); CGPoint centerPoint = CGPointMake(CGRectGetMidX(buttonRect ), CGRectGetMidY(buttonRect)); CGFloat radius = CGRectGetWidth(buttonRect) / 2; CGContextSaveGState(context); CGContextSetShadow(context, CGSizeMake(2.0, 2.0), 2.0); CGContextAddArc(context, centerPoint.x, centerPoint.y, radius, 0, 2*M_PI, 1); //CGContextClip(context); CGContextFillPath(context); CGContextRestoreGState(context); CGColorRelease(colorRef

Categories : IOS

How to adjust the z-axis, if there is, for graphics in AS3
[Embed (source = "images/Untitled.png")] var bg:Class; var bmp1:Bitmap = new bg; addChild(bmp1); // Add the bitmap first var sprite1:Sprite = new Sprite(); this.addChild(sprite1); // Add the sprite afterwards; it appears on top of the bitmap var k:int, l:int; for (l = 0; l < 10; l++) { for (k = 0; k < 8; k++) { sprite1.graphics.beginFill(0xff0000, 1); sprite1.graphics.drawCircle(k*50, l*50, 10); sprite1.graphics.endFill(); } }

Categories : Actionscript

Move Controls and Graphics
without using Threads you'll face the same problem with UserControls , It's recommended to separate UI tasks from other stuff that you're working with It means that if your program is too slow for getting data in real-time you can use two threads , one for getting data and the other for drawing and doing other stuff with UI in this way UI thread won't affect the data thread but remember you may need to optimize your drawing stuff as well by using some Image Processing Libraries or even using faster technologies designed for Working with Graphics like WPF here's a very good tutorial for getting started with Threads in C# : Multithreaded Programming Using C# please keep in mind if you provide us more details and codes we can help you even more :)

Categories : C#

is it worth it to convert graphics from jpg to png?
Since you are starting with a JPG, going to a PNG isn't really buying you anything. You are going from a low fidelity image to a higher fidelity image. But it can't be MORE clear than your original image. Think about watching non HD video on an HD TV. The picture isn't any better, even though the format supports better quality. Here's a handy comparison. http://www.labnol.org/software/tutorials/jpeg-vs-png-image-quality-or-bandwidth/5385/

Categories : Performance

Good looking graphics in C# window form
You want to use the System.Drawing.Graphics.SmoothingMode property. Before beginning to use your Graphics object, do this: canvas.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; That should give you a nice anti-aliased ellipse instead of the default jaggy one. Similarly, if you want to draw high-quality text in an image, use the System.Drawing.Graphics.TextRenderingHint property. As others have mentioned in comments, you might want to consider using WPF instead. WinForms are dated.

Categories : C#

Updating of the ILNumerics surface graphics
Mouse events on nodes in ILNumerics provide arguments of ILMouseEventArgs. The type provides the Refresh property. Set this to true in your mouse event handler. It will trigger a redraw after all events are processed: void iILNode_MouseClick(object sender, ILMouseEventArgs e) { if (e.DirectionUp) { //modify scene here // .. // trigger redraw of the scene e.Refresh = true; } } The documentation on mouse event handling: http://ilnumerics.net/mouse-events.html

Categories : Misc

How to install graphics.py on Ubuntu 12.04 for Python3.2
You problem: usr/lib/python3/dist-packages/graphics.py line 153, in import Tkinter as tk In Python 3+, Tkinter is imported as tkinter. Simply edit the graphics.py file to import tkinter as tk. Note: As Bender stated, it will probably be easier to continue learning with python 2.*, as you may encounter further issues in the future.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.