Canvas Snapshot always returning 0 as color value?

0 favourites
  • 2 posts
From the Asset Store
Basic template for drawing game with masks and easy customization
  • Hi! I tried to save a color palette to a canvas and then get the color value at the touch position. But it's always returning 0 for red, green and blue values. Why?

    + System: On start of layout

    -> DrawingCanvas: Paste object ColorPalette with effects

    -> System: Wait for previous actions to complete

    --------------------------

    + Touch: On tap gesture on ColorPalette

    -> System: Set LastTouchX to floor(Touch.X)

    -> System: Set LastTouchY to floor(Touch.Y)

    -> DrawingCanvas: Save snapshot

    ----------------------------

    + DrawingCanvas: On snapshot

    -> Sprite: Set color to rgbEx255(DrawingCanvas.SnapshotRedAt(LastTouchX, LastTouchY), DrawingCanvas.SnapshotGreenAt(LastTouchX, LastTouchY), DrawingCanvas.SnapshotBlueAt(LastTouchX, LastTouchY))

    -> Browser: Alert "RED: "&DrawingCanvas.SnapshotRedAt(LastTouchX, LastTouchY)&" GREEN: "& DrawingCanvas.SnapshotGreenAt(LastTouchX, LastTouchY)&" BLUE: "& DrawingCanvas.SnapshotBlueAt(LastTouchX, LastTouchY)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You need to convert touch coordinates to canvas snapshot coordinates:

    Set snapshotX to round((Touch.X-DrawingCanvas.BBoxLeft)/DrawingCanvas.PixelScale)

    Set snapshotY to round((Touch.Y-DrawingCanvas.BBoxTop)/DrawingCanvas.PixelScale)

    And then use these variables to get the colors.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)