Canvas index start at 1 or 0?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
milo_goat
Prole
Posts: 5
Joined: Sun Nov 12, 2023 3:47 pm

Canvas index start at 1 or 0?

Post by milo_goat »

I'm making a level editor / file reading script, and to save on resources I'm going to pre-render the foreground to a canvas and draw that canvas every frame rather then drawing each tile individually, but I need to know if drawing an image at (0, 0) or (1, 1) is the exact top left pixel. I don't know how to go about finding this out since I'm unable to see pixels on an individual scale (problem with my eyes not hardware/software) and scaling the canvas would have the same problem of whether to draw it at 0, 0 or 1, 1.

second thought: using a shader that renders the pixel at (0, 0) in texture_coords (don't use pixle_coords obv since that would be screen resolution not texture point) would be a good idea but I feel that floating point accuracy might mess with the position and could end up incidentally drawing multiple pixels as 0,0 (probably won't be a problem but I'm paranoid).

please reply with the method you used to find the solution I would like to double check to make sure it is correct.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Canvas index start at 1 or 0?

Post by slime »

Pixel coordinates are [0, screenSize - 1]. Note that coordinates are not the same as indices.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests