当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsContext.drawImage方法代码示例

本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.drawImage方法的具体用法?Java GraphicsContext.drawImage怎么用?Java GraphicsContext.drawImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.canvas.GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext.drawImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(GraphicsContext gc)
{
	currentFrame++;
	if(currentFrame/frameRepeat >= frameCount)
	{
		currentFrame = 0;
	}
	gc.drawImage
	(
		source,
		(int)(currentFrame/frameRepeat)*sourceWidth,
		0,
		sourceWidth,
		sourceHeight,
		x - (width/2),
		y - (height/2),
		width,
		height
	);
}
 
开发者ID:GabrielCT,项目名称:Chase-R,代码行数:21,代码来源:AnimatedImage.java

示例2: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draws the image representing the nucleotide on a graphics context, with specified rotation.
 * @param GraphicsContext gc: The GraphicsContext you want to draw the object on
 * @param x: The x coord you want to draw the image at
 * @param y: The y coord you want to draw the image at
 * @param r: The rotation, in degrees, you want to draw the nucleotide at. 0 would draw it with the base pointing up.
 */
public void draw(GraphicsContext gc, int x, int y, int r) {
	gc.save();
	gc.translate(x, y);
	gc.rotate(r);
	gc.translate(-x, -y);
	gc.drawImage(image, x, y);
	gc.restore();
}
 
开发者ID:clonex10100,项目名称:Dna-replication-game,代码行数:16,代码来源:Nucleotide.java

示例3: drawShadow

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static void drawShadow(Image image, double scale, GraphicsContext dst)
{
	final double shadowSize = scale * SHADOW_SIZE;
	final double shadowBlur = scale * SHADOW_BLUR;

	GaussianBlur blur = new GaussianBlur(shadowBlur);
	dst.drawImage(image, shadowSize * 2 / 3, shadowSize);
	dst.applyEffect(blur);

	ColorAdjust colorAdjust = new ColorAdjust();
	colorAdjust.setBrightness(SHADOW_BRIGHTNESS);
	dst.applyEffect(colorAdjust);

	dst.drawImage(image, 0, shadowSize);
	dst.applyEffect(colorAdjust);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:17,代码来源:Renderer.java

示例4: playAnimation

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static void playAnimation(GraphicsContext gc, double time, int actualSize, int startingPointX, int startingPointY, int numberOfFrames, int x, int y, double width, double height, double scale, boolean reversePlay, double playSpeed) {

        double speed = playSpeed >= 0 ? playSpeed : 0.3;

        // index reporesents the index of image to be drawn from the set of images representing frames of animation
        int index = findCurrentFrame(time, numberOfFrames, speed);

        // newX represents the X coardinate of image in the spritesheet image to be drawn on screen
        int newSpriteSheetX = reversePlay ? startingPointX + index * actualSize : startingPointX;
        // newY represents the X coardinate of image in the spritesheet image to be drawn on screen
        int newSpriteSheetY = reversePlay ? startingPointY : startingPointY + index * actualSize;
        //System.out.println("Time, Total Frames" + time + ", " + numberOfFrames);
        //System.out.println("index=" + index + " newSpriteSheetX=" + newSpriteSheetX + " newSpriteSheetY=" + newSpriteSheetY + " width=" + width + " height=" + height + " x=" + x + " y=" + y + " width=" + width * scale + " height=" + height * scale);
        //img,             sx,              sy,     w,     h,  dx, dy,        dw,             dh
        gc.drawImage(img, newSpriteSheetX, newSpriteSheetY, width, height, x, y, width * scale, height * scale);
    }
 
开发者ID:ashish2199,项目名称:Aidos,代码行数:17,代码来源:Renderer.java

示例5: drawStrokes

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draws out the all of the phonemes in stroke form on the canvas of the Application.
 *
 * @param s The string that is to be split up and put into phonemes, and then drawn out.
 */
private void drawStrokes(String s, GraphicsContext gc){

    Canvas canvas = gc.getCanvas();

    // Clears all of the previous drawings
    gc.clearRect(0,0, canvas.getWidth(), canvas.getHeight());


    Character[][] phones = TextProc.phones(s);
    int x = 90;
    int y = 100;
    int line = 1;
    Stroke current;

    //Iterates through the sentence
    for (Character[] word : phones) {

        // Checks to see if it is necessary to wrap at the word. The on the end is for padding
        if((canvas.getWidth() - 90)  - x < GraphicsCalculations.wordLength(word)){
            line++;
            x = 80;
            y = line * 80;
        }

        y -= GraphicsCalculations.wordHeight(word);
        // Iterates through the word
        for (Character c : word) {

            // Don't bother with the vowels yet, only draw outlines.
            if (TextProc.isVowel(c)){
                continue;
            }

            current = TextProc.strokeMap.get(c);

            // The starting and ending points of the current stroke
            Point start = current.getStart();
            Point end = current.getEnd();

            // Draw the image
            gc.drawImage(current.getImage(), x - start.x, y - start.y);

            // Moves the pointer to the end of the stroke
            x += end.x - start.x;
            y += end.y - start.y;

        }

        // Puts 80 pixels in between words to fo indicate a space until joining is funtioning
        x += 80;
        y = line * 100;
    }

}
 
开发者ID:squablyScientist,项目名称:Pitman-Translator,代码行数:60,代码来源:Scratchpad.java


注:本文中的javafx.scene.canvas.GraphicsContext.drawImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。