• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

hide object

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
If I draw, say, a circle, how do I make it hidden and, of course, visible again.
Thanks!
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dalibor,
You can do it 2 different ways.
1. Draw it with some color (not background) to show. Draw it with background to hide it.
2. Set XOR graphics mode. Draw it with some color will now toggle it from shown to hidden.
Regards,
Manfred.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
There are lots of ways to do what you are asking. Here are a few of them:
You could just draw a new circle on top of the original, this time using the background color.

You could use clearRect(x, y, width, height) to clear a rectangle (draw a filled rectangle of the background color) surrounding the circle.

Note: The cleared rectangle width and height are set to be one pixel wider and taller than one might think is necessary. Play with it to convince yourself that this is necessary.
You could use an image file containing a circle and another blank image file and display the blank image on top of the circle image.

You could use double-buffering techniques to first draw to an offscreen image buffer and then display that image when the time is right. This is especially useful when you need smooth animation effects.

Note: There are cleaner implementations of Double-Buffering, but this one is a beginning.
Hopefully something here helps you.
Good Luck,
-Dirk Schreckmann
[ January 31, 2002: Message edited by: Dirk Schreckmann ]
 
Dalibor Toth
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, all I can comment is thank you!
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic