當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。