#Putting a grid on an image
1 messages · Page 1 of 1 (latest)
ah so I have to do it manually
oh if you want an example:
\begin{tikzpicture}
[
scale=0.7
]
\foreach \x in {0,0.25,...,10}{%
\draw (\x, 0) --(\x, 10);
\draw (0, \x) -- (10, \x);
}
\end{tikzpicture}
you can also make use of axis environment but you will still need to figure out the intervals etc
arbitrary placements of shapes is not a thing in TikZ I'm afraid, this isn't Paint
Nah, I jsut need the lines
But I need TikZ to understand teh length and width of teh image if I'm going to do that
and some how place that on top of the image and scale it
like usually I use width=\line width for images so teh size can change
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{Leo}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\end{scope}
\end{tikzpicture}
Something like this will work
ey!
and yes that's me
Nice galsses
🤔 Also weir dquestion, not relaly related to thsi specificly
How doe slatex handel upscalling an image?
In Layman-terms or in tech jargon?
Liek if I throw a pixel art at it the blow it up to cover teh entire screen will it stay pixelated or will it be blury?
if it is blkury then... is tehre a way to make it not do that?
^ thsi isn't really a deal breaker, I can just upscale it in a photo editor if it can't
Aside form that, thansk for the info
🤔 crab
Well what you just showed me might be able to fix that if I can ready individual pixel's RPG values which would make a very heavy proccess
might not be so bad... this is a 128 x 128
This doesn't look blury
the grid seems to be in the wrong place but the image doesn't seem to be blury
This is teh type of problem I'm talking baout
Which your image doesn't seem to suffer from
Yeah..
I have another suggestion
Since there's only two colours (or one) in the art, we can just map the image with 0s and 1s using python
and then render the art using the mapped grid
🤨 LaTeX can read Python?
Alos my question is more general, I just happen to have that image at hand
just need the numpy array (or equivalent) and then change the [] to braces and then we can just render it using for loops
more colours would just mean added layer of mapping which number corresponds to which colour
which is still quite easy to automate
colour definition can be done in LaTeX though, but you could fetch the value from the array and define it on-the-fly too (which would make it really slow imo)
Ye would be just manually making upscalling algorithems in LaTeX
@obtuse gulch has earned the Members role!
Thanks for the info man
Let me make a quick demonstration of what I meant
because it genuinely sounds quite fun
🤣 Guess I'm not the only one with mad ideas
\def\pixels{%
{2,1,9,9,9,4,3,2,1,0},
{3,9,8,7,8,9,4,9,2,1},
{9,8,5,6,7,8,9,8,9,2},
{8,7,6,7,8,9,6,7,8,9},
{9,8,9,9,9,6,5,6,7,8}}
\colorlet{pix 0}{black}
\colorlet{pix 1}{red}
\colorlet{pix 2}{green}
\colorlet{pix 3}{yellow}
\colorlet{pix 4}{blue}
\colorlet{pix 5}{yellow}
\colorlet{pix 6}{cyan}
\colorlet{pix 7}{brightblack}
\colorlet{pix 8}{brightgreen}
\colorlet{pix 9}{white}
\begin{tikzpicture}
\foreach \line [count=\y] in \pixels {
\foreach \pix [count=\x] in \line {
\draw[fill=pix \pix] (\x,-\y) rectangle +(1,1);
}
}
\end{tikzpicture}
Aye
The grid is actually from AOC 2021 Day 9 challenge
hmmm I need to learn how to use this TikZ guy
i got carried away...
graphicx's \includegraphics accepts an interpolate option that smooths the image