-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extension request: Pixel(x,y) or Dot(x,y) API function #8
Comments
It is sort of possible to draw a single pixel by drawing a circle of width 1 with it's centre offset by (+0.5,+0.5) but make sure you have stroke width set to 0 (stroking will cause extra pixels to be filled). The offset is needed because openvg works on pixel centres, and when you give a position of say (10,10) you are actually referencing the bottom left corner of that pixel. So if you don't draw the circle from the centre of the pixel then you end up with the circle extents from (9.5,9.5) -> (10.5,10.5) which is why it draws 2x2 pixels, (9,9), (9,10) and (10,9) as well as the intended (10,10) I did a bit of testing for this last night, I haven't checked how well it handles scaling but if it doesn't work as expected you could always create separate paths for various dot sizes. (Needs the later versions of my fork (V1.3, newfonts, windowsave), not the earlier ones).
I'll look into it more when I have time and try and make a tidy version that handles all cases. |
thank you, I already was thinking about Line(x,y, x,y) as a workaround but didn't test it so far. |
Line(x, y, x, y) won't work, it sees that as a zero length line and doesn't draw it. Single pixels are awkward as things change when you translate/scale the coordinate system. |
re: "Single pixels are awkward as things change when you translate/scale the coordinate system." |
You could try it, last time I played around with it it went from drawing nothing to a 1x2. But then my circles didn't work then either (I probably forgot to switch the stroke off back then). I won't have chance to play with it until late tonight at the earliest. |
if round or rectangle doesn't matter, main thing is: |
Just checked, it was stoking that was messing up my previous attempts at single pixel drawing (at least for non-transformed drawing - i.e. no scaling/transforming). So to draw a single pixel at (10,10) you could use Line(10,10.5, 10.5, 10.5) with a stroke width of 1 These should give you square points when scaled up rather than the round points of using circles. I'd prefer the rectangle method as it's less of a hack but it means dots would be subject to the fill paint rather than the stroke paint. |
re: "Or you could use a rectangle Rect(10, 10, 1, 1) with a stroke width of 0" |
I've updated the windowsave branch with a few typos fixed (there was an error in RoundRect) and a new function
This should draw a 1 unit dot with it's lower-left extent at (x,y). This should be faster than using Circle() or Rect() directly, and equivalent to the CirclePath() or RectPath() method I said above (which is what it basically does). It also doesn't use stroke, it only fills so you don't need to do a StrokeWidth(0) before drawing it. |
that's great, thank you very much for your efforts! |
From which version are you coming from? If from ajstarks' original (and what my master is based on) then it's a little tricky. The new version installs over the top, it should leave the old libshapes.so.1 library for use by old programs compiled against it, but unfortunately programs that were compiled against it aren't told to use .1 specifically (ajstarks' original doesn't set the soname in the library) so they will always try to link to the latest installed. Plus the header files will be overwritten with the new ones so you won't be able to directly compile against the old version without keeping a copy somewhere. There are a few slight changes which make my version incompatible (some internal changes especially to how Font data is passed), which means code compiled for the original will fail without being re-compiled against my new versions (V1.2, V1.3, newfonts, windowsave). If you need to keep the old version you can always just not do the final make install step and point the compiler to the headers and object files directly (that's how all the demo files in client/ are compiled). I really must get around to handling it better. |
I have your version, it's a few months old, how can I get my current version number? |
It gives instructions at the bottom of the README shown on the main page under the section Buid and Run. Just substitute git checkout windowsave where it says git checkout newfonts for the current latest. Or if you just want to download the zip file select the windowsave branch from the button on the top left of the home page and then select download zip from the botton on the right. |
the current instructions to install are very complicated and hard to understand - I prefer a completely uninstall and a completely new installation. I did it that way:
Is that still correct? But first of all I want to erase the old installation completely ("uninstall.exe") - so how to do that? |
If you've already cloned the repo beforehand then you should be able to do a You can uninstall the old version first it you want with git branch Other than that the build instructions are the same (although you listed ./shapedemo in the wrong place, that's available after doing make in client/ ) |
thank you, but I don't know waht that means and what I have to do then:
which is the complete and correct list of commands like? |
git fetch origin should update your local copy of the repo with the latest that I uploaded (call it from the main directory). Only works if you have already cloned the repo. make uninstall from the main directory that you would have done make install from. git branch call that from the main directory and it will show you which branch you currently have checked out (which version of the code the files belong to, when you checkout a branch all the code updates to that version). You showed running ./shapedemo right after running make in the main directory but ./shapedemo isn't in that directory and won't be made by that make. When you cd client and run make from there then ./shapedemo is available in that directory. |
i don't know what I have or have not. github is really weird and my English is very shaky. I also don't know from which directory I have once installed. As I still don't understand what I have to do in detail, could you please correct and update just this list? Now the first step should be uninstall all about the current version:
|
If you want to do a total clean install... (I just noticed I forgot to add to the README about needing to install libpng12-dev as well as libfontconfig1-dev, the others should already have been installed from previous) Uninstall current version (renaming the openvg directory so you can keep it just in case)
make library isn't needed as make install will do it automatically anyway.
|
thank you, that's much more clear now. another question:
and because including font types into programs has changed to dynamical including, is it still the same for writing text by fonts, e.g., |
so I would assume: old openVG can be deleted and all the rest stays as it was before. |
hello,
it would be very wishful to have also a Pixel(x,y) or Dot(x,y) API function (draw a dot at (x,y) by StrokeWidth() ), will that be possible ?
The text was updated successfully, but these errors were encountered: