draw

iOS - Draw gradient - Swift

左心房为你撑大大i 提交于 2019-12-28 16:27:20
问题 I'm trying to draw a gradient to UILabel, but it draws only the colors I can't see the text. I saw the code from here StackOverflow my modification: extension String{ func gradient(x:CGFloat,y:CGFloat, fontSize:CGFloat)->UIImage{ let font:UIFont = UIFont.systemFontOfSize(fontSize) let name:String = NSFontAttributeName let textSize: CGSize = self.sizeWithAttributes([name:font]) let width:CGFloat = textSize.width // max 1024 due to Core Graphics limitations let height:CGFloat = textSize.height

Animating a Rectangle in Java

爷,独闯天下 提交于 2019-12-28 07:05:22
问题 I've been trying to get this rectangle to move that I've created using a for loop. All that's happening with this code is that there is an original rectangle and then a new one next to that rectangle. No animation happens, only those two rectangles show on the window. What are some methods to get this rectangle to animate? import java.awt.*; import javax.swing.*; public class Gunman extends JComponent { /** * */ private static final long serialVersionUID = 1L; public int x = 10; public int y

How to draw a Line in ImageView on Android?

三世轮回 提交于 2019-12-28 05:46:06
问题 I'd Like to know how to draw a Line on ImageView as user swipe their finger ? Could any body explain this ? Or perhaps any Link to get start on this. 回答1: You must have your own ImageView and override onDraw function. Use something like this public class MyImageView extends ImageView{ public MyImageView(Context context) { super(context); // TODO Auto-generated constructor stub } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);

Any alternative to calling getGraphics() which is returning null

非 Y 不嫁゛ 提交于 2019-12-28 02:11:11
问题 Frequently when I call getGraphics() it returns null, even if I set the xxx.getGraphics(); xxx to be visible (as a Google search shows...) But this doesn't work, and this frustrates me as it is easy and simple to do in C-Sharp. Does anyone know of a better way of doing this instead of using getGraphics()?? 回答1: You usually don't want to use getGraphics on a Java Swing component since this will be null if the component has not been rendered yet, and even if the component has been rendered and

Class is not abstract and does not override abstract method

独自空忆成欢 提交于 2019-12-28 02:02:11
问题 So I've been working on a homework on abstraction for my programming class and fell into a problem. The goal for me right now is to be able to use abstraction, then later be able to draw with rectangles and ovals a simple city, like a rectangular building or a oval light on a light post. The error I am receiving when I compile is: MyTestApp.Rectangle is not abstract and does not override abstract method drawEllipse(java.awt.Graphics) in MyTestApp.Shape. This Error shows up on the line "class

Windows Phone 8 C# Load and Draw PNGs

倖福魔咒の 提交于 2019-12-26 06:09:38
问题 I'm making a music theory game with C# and XAML, where a note appears on the stave and you press the corresponding button, and then it spawns a new note in a new position and gameplay 'loops' from there until you run out of lives...etc Yet I can't find anything that tells me how to load and draw .png files for Windows Phone 8. The main issue is that the position is what changes, and all I want to do is make the note image appear at one of the defined positions when a new note is made. It

Android : How to Draw multiple images inside the same imageview but shifted in the y coordinate?

不羁的心 提交于 2019-12-25 08:59:30
问题 In my android application I have a horizontal list view and a vertical one. The vertical view contains images. When any of the images is touched, it must go to the horizontal view, but every 3 of them must be drawn over each other in the same image view and shifted upwards so that all the images will appear. Thanks 回答1: use this code for show 2 image in one image: ImageView myImageView = (ImageView) findViewById(R.id.img1); Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(), R

C# Moving PictureBox over other PictureBoxes with transparent background

ぃ、小莉子 提交于 2019-12-25 07:27:31
问题 My goal is to make checkers game , where user can move checkers on the board. The board I have made is from DataGridView class . Right now what am i doing is creating picture boxes for each checker with transparent background and when the user moves the selected checker i am setting him BringToFront. The problem is that the "transparent" effect is actually relative to parent control, and the parent of all checkers is the DataGridView. So the result is when there is 2 checkers overlapping

Can't get pygame.Surface.get_at() to work properly

馋奶兔 提交于 2019-12-25 03:58:14
问题 I am trying to retrieve the color I have drawn onto my display using pygame, but I can't seem to get it to work. I took out some irrelevant code for easier reading, but here is what I have. import pygame import sys from pygame.locals import * pygame.init() blue = (0,0,255) #sets up screen setDisplay = pygame.display.set_mode((400,400)) pygame.display.set_caption('Connections') pygame.draw.circle(setDisplay, blue, (20,20), 10, 10) while True: for event in pygame.event.get(): if event.type ==

Masked bitmap on canvas with transparent activity

醉酒当歌 提交于 2019-12-25 03:42:56
问题 I implemented custom ShowCase for activity I am trying to draw on canvas mask: http://i.stack.imgur.com/u23kQ.png Following this code: mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); // draw solid background mCanvas.drawColor(mMaskColour); // Prepare eraser Paint if needed if (mEraser == null) { mEraser = new Paint(); mEraser.setColor(0xFFFFFFFF); mEraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mEraser.setFlags(Paint.ANTI_ALIAS_FLAG); } // draw (erase) shape /