* Re: [9fans] moving things in a window
@ 2000-09-20 4:09 okamoto
0 siblings, 0 replies; 4+ messages in thread
From: okamoto @ 2000-09-20 4:09 UTC (permalink / raw)
To: 9fans
I forgot to add one more point.
When an item of a category is chosen to use, the item comes to be
the default value of the menubar of that category.
Kenji
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] moving things in a window
@ 2000-09-20 3:35 okamoto
0 siblings, 0 replies; 4+ messages in thread
From: okamoto @ 2000-09-20 3:35 UTC (permalink / raw)
To: 9fans
Russ's usage of mask image is interesting, however the difficult point
to apply this mask image to rubber-banding I met was:
imgmask = allocimage(display, Rect(-Msize-2, -Msize-2, Msize+2, Msize+2), GREY1, 0, DWhite);
where Msize is pre-defined as 100. ^_^
Another point on this maskimage is that it masks all the things.
I'd love to see this kind of discussion more here.
So, I'd like to add a proposal concerning the user interface of Plan 9
graphics programs, or guidelines to make user interface for Plan 9
graphic programms.
When I updated art program for release 3 rio, I had a feeling to make
menubar like X or Windows is not so good for Plan 9. However, it's
good to have such a menu bar in the top of the screen. The mouse
button for pulldown menu acts just like one button mouse, and it's
bad for plan 9.
In acme, we have a rigid rule, that is button 2 executes the file, and
button 3 shows the content of the file. So, Why we cannot apply this
rule to other graphic programms. For an example, menubar shows
default values of some categories, and button 2 executes it, and
button 3 shows popups the contents of its category. It means we
don't have pulldown menu bar, and we can have multiple lines of
menubar.
Like this:
------------------------------------------------------
Circle Blue Text Solidblush Solidline Smallspray ...
------------------------------------------------------
When button 3 on Circle, we'll see a popup menue to show
circle
line
ellipse
poligon
fill circle
fill ellipse
etc...
When we push button 2 or 3 in other reagion of the canvas, we'll see
some programm dependent global menu.
Above method will save the canvas space which is usually occupied
by many icons.
Kenji
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] moving things in a window
@ 2000-09-19 20:06 Russ Cox
0 siblings, 0 replies; 4+ messages in thread
From: Russ Cox @ 2000-09-19 20:06 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
I must say it works quite ok on my ati card (processor speed not being of
importance) and the only problem i see is the refresh of the screen...
The refresh of the screen is not so much
the problem as the flashing you get by
completely erasing the ball and then
redrawing it a moment later.
Try the attached instead, which does not
erase the pixels which will be immediately
redrawn.
Russ
[-- Attachment #2: aamball.c --]
[-- Type: text/plain, Size: 4286 bytes --]
/* draw a bouncing ball with variable
* coloring, optional trace and size
*
* -- andrey
*/
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <thread.h>
#include <event.h>
int minx, miny, maxx, maxy; /* window dimensions */
Point p1; /* center of circle drawn */
void
eresized(int new)
{
/* called whenever a window is resized -- reset dimensions and
* restart drawing
*/
Rectangle r1;
if(new && getwindow(display, Refnone) < 0)
fprint(2,"can't reattach to window");
r1 = screen->r;
minx = r1.min.x;
maxx = r1.max.x;
miny = r1.min.y;
maxy = r1.max.y;
/* circle always starts at same point */
p1.x = r1.min.x + 100;
p1.y = r1.min.y + 100;
/* clean up display */
draw(screen, r1, display->white, nil, ZP);
}
enum { Msize = 100 };
void
main(int argc, char **argv)
{
Mouse m;
Image *img, *imgmask;
/* img -- color used for drawing ball
* imgmask -- black ball on white, mask for drawing an inverse ball
*/
int slp = 10; /* interval between drawings */
int osize, size = 10;
Point oldp; /* previous location of circle */
uint upx = 1; /* flags for movements, should be enum-ed */
uint upy = 1;
uint colors = 0; /* do we draw with random colors */
uint clear = 1; /* do we clean up after the circle */
/* menus for mouse clicks in window */
char *items[] = { "slower", "faster", "exit", nil };
char *items2[] = { "clear", "colors", nil };
char *items3[] = {"bigger", "smaller", nil };
/* ordering does not correspond to mouse buttons -- too lazy to fix */
Menu menu;
Menu menu2;
Menu menu3;
/* setup menus */
menu.item = items;
menu.gen = nil;
menu2.item = items2;
menu2.gen = nil;
menu3.item = items3;
menu3.gen = nil;
srand(0);
initdraw(0,0,"whoopty doo");
eresized(0);
einit(Emouse);
imgmask = allocimage(display, Rect(-Msize-2, -Msize-2, Msize+2, Msize+2), GREY1, 0, DWhite);
osize = 0;
for(;;){
/* handle mouse clicks if any */
if(ecanmouse()) {
m = emouse();
if(m.buttons & 4) {
switch(emenuhit(3, &m, &menu)) {
case 0: slp += 10; break;
case 1: if(slp > 0)
slp -= 10;
else
slp = 0;
break;
case 2: exits("user abort");
default: ;
}
//eresized(0);
} else if(m.buttons & 2) {
switch(emenuhit(2, &m, &menu2)) {
case 0: if (clear)
clear = 0;
else
clear = 1;
break;
case 1: if (colors)
colors = 0;
else
colors = 1;
break;
default: ;
}
//eresized(0);
} else if(m.buttons & 1) {
switch(emenuhit(1, &m, &menu3)) {
case 0: if((size += 5) > 100)
size = 100;
break;
case 1: if((size -= 5) < 1)
size = 0;
break;
default: ;
}
//eresized(0);
}
}
if (colors)
/* use some sort of random coloring.. ugly */
img = allocimagemix(display,nrand(256)<<24 | nrand(256) << 16 | nrand(256) <<8 | (256 - nrand(256)),nrand(256)<<24 | nrand(256) << 16 | nrand(256) <<8 | (256 - nrand(256)));
else
/* just draw a black circle */
img = allocimagemix(display, DBlack, DBlack);
/* calculate new position */
if (upx)
oldp.x = p1.x++;
else
oldp.x = p1.x--;
if(upy)
oldp.y = p1.y++;
else
oldp.y = p1.y--;
/* see if we've reached window limits */
if (p1.x - size < minx)
upx = 1; /* start moving upwards */
else if (p1.x + size > maxx)
upx = 0;
if (p1.y - size < miny)
upy = 1;
else if (p1.y +size > maxy)
upy = 0;
/* clean up previous location */
if (osize && clear) {
draw(imgmask, imgmask->r, display->black, nil, ZP); // transparent
fillellipse(imgmask, subpt(oldp, p1), osize, osize, display->white, ZP); // draw opaque old
fillellipse(imgmask, ZP, size, size, display->black, ZP); // cover new
draw(screen, rectaddpt(imgmask->r, p1), display->white, imgmask, imgmask->r.min);
}
/* draw */
fillellipse(screen, p1, size, size, img, ZP);
flushimage(display, 1);
osize = size;
/* deallocate current colour */
freeimage(img);
/* slow down the drawing somehow */
sleep(slp);
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [9fans] moving things in a window
@ 2000-09-18 18:04 Andrey A Mirtchovski
0 siblings, 0 replies; 4+ messages in thread
From: Andrey A Mirtchovski @ 2000-09-18 18:04 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: TEXT/PLAIN, Size: 478 bytes --]
Hello,
I stopped playing with graphics on plan9 for a while, but last night
(being sleep deprived for no reason) I sat down and implemented a simple
bouncing ball.
I must say it works quite ok on my ati card (processor speed not being of
importance) and the only problem i see is the refresh of the screen...
please take a look and comment/flame as you see fit...
obligatory screenshot located at:
http://homepage.usask.ca/aam396/scrsht2.gif
andrey
[-- Attachment #2: Type: TEXT/PLAIN, Size: 3883 bytes --]
/* draw a bouncing ball with variable
* coloring, optional trace and size
*
* -- andrey
*/
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <thread.h>
#include <event.h>
int minx, miny, maxx, maxy; /* window dimensions */
Point p1; /* center of circle drawn */
void
eresized(int new)
{
/* called whenever a window is resized -- reset dimensions and
* restart drawing
*/
Rectangle r1;
if(new && getwindow(display, Refnone) < 0)
fprint(2,"can't reattach to window");
r1 = screen->r;
minx = r1.min.x;
maxx = r1.max.x;
miny = r1.min.y;
maxy = r1.max.y;
/* circle always starts at same point */
p1.x = r1.min.x + 100;
p1.y = r1.min.y + 100;
/* clean up display */
draw(screen, r1, display->white, nil, ZP);
}
void
main(int argc, char **argv)
{
Mouse m;
Image *img, *img2; /* img -- color used for drawing ball
* img2 -- white to clean up traces
*/
int slp = 10; /* interval between drawings */
int size = 10;
Point oldp; /* previous location of circle */
uint upx = 1; /* flags for movements, should be enum-ed */
uint upy = 1;
uint colors = 0; /* do we draw with random colors */
uint clear = 1; /* do we clean up after the circle */
/* menus for mouse clicks in window */
char *items[] = { "slower", "faster", "exit", nil };
char *items2[] = { "clear", "colors", nil };
char *items3[] = {"bigger", "smaller", nil };
/* ordering does not correspond to mouse buttons -- too lazy to fix */
Menu menu;
Menu menu2;
Menu menu3;
/* setup menus */
menu.item = items;
menu.gen = nil;
menu2.item = items2;
menu2.gen = nil;
menu3.item = items3;
menu3.gen = nil;
srand(0);
initdraw(0,0,"whoopty doo");
eresized(0);
einit(Emouse);
img2 = allocimagemix(display, DWhite, DWhite); /* clear colour */
for(;;){
/* handle mouse clicks if any */
if(ecanmouse()) {
m = emouse();
if(m.buttons & 4) {
switch(emenuhit(3, &m, &menu)) {
case 0: slp += 10; break;
case 1: if(slp > 0)
slp -= 10;
else
slp = 0;
break;
case 2: exits("user abort");
default: ;
}
//eresized(0);
} else if(m.buttons & 2) {
switch(emenuhit(2, &m, &menu2)) {
case 0: if (clear)
clear = 0;
else
clear = 1;
break;
case 1: if (colors)
colors = 0;
else
colors = 1;
break;
default: ;
}
//eresized(0);
} else if(m.buttons & 1) {
switch(emenuhit(1, &m, &menu3)) {
case 0: if((size += 5) > 100)
size = 100;
break;
case 1: if((size -= 5) < 1)
size = 0;
break;
default: ;
}
//eresized(0);
}
}
if (colors)
/* use some sort of random coloring.. ugly */
img = allocimagemix(display,nrand(256)<<24 | nrand(256) << 16 | nrand(256) <<8 | (256 - nrand(256)),nrand(256)<<24 | nrand(256) << 16 | nrand(256) <<8 | (256 - nrand(256)));
else
/* just draw a black circle */
img = allocimagemix(display, DBlack, DBlack);
/* calculate new position */
if (upx)
oldp.x = p1.x++;
else
oldp.x = p1.x--;
if(upy)
oldp.y = p1.y++;
else
oldp.y = p1.y--;
/* see if we've reached window limits */
if (p1.x - size < minx)
upx = 1; /* start moving upwards */
else if (p1.x + size > maxx)
upx = 0;
if (p1.y - size < miny)
upy = 1;
else if (p1.y +size > maxy)
upy = 0;
/* clean up previous location */
if (clear)
fillellipse(screen, oldp, size, size, img2, ZP);
/* draw */
fillellipse(screen, p1, size, size, img, ZP);
flushimage(display, 1);
/* deallocate current colour */
freeimage(img);
/* slow down the drawing somehow */
sleep(slp);
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-09-20 4:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-20 4:09 [9fans] moving things in a window okamoto
-- strict thread matches above, loose matches on Subject: below --
2000-09-20 3:35 okamoto
2000-09-19 20:06 Russ Cox
2000-09-18 18:04 Andrey A Mirtchovski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).