I've resorted to actually drawing all of the characters of the alphabet on a
graph to avoid having to drag around font files. It's mostly just uppercase
characters, so it's not too bad.
But I noticed that some of the line segments have to be extended one pixel
longer than they should be in order for the last pixel to show up.
The character cells are 6 pixels wide by 8 pixels high. An "L" is drawn
with
Graph.line((x,y, x,y+7, x+5,y+7), Color)
where the starting x and y are supplied to the function. An L works OK, but
to get a "T" to look right I have to do
Graph.line((x+1,y, x+5,y), Color)
Graph.line((x+3,y, x+3,y+8), Color)
I have to extend the vertical line to y+8, instead of y+7 to get the line
segment to be drawn long enough. This is on Linux, Solaris, 2.x versions of
Python, 1.1.5 version of PIL, and on Windows with the latest of everything.
Am I missing a setting somewhere?
Thanks!
Bob 3 2369
Bob Greschke wrote I've resorted to actually drawing all of the characters of the alphabet on a graph to avoid having to drag around font files. It's mostly just uppercase characters, so it's not too bad.
But I noticed that some of the line segments have to be extended one pixel longer than they should be in order for the last pixel to show up.
The character cells are 6 pixels wide by 8 pixels high. An "L" is drawn with
Graph.line((x,y, x,y+7, x+5,y+7), Color)
where the starting x and y are supplied to the function. An L works OK, but to get a "T" to look right I have to do
Graph.line((x+1,y, x+5,y), Color) Graph.line((x+3,y, x+3,y+8), Color)
I have to extend the vertical line to y+8, instead of y+7 to get the line segment to be drawn long enough. This is on Linux, Solaris, 2.x versions of Python, 1.1.5 version of PIL, and on Windows with the latest of everything. Am I missing a setting somewhere?
Some drawing APIs (e.g. Windows GDI) draw lines including the starting
point but excluding the end point: I think the reason is that this way,
if you draw a series of connected lines (like in your "L" case), no
pixel gets drawn twice (this is important if you use colors with alpha
channels, or line patterns).
Bob Greschke wrote: I have to extend the vertical line to y+8, instead of y+7 to get the line segment to be drawn long enough. This is on Linux, Solaris, 2.x versions of Python, 1.1.5 version of PIL, and on Windows with the latest of everything. Am I missing a setting somewhere?
I recently got another bug reported that talked about the same thing, so
it's probably a bug in 1.1.5 that nobody has noticed before.
(as nikie mentions, the low-level line segment drawer avoids drawing over-
lapping points, but the "line" wrapper should add the last pixel)
</F>
"Fredrik Lundh" <fr*****@pythonware.com> wrote in message
news:ma***************************************@pyt hon.org... Bob Greschke wrote:
I have to extend the vertical line to y+8, instead of y+7 to get the line segment to be drawn long enough. This is on Linux, Solaris, 2.x versions of Python, 1.1.5 version of PIL, and on Windows with the latest of everything. Am I missing a setting somewhere?
I recently got another bug reported that talked about the same thing, so it's probably a bug in 1.1.5 that nobody has noticed before.
(as nikie mentions, the low-level line segment drawer avoids drawing over- lapping points, but the "line" wrapper should add the last pixel)
</F>
Hey! It's not ME for once. :) It seems to only happen with lines that have
a vertical-ness to them (straight up-down or diagonal). It doesn't seem to
happen when the line segment is just horizontal.
These are the characters that I am drawing www.greschke.com/unlinked/images/graphs.png
It works really well.
Thanks!
Bob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Max M |
last post by:
I am using PIL to generate som graphs, like:
draw = ImageDraw.Draw(im)
for graph in self.graphs:
polygon = graph.getPolygon()
draw.polygon(polygon, outline=graph.color)
del draw
But the...
|
by: nephish |
last post by:
Hey there.
i want to set a variable to represent the last line of a text file
how do i do that?
or even better, how do i create a list of the lines of a text file?
|
by: Edd Dawson |
last post by:
Hi. I have a strange problem involving the passing of command line
arguments to a C program I'm writing. I tried posting this in
comp.programming yesterday but someone kindly suggested that I'd...
|
by: DraguVaso |
last post by:
Hi,
For my application I need the following behavior: When I press F4 the cursor
has to move to the next line in my multiline textbox which begins with "0".
Finding lines starting with 0 isn't...
|
by: alexandre_irrthum |
last post by:
Hi there,
I am puzzled by the comportment of the line function from the ImageDraw
module with regard to the way it draws or does not draw the last pixel
of a line.
Below I test this function...
|
by: alexandre_irrthum |
last post by:
Hi there,
Sorry to repost this, but I didn't get any answer one month ago. In
essence, it seems that the ImageDraw line function draws lines one
pixel shorter in some circumstances. This could...
|
by: aljosa |
last post by:
is it possible to create transparent text (~50% transparency) on image?
i'm using the following code to draw text on image:
font = ImageFont.truetype(str(self.font_family)+".ttf", self.font_size)...
|
by: Daniel Mark |
last post by:
Hello all:
I am looking the sample code posted on PIL website
http://www.pythonware.com/library/pil/handbook/imagedraw.htm
################################################
<<Draw a Grey Cross...
|
by: Bryan Parkoff |
last post by:
I want to know the best practice to write on both C / C++ source codes.
The best practice is to ensure readable. Should left brace be after
function or if on the same line or next line.
For...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |