473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

drawing a line

Hi everyone,
I'm an artist and I'm looking for a way to draw a line that will zig-zag
its way thru an image randomly, crisscrossing itself many times, based
on random numbers.

To give you an idea of what I'd like to do, here's a link to a gif :
http://www.chaosmos.net/chaosmoseng/chaosmos7.htm
(it is based on a simple algorithm :
http://www.chaosmos.net/chaosmoseng/chaosmos6.htm)

Is there a way to do that or am I barking up the wrong tree?

As a side note, I don't know anything about C language, I do only have
some knowledge of shell scripting and php.
FWIW I'm a FreeBSD user, so there is no OS issue.
Thanks for your answers

marko
Nov 24 '06 #1
14 2098
marko wrote:
I'm an artist and I'm looking for a way to draw a line that will zig-zag
its way thru an image randomly, crisscrossing itself many times, based
on random numbers.

To give you an idea of what I'd like to do, here's a link to a gif :
http://www.chaosmos.net/chaosmoseng/chaosmos7.htm
(it is based on a simple algorithm :
http://www.chaosmos.net/chaosmoseng/chaosmos6.htm)

Is there a way to do that or am I barking up the wrong tree?
well it's certainly programmable, But standard C, which this ng
discusses,
doesn't provide any graphics primitives. So you would need to pick a
graphics package of some sort, and that's off-topic to this ng. Try
looking
for a graphics ng they may be able to give more help.

As a side note, I don't know anything about C language, I do only have
some knowledge of shell scripting and php.
C may not be your best option then. Python maybe? Probably a similar
learning curve, but lots of goodies in the standard library.
FWIW I'm a FreeBSD user, so there is no OS issue.
why no OS issue? You've eliminated MSs GDI for instance.
--
Nick Keighley

Nov 24 '06 #2
Nick Keighley said:
marko wrote:
>I'm an artist and I'm looking for a way to draw a line that will zig-zag
its way thru an image randomly, crisscrossing itself many times, based
on random numbers.

To give you an idea of what I'd like to do, here's a link to a gif :
http://www.chaosmos.net/chaosmoseng/chaosmos7.htm
(it is based on a simple algorithm :
http://www.chaosmos.net/chaosmoseng/chaosmos6.htm)

Is there a way to do that or am I barking up the wrong tree?

well it's certainly programmable, But standard C, which this ng
discusses,
doesn't provide any graphics primitives. So you would need to pick a
graphics package of some sort, and that's off-topic to this ng. Try
looking
for a graphics ng they may be able to give more help.
Well, that's not necessarily true. He could write all the necessary code in
standard C. I've done it, so I don't see why he can't, if he's prepared to
spend enough time learning. I should add that I haven't actually
implemented his precise requirements, but I /have/ written code that can
load a bitmap file into into memory, perform various graphical operations
on it, and write it back out to a file, and that would probably be all he
needs - he can use something like Image-Magick to do any necessary file
conversions. Okay, so I rely on having sufficient memory to load the image,
I'll grant you that, but my code works quite happily on Windows and Linux,
and I have no doubts whatsoever that it would also work on a mini, a
mainframe, or a Mac - or indeed anything that has sufficient memory
available to it.

Um, okay, a caveat - I'm not 100% sure it would cope on systems with huge
CHAR_BIT values, at least not without going back and looking closely at it
to check. So it might not work on some ancient mainframes or some modern
DSPs. But, given that caveat, it would probably be considered
comp.lang.c-conforming, so to speak.

<snip>
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 24 '06 #3
Richard Heathfield wrote:
Nick Keighley said:
>marko wrote:
>>I'm an artist and I'm looking for a way to draw a line that will zig-zag
its way thru an image randomly, crisscrossing itself many times, based
on random numbers.

To give you an idea of what I'd like to do, here's a link to a gif :
http://www.chaosmos.net/chaosmoseng/chaosmos7.htm
(it is based on a simple algorithm :
http://www.chaosmos.net/chaosmoseng/chaosmos6.htm)

Is there a way to do that or am I barking up the wrong tree?
well it's certainly programmable, But standard C, which this ng
discusses,
doesn't provide any graphics primitives. So you would need to pick a
graphics package of some sort, and that's off-topic to this ng. Try
looking
for a graphics ng they may be able to give more help.

Well, that's not necessarily true. He could write all the necessary code in
standard C. I've done it, so I don't see why he can't, if he's prepared to
spend enough time learning. I should add that I haven't actually
implemented his precise requirements, but I /have/ written code that can
load a bitmap file into into memory, perform various graphical operations
on it, and write it back out to a file, and that would probably be all he
Of course he may just want to get the job done, in which
case using a library or two might help. Especially if
you want to do things like draw anti-aliased lines and
don't want to have to learn the algorithms.
(The quick hack approach is to write out a raw bitmap
and use a graphics program capable of importing it, but
that quickly gets tiresome)
>
Um, okay, a caveat - I'm not 100% sure it would cope on systems with huge
CHAR_BIT values, at least not without going back and looking closely at it
to check. So it might not work on some ancient mainframes or some modern
DSPs. But, given that caveat, it would probably be considered
comp.lang.c-conforming, so to speak.
You're talking about reading binary file formats and adjusting
for the fact that your implementation has a bizarre choice
of CHAR_BIT (one not equal to 8...). Is this done by masking
and bit shifts?

--
imalone
Nov 24 '06 #4
Ian Malone said:

<snip>
You're talking about reading binary file formats and adjusting
for the fact that your implementation has a bizarre choice
of CHAR_BIT (one not equal to 8...). Is this done by masking
and bit shifts?
Yes, although if you're very very lucky, CHAR_BIT is 24, in which case .bmp
loads and saves actually become simpler!

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 24 '06 #5
Richard Heathfield a écrit :
Well, that's not necessarily true. He could write all the necessary code in
standard C. I've done it, so I don't see why he can't, if he's prepared to
spend enough time learning. I should add that I haven't actually
implemented his precise requirements, but I /have/ written code that can
load a bitmap file into into memory, perform various graphical operations
on it, and write it back out to a file, and that would probably be all he
needs - he can use something like Image-Magick to do any necessary file
conversions. Okay, so I rely on having sufficient memory to load the image,
I'll grant you that, but my code works quite happily on Windows and Linux,
and I have no doubts whatsoever that it would also work on a mini, a
mainframe, or a Mac - or indeed anything that has sufficient memory
available to it.
This is interesting.
Would it be possible to get a copy of your code?
I'd be interested in testing it, and see if I can do anything from there
(as mentioned, I'm really not a c programmer)

m
Nov 24 '06 #6
Nick Keighley a écrit :
well it's certainly programmable, But standard C, which this ng
discusses,
doesn't provide any graphics primitives. So you would need to pick a
graphics package of some sort, and that's off-topic to this ng. Try
looking
for a graphics ng they may be able to give more help.
ok, thanks for the tip!
Nov 24 '06 #7
marko <ma***@nullepart.euwrote:
# Hi everyone,
# I'm an artist and I'm looking for a way to draw a line that will zig-zag
# its way thru an image randomly, crisscrossing itself many times, based
# on random numbers.

# As a side note, I don't know anything about C language, I do only have
# some knowledge of shell scripting and php.

Unless this is an exercise to learn C, I wouldn't use C or
any derivatives because there is so much overhead just getting
started. Other languages like Wish allow you to get graphics
up on your screen more easily.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Raining down sulphur is like an endurance trial, man. Genocide is the
most exhausting activity one can engage in. Next to soccer.
Nov 24 '06 #8

On Fri, 24 Nov 2006, marko wrote:
Richard Heathfield a écrit :
>Well, that's not necessarily true. He could write all the necessary code in
standard C. I've done it, so I don't see why he can't, if he's prepared to
spend enough time learning. I should add that I haven't actually
implemented his precise requirements, but I /have/ written code that can
load a bitmap file into into memory, perform various graphical operations
on it, and write it back out to a file, and that would probably be all he
needs - he can use something like Image-Magick to do any necessary file
conversions. Okay, so I rely on having sufficient memory to load the image,
I'll grant you that, but my code works quite happily on Windows and Linux,
and I have no doubts whatsoever that it would also work on a mini, a
mainframe, or a Mac - or indeed anything that has sufficient memory
available to it.

This is interesting.
Would it be possible to get a copy of your code?
I'd be interested in testing it, and see if I can do anything from there (as
mentioned, I'm really not a c programmer)
I dunno about Richard's code (haven't looked for it), but I have what
sounds like a very similar image library at
http://www.contrib.andrew.cmu.edu/~a...re/ImageFmtc.h
http://www.contrib.andrew.cmu.edu/~a...re/ImageFmtc.c

(and other files named Image???c.? in that directory do related things).

Also, try searching the newsgroup archives.

HTH,
-Arthur
Nov 25 '06 #9
marko said:
Would it be possible to get a copy of your code?
I certainly plan to publish it one day, but not just yet.

But really, it doesn't do anything difficult. The BMP file format is - er,
the BMP file formats are - well-known and quite easy to parse, once you
realise something stupidly obvious (i.e. you can decide to deal exclusively
with 24-bit bitmaps, making your life a trillion times easier). And my
"frame buffer" is just a bunch of h pointers to long, each of which points
to w longs. There is nothing here that's hard to do, honest.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #10

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:3u********************@bt.com...
marko said:
>Would it be possible to get a copy of your code?

I certainly plan to publish it one day, but not just yet.

But really, it doesn't do anything difficult. The BMP file format is - er,
the BMP file formats are - well-known and quite easy to parse, once you
realise something stupidly obvious (i.e. you can decide to deal
exclusively
with 24-bit bitmaps, making your life a trillion times easier). And my
"frame buffer" is just a bunch of h pointers to long, each of which points
to w longs. There is nothing here that's hard to do, honest.
It's OK to write 24-bit bitmaps exclusively in these days of infinite hard
drives. However you still need to read the lot, unless you are in control of
whoever uses the program.
Then there is an evil little twist. Microsoft Visual Studio will only import
bitmaps that are upside down. That's right. MS programming dept can't even
parse their own file format.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.

Nov 25 '06 #11

"marko" <ma***@nullepart.euwrote in message
news:45***********************@news.free.fr...
Hi everyone,
I'm an artist and I'm looking for a way to draw a line that will zig-zag
its way thru an image randomly, crisscrossing itself many times, based on
random numbers.

To give you an idea of what I'd like to do, here's a link to a gif :
http://www.chaosmos.net/chaosmoseng/chaosmos7.htm
(it is based on a simple algorithm :
http://www.chaosmos.net/chaosmoseng/chaosmos6.htm)

Is there a way to do that or am I barking up the wrong tree?

As a side note, I don't know anything about C language, I do only have
some knowledge of shell scripting and php.
FWIW I'm a FreeBSD user, so there is no OS issue.
Thanks for your answers
Off-topic but
This looks like a job for BASICdraw.
The program is avialable for free on my website and marries a BASIC
intepreter to image-handling software.
You can save as BMP, by the way, a little bug makes it look as though the
only save format is JPEG.
Version 1.1 with some fixes is nearly due for release, so tell me on any
more bugs or enhancement requests.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
Nov 25 '06 #12
Malcolm said:
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:3u********************@bt.com...
>>
[...] The BMP file format is -
er, the BMP file formats are - well-known and quite easy to parse, once
you realise something stupidly obvious (i.e. you can decide to deal
exclusively with 24-bit bitmaps, making your life a trillion times
easier). [...]
It's OK to write 24-bit bitmaps exclusively in these days of infinite hard
drives. However you still need to read the lot, unless you are in control
of whoever uses the program.
Yes, one day I suppose I'll extend my reader to read any bitmap, but for now
it meets my needs, as I am the one who converts the images into bitmap
format in the first place, so I'm careful to use something which knows
(such as the GIMP, or Image-Magick, or - to be fair - almost anything,
nowadays).
Then there is an evil little twist. Microsoft Visual Studio will only
import bitmaps that are upside down. That's right. MS programming dept
can't even parse their own file format.
<shrugI suppose I could care less, but it's difficult to see how. I am not
attracted to bitmaps because of their (limited) support in Windows, but
because BMP (or at least the subset of it that I choose to acknowledge) is
a nice simple non-lossy file format that's dead easy to read into a frame
buffer for graphical messing about with in ISO C. It's the graphical
messing about in ISO C which interests me, not the peculiarities of
storage. Otherwise I'd be using GIF or JPEG or PNG or something.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #13
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
Malcolm said:
>"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:3u********************@bt.com...
>>>
[...] The BMP file format is -
er, the BMP file formats are - well-known and quite easy to parse, once
you realise something stupidly obvious (i.e. you can decide to deal
exclusively with 24-bit bitmaps, making your life a trillion times
easier). [...]
It's OK to write 24-bit bitmaps exclusively in these days of infinite
hard
drives. However you still need to read the lot, unless you are in control
of whoever uses the program.

Yes, one day I suppose I'll extend my reader to read any bitmap, but for
now
it meets my needs, as I am the one who converts the images into bitmap
format in the first place, so I'm careful to use something which knows
(such as the GIMP, or Image-Magick, or - to be fair - almost anything,
nowadays).
>Then there is an evil little twist. Microsoft Visual Studio will only
import bitmaps that are upside down. That's right. MS programming dept
can't even parse their own file format.

<shrugI suppose I could care less, but it's difficult to see how. I am
not
attracted to bitmaps because of their (limited) support in Windows, but
because BMP (or at least the subset of it that I choose to acknowledge) is
a nice simple non-lossy file format that's dead easy to read into a frame
buffer for graphical messing about with in ISO C. It's the graphical
messing about in ISO C which interests me, not the peculiarities of
storage. Otherwise I'd be using GIF or JPEG or PNG or something.
I agree.
PCs are also very good for low-end graphical work. BMP is the one format
that virtually every PC tool will support.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.

Nov 25 '06 #14
Arthur J. O'Dwyer a écrit :
I dunno about Richard's code (haven't looked for it), but I have what
sounds like a very similar image library at
http://www.contrib.andrew.cmu.edu/~a...re/ImageFmtc.h
http://www.contrib.andrew.cmu.edu/~a...re/ImageFmtc.c

(and other files named Image???c.? in that directory do related things).
thanks, I'll take a look at it!
Also, try searching the newsgroup archives.
ditto

m
Nov 25 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Remon Huijts | last post by:
Hi there, For a very specific service, I have created a PHP script that uses the GD library functions to create a PNG image from a few lines of XML data describing a simple diagram/drawing. It's...
8
by: john | last post by:
Hi I am a C++ newbie, I am looking to draw single lines and simple boxes in a C++ console window. Is there a draw command with x and y coordinates that can be used with my Dev C++ compiler. For...
0
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as...
9
by: Steve Long | last post by:
Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox. I just want a straight, dotdash line. I have two methods, one works and one doesn't (it cause...
6
by: Rene | last post by:
I tried searching the newsgroups to see how do you draw a dotted line but I was unable to find an answer, drawing a straight line is very easy but not a dotted one. So the question is, how do I...
2
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
4
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
2
by: mattc66 via AccessMonster.com | last post by:
Does anyone know of some simple line drawing add-on apps. I just need to be able to do some simple line drawing with dims. 4 walls and a door and allow the user to type the dims for the walls. All...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.