paint

Java BasicStroke “Fuzzy”

被刻印的时光 ゝ 提交于 2019-12-17 22:01:35
问题 I'm trying to write a simple paint applet with Java, but I'm having trouble with BasicStroke . Initially, my plan was to try to somehow draw a line with a width, but the API apparently doesn't support that. I tried using BasicStroke , but the result is just a fuzzy mess. How can I fix this fuzz problem? private void mousedrag_hook(Point point) { if(start == null) start = point; end = point; Graphics2D g2d = (Graphics2D)applInstance.buffer_g; g2d.setStroke(new BasicStroke(7)); //g2d.fillOval

Displaying an ImageIcon

做~自己de王妃 提交于 2019-12-17 20:52:34
问题 I am trying to display an image on a JPanel . I'm using an ImageIcon for rendering the image, and the image is in the same directory as the class file. However, the image is not being displayed, and there are no errors occuring. Could anyone please assist in working out what's wrong with my code... package ev; import java.awt.Graphics; import javax.swing.ImageIcon; import javax.swing.JPanel; public class Image extends JPanel { ImageIcon image = new ImageIcon("peanut.jpg"); int x = 10; int y =

Java 2D Game: repaint(); makes window grey

孤街醉人 提交于 2019-12-17 20:42:33
问题 I'm trying to make a 2D game in Java, but when I call the repaint() method in a thread there's an odd grey-only window. Here's the source code I have so far: Spaceshooter.java package spaceshooter; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; public class Spaceshooter extends JFrame implements KeyListener, Runnable { private Player player = new Player(5, 186, this); private boolean up, down; public Spaceshooter(String title) {

Blur Effect (Wet in Wet effect) in Paint Application Using OpenGL-ES

回眸只為那壹抹淺笑 提交于 2019-12-17 19:56:10
问题 I am developing Paint application using OpenGL-ES for iPhone and i want to implement Gaussian blur effect(Wet in Wet) for painting. Please have look at the image describing my requirement for Blur effect : I tried to search how for OpenGL function but did not get anything. Can anyone guide me to a right direction in this problem.. Any kind of help or suggestion will be highly appreciated.. Thanks.. 回答1: You should be able to render the same brush stroke many times pixels apart to get the

How to show a line being drawn from one point to another?

夙愿已清 提交于 2019-12-17 16:55:18
问题 I used canvas.drawLine to show a line but I want user to be able to see it being drawn from one point to another and also, if possible, control the duration of the animation. (something like progress bar but this is my custom widget) 回答1: You can use an AnimationController to control the animation duration. To draw the line "step by step" you can use a Tween (linear interpolation between a beginning and ending value). Then you just need to pass the current progress to your line painter and

How to Clip a Star in android ? But the appearance of the star is clear

╄→гoц情女王★ 提交于 2019-12-17 16:33:16
问题 First to see the below images. package com.syncfusion.rating; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Region; import android.view.View; /** * Created by chozarajan.pandiyarajan on 10/9/2015. */ public class SfRatingItem extends View { private int fillColor,minDim,topXPoint,topYPoint; private double bigHypot,bigA,bigB,littleHypot,littleA,littleB,value;

Android: measureText() Return Pixels Based on Scaled Pixels

馋奶兔 提交于 2019-12-17 10:49:10
问题 So I use Paint's measureText() method to measure the width of a segment of text, but I wanted to measure text based on a certain text size. Say I wanted to get the width of a text segment that will be 20 scaled pixels when it occupies a certain TextView. I tried the following: Paint paint = new Paint(); paint.setTextSize(20); paint.measureText("sample text"); However, it does not seem to be working. I believe it is returning a width with respect to a smaller text size. I feel like I'm missing

Android color picker to be included in the activity

喜夏-厌秋 提交于 2019-12-17 10:47:18
问题 I would like to include a color picker in my paint program. So anyone here has already done something like this please give me some tutorials or piece of code to get me started. I really need to get the whole idea of adding this. I already have set up the canvas for the drawing so I'd like to add the color picker to it. Any ideas are welcome. Thanks. 回答1: Your class should implement ColorPickerDialog.OnColorChangedListener public class MainActivity implements ColorPickerDialog

setShadowLayer Android API differences

与世无争的帅哥 提交于 2019-12-17 09:31:49
问题 I develop a custom view component for my application and I am struggling with adding a shadow to a circle. Here is the code of my class extending View public class ChartView extends View { public ChartView(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } Paint paint; public void init(){ paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); paint.setStyle(Paint.Style.FILL); paint.setShadowLayer(30, 0, 0, Color.RED); } @Override protected

setShadowLayer Android API differences

我是研究僧i 提交于 2019-12-17 09:31:14
问题 I develop a custom view component for my application and I am struggling with adding a shadow to a circle. Here is the code of my class extending View public class ChartView extends View { public ChartView(Context context, AttributeSet attributeSet){ super(context, attributeSet); init(); } Paint paint; public void init(){ paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); paint.setStyle(Paint.Style.FILL); paint.setShadowLayer(30, 0, 0, Color.RED); } @Override protected